[OpenMap Users] trying to understand EsriLayer

From: John Chamberlain <jchamberlain_at_cra.com>
Date: Mon, 21 May 2007 10:55:19 -0400

I am loading a zip code shape file (one of the standard ones from the
post office) with the class shown below. This load works because the
shapes show up later when the layer is rendered. My efforts to find out
the latitude/longitude of the loaded shapes is failing, however, and I
don't understand why. The code below uses getEsriGraphicList() and then
tries to print out the lat/lons, but the output is always all zeroes for
every shape. For example, typical output is:

item 613: 0.0 0.0 LATLON
item 614: 0.0 0.0 LATLON
item 615: 0.0 0.0 LATLON
item 616: list item 1: 0.0 0.0 LATLON
   list item 2: 0.0 0.0 LATLON
   list item 3: 0.0 0.0 LATLON
   list item 4: 0.0 0.0 LATLON
   list item 5: 0.0 0.0 LATLON
   list item 6: 0.0 0.0 LATLON
   list item 7: 0.0 0.0 LATLON
   list item 8: 0.0 0.0 LATLON

item 617: list item 1: 0.0 0.0 LATLON
   list item 2: 0.0 0.0 LATLON

item 618: 0.0 0.0 LATLON
item 619: 0.0 0.0 LATLON
item 620: 0.0 0.0 LATLON
item 621: list item 1: 0.0 0.0 LATLON
   list item 2: 0.0 0.0 LATLON
   list item 3: 0.0 0.0 LATLON
   list item 4: 0.0 0.0 LATLON
   list item 5: 0.0 0.0 LATLON

item 622: 0.0 0.0 LATLON
item 623: 0.0 0.0 LATLON
item 624: 0.0 0.0 LATLON
item 625: 0.0 0.0 LATLON
item 626: 0.0 0.0 LATLON
item 627: 0.0 0.0 LATLON

etc.

public class ZipcodeLayer extends EsriLayer
{
        private double[][] data;
        private int zctaColumn;
        private int rowCount;

        public ZipcodeLayer( String name, String dbf, String shp, String
shx, DrawingAttributes da ) throws MalformedURLException
        {
                super( name, dbf, shp, shx, da );
                rowCount = getModel().getRowCount();
                clear();
                com.bbn.openmap.dataAccess.shape.EsriGraphicList
graphic_list = this.getEsriGraphicList();
                for( int xList = 1; xList <= rowCount; xList++ )
                {
                        OMGraphic graphic = graphic_list.getOMGraphicAt(
xList - 1 );
                        System.out.println("item " + xList + ": " +
sRender_Graphic( graphic ) );
// java.util.Iterator iterator =
getModel().getRecords();
// java.util.ArrayList listFields =
(java.util.ArrayList)iterator.next();
// for()
                }
                
        }
        
        String sRender_Graphic( OMGraphic graphic ){
                if( graphic == null ){
                        return ("null");
                } else if( graphic instanceof OMPoly ){
                        OMPoly poly = (OMPoly)graphic;
                        return (" " + poly.getLat() + " " +
poly.getLon() + " " + sRender_RenderType( graphic.getRenderType() ) );
                } else if( graphic instanceof EsriPolygonList ){
                        StringBuffer sbList = new StringBuffer(10000);
                        EsriPolygonList poly_list =
(EsriPolygonList)graphic;
                        for( int xList = 1; xList <= poly_list.size();
xList++ ){
                                OMGraphic sub_graphic =
poly_list.getOMGraphicAt( xList - 1 );
                                sbList.append( " list item " + xList +
": " + sRender_Graphic( sub_graphic ) + "\n" );
                        }
                        return sbList.toString();
                } else {
                        return ( "class is " + graphic.getClass() );
                }
        }
        
        String sRender_RenderType( int iRENDER_TYPE ){
                switch( iRENDER_TYPE ){
                        case
com.bbn.openmap.layer.link.LinkGraphicConstants.RENDERTYPE_LATLON:
                                return "LATLON";
                        case
com.bbn.openmap.layer.link.LinkGraphicConstants.RENDERTYPE_OFFSET:
                                return "OFFSET";
                        case
com.bbn.openmap.layer.link.LinkGraphicConstants.RENDERTYPE_XY:
                                return "XY";
                        case
com.bbn.openmap.layer.link.LinkGraphicConstants.RENDERTYPE_UNKNOWN:
                                return "UNKNOWN";
                        default:
                                return "UNDEFINED";
                }
        }
}

Thanks for any assistance.

John S. Chamberlain
Charles River Analytics
 

--
[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 Mon May 21 2007 - 10:56:16 EDT

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