Re: [OpenMap Users] Problems rendering a layer

From: JR Andreassen <janrune_at_io.com>
Date: Thu, 10 Aug 2006 15:18:38 -0500

Sure...

I traced through it. The org.wkb4j.engine.WKBReader returns
OMGraphicsList with OMPoint/OMLines/OMPolygon.
They look fine to me in World Coord, not sure about the SRID though...
Thanks for taking a look at it...
   JR

Here is the code...
public abstract class DB2GSEGeometryLayer extends OMGraphicHandlerLayer
{
...
    // -------------------------------------------------------------
    public synchronized OMGraphicList prepare()
    {
        OMGraphicList retVal = null;
        int geomcoltype = OpenGIS_Elements.getElementID(geomColumnType);

        Projection proj = getProjection();

        if (proj == null)
        {
            Debug.output("DB2GSEGeometryLayer.prepare: null projection!");
            return null;
        }


        if (Debug.debugging("DB2GSE"))
        {
            Debug.output("DB2GSEGeometryLayer Driver: " + dbClass);
        }

        Connection conn = getConnection();
        if(conn == null)
        {
            if (Debug.debugging("DB2GSE"))
            {
                Debug.output("DB2GSEGeometryLayer Connection failed: ");
            }
            return retVal;
        }

        retVal = handleWK(proj, conn);
/* OMGraphicList ret = handleWK(proj, conn);
        if(ret != null)
        {
            OMGraphic omg = null;
            int sz = ret.size();
            retVal = new OMGraphicList(sz);
            for(int idx = 0; idx < sz; idx++)
            {
                omg = ret.getOMGraphicAt(idx);
                omg.generate(proj);
                retVal.add(omg);
            }
        }
// synchronized(myGraphicsList)
// { myGraphicsList = retVal;}
*/
        if(retVal != null)
        { retVal.generate(proj);}
        return retVal;
    }
    // -------------------------------------------------------------
    protected abstract OMGraphicList handleWK(Projection proj,
Connection conn);
}
-----------------------------------------------------------------------------------
public class DB2GSEGeometryWKBLayer extends DB2GSEGeometryLayer
{
...
// ---------------------------------------------------------
    protected synchronized OMGraphicList handleWK(Projection proj,
Connection conn)
    {
        OMGraphicList retVal = null;
        // SELECT srid(geocolumn) AS srid, asbinary(geocolumn,'XDR') AS
wkb FROM geotable WHERE id BETWEEN 125 AND 168
// String SQLstring = "SELECT GID, SRID, WKB FROM " + geomTable;
//+ " WHERE GID = 186";
        String SQLstring = "SELECT * FROM " + geomTable; //+ " WHERE GID
= 186";
/* + " WHERE
"+OpenGIS_Elements.getElementString(OpenGIS_Elements.FN_INTERSECTS)+"("
+ OpenGIS_Elements.getElementString(OpenGIS_Elements.FN_ENVELOPE) +"("+
geomColumn + "), "
                                        +
OpenGIS_Elements.getElementString(OpenGIS_Elements.TYPE_GEOMETRY)
+"('Polygon(( "
                                        +
getProjection().getUpperLeft().getLongitude() + " "
                                        +
getProjection().getUpperLeft().getLatitude() + ", "
                                        +
getProjection().getUpperLeft().getLongitude() + " "
                                        +
getProjection().getLowerRight().getLatitude() + ", "
                                        +
getProjection().getLowerRight().getLongitude() + " "
                                        +
getProjection().getLowerRight().getLatitude() + ", "
                                        +
getProjection().getLowerRight().getLongitude() + " "
                                        +
getProjection().getUpperLeft().getLatitude() + ", "
                                        +
getProjection().getUpperLeft().getLongitude() + " "
                                        +
getProjection().getUpperLeft().getLatitude() + "))',
"+OpenGIS_Elements.getElementString(OpenGIS_Elements.FN_SRSID) +"("+
geomColumn + ") )) > 0 ";
*/
        if (Debug.debugging("DB2GSE"))
        {
            Debug.output("DB2GSEGeometryWKBLayer query: " + SQLstring);
        }
        // Create the WKBReader.
        DB2GSE_WKBReader reader = new DB2GSE_WKBReader();
        // For this demo we will be using the OpenMapFactory.
        OpenMapFactory factory = new OpenMapFactory();
        // Create the WKBParser.
        DB2GSE_WKBParser parser = new DB2GSE_WKBParser(factory);
/*
                /* You can complement this query with your own code.
                reader.readData(conn, SQLstring, parser);
                retVal = factory.getGeometries();
*/
// OpenMapGetter getter = new OpenMapGetter();
// retVal = getter.getOMGraphicList(conn, SQLstring);
        ResultSet rs = null;
        try
        {
            Statement stmt = conn.createStatement();
            stmt.executeQuery(SQLstring);
            List words = new ArrayList(1);
            words.add("srid");
            rs = stmt.getResultSet();

            readData(rs, parser, factory);
            retVal = ((OpenMapFactory) factory).getGeometries();
        }
        catch(SQLException sqle)
        {
            Debug.output("DB2GSEGeometryWKBLayer Exception: " + sqle);
        }
        if (rs != null)
        {
            try
            {
                rs.close();
            }
            catch(SQLException sqle)
            {}
        }
/*
                        // In the OpenMapFactory, completed Geometries
are stored internally
                        // and can be returned through this method.
                        ArrayList geomlist = factory.getGeometries();

                        // Log the result to the console.
                        Log.debug("Geometries: " + geomlist.size());
                        for (int i = 0; i < geomlist.size(); ++i) {
                                Geometry geom = (Geometry) geomlist.get(i);
                                if (Log.isDebugEnabled()) {
                                        Log.debug("Geometry " + i + " :
" + geom.toString());
                                }
                        }
*/
        if (Debug.debugging("DB2GSE"))
        {
            Debug.output("DB2GSEGeometryWKBLayer returning: " + retVal);
        }
        return retVal;
    }

...
}

