How do I draw points in an ESRI polyline given the bounding rectangle as lat / long and "points" as radians?
I am using OpenMap and I am reading ShapeFile using com.bbn.openmap.layer.shape.ShapeFile. The bounding box is read as lat / long dots, e.g. 39.583642, -104.895486. The bounding box is the bottom-left point and the top-right point that represents where the points are. The "points", which are called "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 points like "0.69086486, -1.8307719" to x, y coordinates that can be used in normal graphics?
I believe that all that is needed here is some kind of transformation, because casting the points in Excel and plotting them graphically creates a line whose curve corresponds to the curve of the road at a given location (lat / long). However, the axes need to be adjusted manually, and I have no link on how to adjust the axes as this bounding box appears in a different format than the points indicated.
The ESRI Shapefile datasheet doesn't seem to mention this ( http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf ).
a source to share
0.69086486, -1.8307719
- latitude and 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 display 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 the anchor point (like the bottom 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, viewed as a sphere whose radius is 6378137.0 m (semi-major axis of the WGS84 ellipsoid), centered on the point (lat0, lon0)
a source to share
There are several ways to convert from radians to decimal degrees in OpenMap:
Length.DECIMAL_DEGREE.fromRadians(radVal);
Math.toDegrees(radVal) // Standard java library
For an array, you can use ProjMath.arrayDegToRad (double [] radvals);
Be careful with the latter, it does the conversion in place. So if you grab the lat / lon array from OMPoly, make a copy of it first before converting it. Otherwise, you mess up the OMPoly's internal coordinates, which are expected to be in radians.
a source to share