views:

354

answers:

2

I'm using OpenMap and I'm reading a ShapeFile using com.bbn.openmap.layer.shape.ShapeFile. The bounding box is read in as lat/long points, for example 39.583642,-104.895486. The bounding box is a lower-left point and an upper-right point which represents where the points are contained. The "points," which are named "radians" in OpenMap, are in a different format, which looks like this: [0.69086486, -1.8307719, 0.6908546, -1.8307716, 0.6908518, -1.8307717, 0.69085056, -1.8307722, 0.69084936, -1.8307728, 0.6908477, -1.8307738, 0.69084626, -1.8307749, 0.69084185, -1.8307792].

How do I convert the points like "0.69086486, -1.8307719" into x,y coordinates that are usable in normal graphics?

I believe all that's needed here is some kind of conversion, because bringing the points into Excel and graphing them creates a line whose curve matches the curve of the road at the given location (lat/long). However, the axises need to be adjusted manually and I have no reference as how to adjust the axises, since the given bounding box appears to be in a different format than the given points.

The ESRI Shapefile technical description doesn't seem to mention this (http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf).

+1  A: 

0.69086486, -1.8307719 is a latitude and a longitude in radians.

First, convert to degrees (multiply by (180/pi)), then you will have common units between your bounding box and your coordinates.

Then you can plot all of it in a local frame with the following :

x = (longitude-longitude0)*(6378137*pi/180)*cos(latitude0*pi/180)
y = (latitude-latitude0)*(6378137*pi/180)

(latitude0, longitude0) are the coordinates of a reference point (e.g. the lower-left corner of the bounding box) units are degrees for angles and meters for distances

Edit -- explanation : This is an orthographic projection of the Earth considered as a sphere whose radius is 6378137.0 m (semi-major axis of the WGS84 ellipsoid), centered on the point (lat0, lon0)

Stéphane
Looks like you're right about the radians and the equations. How about an explanation of what the equations are doing?...
Aaron
Aaron would you mind sharing your ColdFusion code to read the Shapefile? Thanks find me on twitter same name
cfEngineers
A: 

In OpenMap, there are a number of ways to convert from radians to decimal degrees:

Length.DECIMAL_DEGREE.fromRadians(radVal); Math.toDegrees(radVal) // Standard java library

For an array, you can use ProjMath.arrayDegToRad(double[] radvals);

Be careful with that last one, it does the conversion in place. So if you grab a lat/lon array from an OMPoly, make a copy of it first before converting it. Otherwise, you'll mess up the internal coordinates of the OMPoly, which it expects to be in radians.

Don