[OpenLayers-Users] Re: SLDSelect doesn't highlight anything

Phil Scadden p.scadden at gns.cri.nz
Sun Apr 22 17:47:00 EDT 2012


Sorry, should have read more closely. Geoserver doesnt honour srsname in 
this context (Mapserver does). You have to convert the geometry to 
server native projection at the client end.

eg my code implementing a pt selection using DWITHIN. transformgeometry 
function does the work of converting to native.
                 ptSelCtrl[i] = new 
OpenLayers.Control.DrawFeature(selectedLayer, OpenLayers.Handler.Point);
                 ptSelCtrl[i].events.register("featureadded", this, 
function (e) {
                     clearData();
                     var geom = map.getExtent(); //Done with left side 
only to avoid 180 line crossing issues
                     var pt1 = new OpenLayers.Geometry.Point(geom.left, 
geom.bottom);
                     var pt2 = new OpenLayers.Geometry.Point(geom.left, 
geom.top);
                     transformGeometry(pt1);
                     transformGeometry(pt2);
                     var dist = (pt2.y - pt1.y) / 200;
                     var pfilter = new OpenLayers.Filter.Spatial({
                             type: OpenLayers.Filter.Spatial.DWITHIN,
                             distance: dist,
                             distanceUnits: "meters",
                             value: e.feature.geometry
                      });
                      var ly = getLayerNode(combo.value);
                      if (ly.CQL && ly.CQL != '') {
                        var format = new OpenLayers.Format.CQL();
                        pfilter = new OpenLayers.Filter.Logical({
                         type:OpenLayers.Filter.Logical.AND,
                         filters:[format.read(ly.CQL),pfilter]
                        });
                     }
                     wfsProtocol[combo.value].read({
                         filter: pfilter,
                         callback: processSpatialQuery,
                         scope: strategy
                     });
                 });
                 mapPanel.map.addControl(ptSelCtrl[i]);

transformGeometry has application-specific code to sort out what map 
projection is and what the native projection is, and then transforms with:
         geometry.transform(proj, pproj);


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.



More information about the Users mailing list