[OSM-dev] slippymap doesnt wrap around +-180deg
Luka Frelih
luka at ljudmila.org
Mon Apr 14 01:46:08 BST 2008
Tom Hughes wrote:
> I've turned on wrapDateLine so this should be fixed now.
>
great!
thanks to all who help figured this out
and fixed the rift in the coordinate continuum. :)
> Placename truncated at 180° meridian
> http://www.openstreetmap.org/?lat=-8.7&lon=179.999&zoom=5&layers=B0FT
>
> also giving lon=180 to slippymap incorrectly jumps to 0° longitude.
>
these two issues remain.
the rendering of names might require special-casing the query for tiles bordering on the 180 boundary.
and the 180 flip of this url:
http://www.openstreetmap.org/?lat=-8.7&lon=180&zoom=5&layers=B0FT
seems to be zeroing home if it's not inside the interval -180 < lon < 180
this ends up in javascript:
var centre = lonLatToMercator(new OpenLayers.LonLat(180, -8.7));
map.setCenter(centre, zoom);
running in console:
> >> p=new OpenLayers.LonLat(180, -8.7)
lon=180,lat=-8.7 lon=180 lat=-8.7 CLASS_NAME=OpenLayers.LonLat
> >> lonLatToMercator(new OpenLayers.LonLat(180, -8.7));
lon=20037508.34,lat=-972222.7900441375 lon=20037508.34
lat=-972222.7900441375
this seems ok
map.setCenter seems to be from OpenLayers.js, one of these two?
setCenter:function(lonlat,zoom,dragging,forceZoomChange){if(!this.center&&!this.isValidLonLat(lonlat)){lonlat=this.maxExtent.getCenterLonLat();}
setCenter:function(){if(this.map.baseLayer){this.map.events.unregister('changebaselayer',this,this.setCenter);this.map.setCenter(this.center,this.zoom);}}
isValidLonLat the culprit? should it do a mod wrap?
isValidLonLat:function(lonlat){var valid=false;if(lonlat!=null){var maxExtent=this.getMaxExtent();valid=maxExtent.containsLonLat(lonlat);}
return valid;},getProjection:function(){var projection=null;if(this.baseLayer!=null){projection=this.baseLayer.projection;}
hmmm, i guess perhaps the web server should send a redirect to an url
with "normalized" coordinates... this way all incoming links end up at
the canonical url. then we make sure getMaxExtent likes all that range
and it should work.
LF
More information about the dev
mailing list