[OpenLayers-Users] OpenLayers.Control.ScaleLine accuracy issue
plen
peteralen at earthlink.net
Tue Jan 6 21:37:12 EST 2009
Christopher,
Thanks for the reply. I see that you work for MetaCarta so you are not as
confused about planar vs geodesic vs degrees vs projected units etc etc as I
am. A little background as to how we are using OpenLayers and what led me
to this question....
We are using a government mapping interface API (which is built upon
OpenLayers) for our 2D mapping solution. All base maps are populated by them
(Google Maps is not one of them). Calls to do something with the map are
either through the government API or I can make some calls directly to the
OpenLayers API.
I needed to find the map viewport's diagonal (SW to NE corner). To do this,
I was comparing two different methods: The OpenLayers distanceTo function
and another third party function that determines the length of 2 points on a
sphere. The distanceTo function always returned the same distance value,
regardless of where I was on the map while the other method always returned
a different value. This goes to the flat map vs a sphere thing. The reason
why I needed to viewport diagonal is that I need to determine the SW & NE
coordinates for the viewport at x zoom levels out from the current zoom
level. For example, the viewport might be at zoom level 13 and I need to
find what the viewport's SW & NE coordinates are if I were out at zoom level
10. To do this I get the bearings of the SW --> NE and NE <-- SW points and
then determine the distance out to the previous zoom level (for our 15 zoom
levels I found that the distance from the NE corner of zoom level x to the
NE corner of zoom level x-1 was half of the diagonal distance). Using the
bearing and the distance out, I can caluculate wher the SW & NE coordinates
are for the zoom level I need. In my tests, if I used the formula that
generated the diagonal based on 2 points on a sphere, the newly generated SW
& NE coordinates matched up exactly. When I say exactly, I meant that I
could plot the new points on the map and then draw a colored polygon based
on the viewport coordinates for the zoom level I was trying to go to and the
points would be at the SW & NE corners. If I used the distanceTo function
to determine the viewport diagonal, the generated points would be further
out and not match. The distanceTo function, like the map scale, seem to be
based on a flat map.
Now to your response..... while I am a little confused over what degrees vs
projected units is, I understood you to indicate that the OpenLayers map is
a 2d flat map and the scale is based on that premise. My confusion now is
that it seem that several OpenLayers mapping functions are based on degrees.
I say that because, for example, get the area of a polygon (using the
OpenLayers API) returns a value in square degrees. The distanceTo function
also returns a value in square degrees. Also, because my newly generated
points that were based on a distance determine by 2 points on a sphere
(rather than a flat map) exactly matched the OpenLayers zoom level corners
makes me think that OpenLayers must deal with degrees on the map.
That all being said, my head just spins when thinking of the whole issue of
geographic mathematics/algorithms. Now, I don't really know what to make of
what I mentioned above. I have to make the functionality for our mapping
requirements as accurate as possible and it doesn't seem that I can use some
functions that deal with map from a flat perspective along side with other
functions that deal with the map as a sphere. I am still trying to get my
hands wrapped around this issue and my forum question on the line scale was
part of this process. Out of this I am not even sure if I am asking another
question or just validation. In any case, I appreciate your initial
response and your time in taking my question.
Thanks - Peter Len
--
View this message in context: http://n2.nabble.com/OpenLayers.Control.ScaleLine-accuracy-issue-tp2117980p2120559.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list