[OpenLayers-Users] Select WFS Features using intersect of polygon

Andrew Stewart Andrew.Stewart at reddeer.ca
Tue Feb 14 18:01:04 EST 2012


Hi Phil,

Thanks a ton for your suggestion and sample script! I was able to get this working perfectly using your code and modifying mine, here is what I ended up with. Really appreciate the help!


function processSpatialQuery(e)
{
    //output data here
    alert(e.features[0].attributes.Orig_AddrKey);
}

var selectedLayer = new OpenLayers.Layer.Vector();
map.addLayer(selectedLayer);
    
pySelCtrl = new OpenLayers.Control.DrawFeature(selectedLayer, OpenLayers.Handler.Polygon, {
                     geodesic: true,
                     handlerOptions: {
                         citeCompliant: true
                     }
                 });
                             
 wfsProtocol =  new OpenLayers.Protocol.WFS({
        url:  wfs,
        featureType: "Parcels_Select",
        featureNS: "http://www.intergraph.com/geomedia/gml",
        featurePrefix: "gmgml",
        srsName: "EPSG:3776",
        geometryName: "Geometry",
        version: "1.1.0"
    })                
                 
                 
pySelCtrl.events.register("featureadded", this, function (e) 
{
                     var pfilter = new OpenLayers.Filter.Spatial({
                             type: OpenLayers.Filter.Spatial.INTERSECTS,
                             value: e.feature.geometry
                         });
                     wfsProtocol.read({
                         filter:  pfilter,
                         callback: processSpatialQuery,
                         scope: new OpenLayers.Strategy.BBOX()
                     });
});

map.addControl(pySelCtrl);
pySelCtrl.activate(); 



-----Original Message-----
From: openlayers-users-bounces at lists.osgeo.org [mailto:openlayers-users-bounces at lists.osgeo.org] On Behalf Of Phil Scadden
Sent: February 14, 2012 3:03 PM
To: openlayers-users at lists.osgeo.org
Subject: Re: [OpenLayers-Users] Select WFS Features using intersect of polygon

I do the select with featureadded. Eg here is my code.

                 pySelCtrl = new 
OpenLayers.Control.DrawFeature(selectedLayer, OpenLayers.Handler.Polygon, {
                     geodesic: true,
                     handlerOptions: {
                         citeCompliant: true
                     }
                 });
                 pySelCtrl.events.register("featureadded", this, 
function (e) {
                     clearData();
                     var pfilter = new OpenLayers.Filter.Spatial({
                             type: OpenLayers.Filter.Spatial.INTERSECTS,
                             value: e.feature.geometry
                         });
                     }
                     wfsProtocol.read({
                         filter:  pfilter,
                         callback: processSpatialQuery,
                         scope: strategy
                     });
                 });


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.

_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users


[This message has been scanned for security content threats and viruses.]

[The City of Red Deer I.T. Services asks that you please consider the environment before printing this e-mail.]






More information about the Users mailing list