> Do you want to post the code of your prepare() method?
>
> I'd check the list contents to make sure there are OMGraphics on it.
>
> The OMGraphicList won't have a shape itself, but it will call on all
> of the OMGraphics it contains to have them render themselves.
>
> - Don
>
> On Aug 10, 2006, at 3:11 PM, JR Andreassen wrote:
>
>> Hello Again...
>> I've got the WKB fetch working.
>> Now I have a problem with rendering.
>> For some reason it won't paint.
>> I've traced it, the problem seams to be that the OMGraphics list has
>> no shape...
>> In my OMGraphicHandlerLayer.prepare()
>> I get the OMGraphicList,
>> Then project on the list and return
>> Nothing displayed...
>> Ideas ??
>> Thanks
>> JR
>>
>>> [...]
>>> [java] US-States|Layer: repaint(tm=0, x=0, y=0, width=1084,
>>> height=956)
>>> [java] Graticule|Layer: repaint(tm=0, x=0, y=0, width=1084,
>>> height=956)
>>> [java] OMGraphicHandlerLayer Political Boundaries projection
>>> changed, calling com.bbn.openmap.layer.policy.ListResetPCPolicy
>>> [java] Political Boundaries: ListResetPCPolicy
>>> projectionChanged with OLD projection, repainting.
>>> [java] Political Boundaries|Layer: repaint(tm=0, x=0, y=0,
>>> width=1084, height=956)
>>> [java] Texas Counties(DB/2 GSE) |LayerWorker.construct()
>>> [java] DB2GSEGeometryLayer Driver: com.ibm.db2.jcc.DB2Driver
>>> [java] DB2GSEGeometryWKBLayer query: SELECT GID, SRID, WKB FROM
>>> COGDATA.OGIS_Counties
>>> [java] 0 [Thread-10] DEBUG org.wkb4j.engine.WKBReader - Final
>>> words: [srid]
>>> [java] Texas Counties(DB/2 GSE) |Layer: repaint(tm=0, x=0, y=0,
>>> width=1084, height=956)
>>> [java] DB2GSEGeometryWKBLayer returning:
>>> com.bbn.openmap.omGraphics.OMGeometryList_at_14d1d41
>>> [java] Texas Counties(DB/2 GSE) |LayerWorker.construct():
>>> fetched 254 graphics in 4.344 seconds
>>> [java] Texas Counties(DB/2 GSE) .paint(): NULL list, skipping...
>>> [java] Texas Counties(DB/2 GSE) |Layer: repaint(tm=0, x=0, y=0,
>>> width=1084, height=956)
>>



--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Thu Aug 10 2006 - 16:19:06 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:07 EDT