[OpenLayers-Users] transformation issues

Phil Scadden p.scadden at gns.cri.nz
Wed Jun 22 17:51:26 EDT 2011


> I'm using a map with no options and an OSM base layer. Am I right is 
> assuming that the map inherits OSM's projection of 900913?
Yes, map picks up transformation of the base layer.
> I'm confused because I transform my arbitrarily set center via
>
>     map.setCenter(new OpenLayers.LonLat(-90, 38).transform(new
>     OpenLayers.Projection("EPSG:4326"),map.getProjectionObject()),12);
>
That looks right.
>
>
> but I transform my re-set center (after geolocating) via
>
>     var temp = map.getCenter().transform(new
>     OpenLayers.Projection("EPSG:900913"),new
>     OpenLayers.Projection("EPSG:4326"));
>
This should give you temp in long/lat. But why using 900913 instead of 
map.getProjectionObject()?
>
>
> in order to be able to feet the twitter search api a set of 
> coordinates that it understands. And further confusing me is the 
> necessity to reproject the coords that I'm pulling into from the 
> geolocation API, as theoretically they're already in EPSG 4326 (WGS 1984)
>
>     var feat = new OpenLayers.Feature.Vector(new
>     OpenLayers.Geometry.Point(position.coords.longitude,position.coords.latitude).transform(new
>     OpenLayers.Projection("EPSG:4326"),map.getProjectionObject()),14);
>
What are values of position.coords.longitude/latitude? It makes sense 
that you have to transform lat/long
to plot them on the OSM projection. In WMS/WFS you are relying on the 
server to transform things to required projection (OL doesnt) but here 
you have to it yourself. It is really at 0,0 - I would expect coords in 
range of -180:180,-90:90 to plot near zero on a map with coordinate 
range of -2E6:-2E6:2E6:2E6.

>
>
> Finally, I'm pulling in coordinates from the twitter search api, and I 
> can verify that they're in lat-lon, and getting passed to my point. 
> The issue is that they're getting places at 0,0. Clearly this is 
> because they're not being properly transformed before getting added to 
> the layer,  BUT when I apply any of the previous methods to transform 
> the point, my lat value gets corrupted into a NAN.
As above, you have to transform them yourself. The only obvious thing 
that I can think of is lat/long are round the wrong way. If you pass 
-90,334 as a latitude then you would get a NaN.


Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110623/d8e72589/attachment.html


More information about the Users mailing list