I have us state border shape file and I want to read information from that file using openmap api for java.Also to find the states within 50 miles of a given city. How can i do it?
A:
If you just want to inspect the contents of the file programmatically, you can read the information from the shape files using a com.bbn.openmap.dataAccess.shape.EsriGraphicList. There is a static getGraphicList(...) method that will load the shapes and the attributes stored in the dbf file.
If you want to display the contents of the file, use a com.bbn.openmap.layer.shape.ShapeLayer.
To do spatial analysis on the contents of a shape file, you'll need do to a little programmatic work, using the com.bbn.openmap.geo package:
- Create an ExtentIndex, which will be a collection of GeoExtents.
- Create GeoRegions from the EsriGraphicList EsriPolygons, add them to the ExtentIndex.
- Create GeoPoint for the city you want to test for.
- Create Intersection with MatchParameters being Length.MILE.toRadians(50).
- Call intersection.considerPointXRegions(GeoPoint, ExtentIndex);
- Call intersection.getCollector().iterator() to get results.
Don
2010-08-09 15:23:10