[OpenLayers-Users] OpenLayers passing query bounds in wrong projection

Christopher Schmidt crschmidt at metacarta.com
Thu Mar 19 19:51:18 EDT 2009


On Thu, Mar 19, 2009 at 02:56:15PM -0700, SeeJay wrote:
> 
> Ok, I've been banging my head against this for a couple of days.  I'm sure
> I'm just missing something simple.  My map is in epsg:900913, the WFS
> request is passed to mapserver which hits a postGIS database containing a
> grand total of 2 point features.  
> 
> Code snippets follow:
> ---------------------------------------------
> var options = {
>           projection: new OpenLayers.Projection("EPSG:900913"),
>           units: "m",
>           maxResolution: 156543.0339,
>           maxExtent: new OpenLayers.Bounds(
>             -20037508.34, -20037508.34,20037508.34, 20037508.34),
>           controls: [
> 						new OpenLayers.Control.LayerSwitcher({'ascending':false}),
> 						new OpenLayers.Control.MousePosition(),
> 						new OpenLayers.Control.PanZoom(),
> 						new OpenLayers.Control.ScaleLine()
> 						]
> 				};
> 				
> var map = new OpenLayers.Map('map', options );
> 
> var tripdata = new OpenLayers.Layer.WMS( "Trips",
>        
> "http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apache/htdocs/gpshistory/test5.map", 
>         {isbaselayer: 'true',layers: 'trippoints,tracks', format:
> 'image/png'});
> var waypoints = new OpenLayers.Layer.WFS("Waypoints",
>        
> "http://localhost/cgi-bin/mapserv.exe?map=/ms4w/apache/htdocs/gpshistory/test5.map",
>        {request:  'GetFeature', typename: 'waypoints', projection: new
>          OpenLayers.Projection("EPSG:4326")});

This definition is wrong. The third parameter is sent directly to the
server; it should never have objects in it.

Instead, it should be:
 WFS("Name", "url", {'typename':'waypoints'}, {'projection': new
 OpenLayers.Projection("EPSG:4326")});

>       map.addLayers([ waypoints,tripdata ]);
> -----------------------------------------------------
> 
> The Mapfile contains layers defined only as epsg:4326.  However in the
> MapServer error file, I can see the that bouding box being passed is still
> in epsg:900913.  Here is a line from the errorfile:
> 
> [Thu Mar 19 16:42:44 2009].203000 query_string_0_6:DECLARE mycursor BINARY
> CURSOR FOR SELECT
> asbinary(force_collection(force_2d(the_geom)),'NDR'),uniqueid::text from
> waypoints WHERE the_geom && setSRID('BOX3D(1490115.87110093
> 5220415.61602237,1528334.38523667 5239524.87309024)'::BOX3D, 4326 )
> 
> What am I missing?  
> 
> Thanks,
> cj
>       
> -- 
> View this message in context: http://n2.nabble.com/OpenLayers-passing-query-bounds-in-wrong-projection-tp2505674p2505674.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.

> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users


-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list