[OpenLayers-Users] Questions about script protocol

Phil Scadden p.scadden at gns.cri.nz
Wed Jun 1 00:51:30 EDT 2011


Script protocol looks awfully close to what I want. At the moment, I do 
queries on an WFS layer by first creating a protocol object, viz
                  wfsProtocol = new OpenLayers.Protocol.WFS.v1_1_0({
                          url: myWFSurl
                          geometryName: "SHAPE",
                          featurePrefix: myfeaturePrefix,
                          featureType: myfeatureType,
                          srsName: "EPSG:900913"
                  });
I then do queries by:
                          wfsProtocol.read({
                             filter: myFilter,
                             callback: processWFSQuery,
                             scope: strategy
                          });

Of course, this uses ajax and runs into cross-domain issues if I am say 
running the html off a memory stick instead of server.

It appears I could instead do something:
             protocol: new OpenLayers.Protocol.Script({
                 url: myWFSurl,
                 callbackKey: "format_options",
                 callbackPrefix: "callback:",
                 params: {
                     service: "WFS",
                     version: "1.1.0",
                     srsName: "EPSG:900913",
                     request: "GetFeature",
                     geometryName: "SHAPE",
                     featurePrefix: myfeaturePrefix,
                     featureType: myfeatureType,
                     outputFormat: "json"
                 },
             })
or should featureType be typeName???

Presumably, I can read specifying my callback, just the the wfsprotocol, 
however, it gets more interesting with the filter. The filters I use are 
a mixed bunch. Mostly spatial like:
                             filter: new OpenLayers.Filter.Spatial({
                                     type: 
OpenLayers.Filter.Spatial.INTERSECTS,
                                     value: e.feature.geometry
                             }),
or
                                      filter: new 
OpenLayers.Filter.Spatial({
                                                                       
type: OpenLayers.Filter.Spatial.DWITHIN,
                                                                       
distance: map.getExtent().getHeight() / 10000000,
                                                                       
distanceUnits: "degree",
                                                                       
value: e.feature.geometry
                                                               }),
  but also text filters created with logical OR
                                         filter: new 
OpenLayers.Filter.Logical({
                                                 type: 
OpenLayers.Filter.Logical.OR,
                                                 filters: filters
                                         }),

I'm a little lost as to how the filtertoParams is supposed to work to 
serialise all these. Any tips really appreciated.

Thanks

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