Open Map 4.6.5


OpenMap is open source software written in Java which deals with geographic data. It provides plenty of examples but finding exactly what you need can sometimes be difficult.

Reading Road Data from an ESRI Shape File in Lat/Long format

OpenMap version: 4.6.5
ESRI Shape File version: TIGER2009

There are two parts to reading road data – there’s reading the “shape” data (i.e. lines), and reading whether a particular line represents a road or represents something else. Lines can be read using as shown below. Whether or not a particular record is a road or not, is represented by the road flag, aka “ROADFLG.” The ROADFLG can be read using … as shown below.

Reading the shape of Polylines

Method: public static void main(String args[])
Usage: Pass in the full path to the .shp file as the first and only argument. The data type ESRIRecord holds the lat/long data.

bounds: Two lat/long points which describe the bounding box of the line(s).
polygons: holds various parts / polygons
radians: holds points used to plot the road/line data

In addition to the bounding box, there are a number of associated polygons (usually only one as far I can tell) with a number of “radians” associated with the polygon. These are coordinates inside the bounding box which are used to actually form the Polyline. The Polyline is simply a string of lines that when drawn end to end approximate the curve of the road (i.e. it is the road shape).
Thus, in order to read the shape of a road, you’ll have to get the bounding box, then plot the points within the box, where the points are the radians.

Radians to Points

It turns out radians are a different format than the bounding box itself, which can make plotting them difficult. The conversion from “degrees” to “radians” is done by OpenMap automatically. To get the degrees you’ll have to drill down into the following classes and methods.

com.bbn.openmap.layer.shape.ESRIPolygonRecord (see variable “polygons” of type ESRIFloatPoly[])
getDecimalDegrees(); (method)

The decimal degrees are in the same format as the bounding box, that is, latitude and longitude. Once the points are available as lat/long points inside a lat/long bounding box, plotting the points requires converting from lat/long to x/y coordinates, and adjusting for the inherent “curve” of the measurement.

Reading the ROADFLG

This is less strange.

Class: com.bbn.openmap.plugin.esri.EsriPlugIn
Method: public static void main(String[] argv)
Usage: Pass in the full path to the .shp file as the first and only argument. The data type DbfTableModel will hold the ROADFLG once the file is read.

One of the columns will be named “ROADFLG” and the record number corresponds to the row number. So you can read whether a certain row has “Y” for the ROADFLG by using .getValueAt(row, col).

 Posted by at 9:40 pm

  One Response to “Open Map 4.6.5”

  1. Do you have an example of how to dynamically draw points (OMPoint) in a list (OMGraphicsList) on the map? I have not had any success.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>