Re: [OpenMap Users] Reading and querying shapefiles

From: Don Dietrick <dfdietrick_at_gmail.com>
Date: Sun, 3 Jun 2012 11:34:38 -0400

Hi Kedar,

OpenMap has stuff to help you do this. Use the com.bbn.openmap.dataAccess.shape.ShapeGeoIndex. You can then make queries on that index to find out which shape pertains to different geospatial queries.

ShapeGeoIndex geoIndex = ShapeGeoIndex.builder(URL shapefile).create();
DbfTableModel. dbf = DbfTableModel.getDbfTableModel(URL dbffile);
Iterator extents = geoIndex.intersect(new GeoPoint.Impl(lat, lon));

extents will be all the GeoExtents that intersect with whatever GeoExtent was used in the intersection query. For a point over a bunch of non-intersecting areas (zip code areas), you should generally get one thing in that iterator).

>From that extent, you can get the ID, which will be the index of that extent/OMGraphic/Shape in the shape file.

for (GeoExtent geoExtent : extents) {
Object idObj = geoExtent.getID();

// You can query the dbf file for the column holding the zip codes.
// This idObj is an Integer object, you can use it on the dbf file to retrieve the row from the column, and
// there's your zip code.
}

Hope this helps,

- Don

=-=-=-=-=-=-=-=-=
Don Dietrick
_at_dfdietrick
=-=-=-=-=-=-=-=-=


On Friday, June 1, 2012 at 6:22 PM, Kedar Deshpande wrote:

> Hi,
>
> I am trying to create an application that reads a given shapefile and answers to queries like 'what is the zip code for given latitude,longitude'.
> I have a US Census TIGER shapefile that has Zipcode Tabulation Areas. I am not trying to plot or render any map using this file.
> I just need to get zipcode for a given lat/long. Is there a package, class in the OpenMap library that will help me in doing this ?
>
> Thanks,
> Kedar
>
>




--
[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 Sun Jun 03 2012 - 11:36:10 EDT

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