<HTML><HEAD>
<META content="text/html; charset=iso-8859-15" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18928"></HEAD>
<BODY style="MARGIN: 4px 4px 1px">
<DIV>Hi Phil</DIV>
<DIV> </DIV>
<DIV>I just want to use a BBOX, so no cql filters. Does the Script protocol know to return the response to the callback function?</DIV>
<DIV> </DIV>
<DIV>Thanks,</DIV>
<DIV> </DIV>
<DIV>Robert</DIV>
<DIV><BR>>>> Phil Scadden <p.scadden@gns.cri.nz> 20/09/2011 4:15 p.m. >>><BR>yes, I've done it with eg.<BR><BR>Instead of<BR> wfsProtocol = new OpenLayers.Protocol.WFS.v1_1_0({<BR> url: myurl,<BR> geometryName: "SHAPE",<BR> featurePrefix: myfeaturePrefix,<BR> featureType: myfeatureType,<BR> srsName: myproj<BR> });<BR><BR>I use<BR><BR> wfsProtocol = new OpenLayers.Protocol.Script({<BR> url: myurl,<BR> callbackKey: "format_options",<BR> callbackPrefix: "callback:",<BR> params: {<BR> service: "WFS",<BR> version: "1.1.0",<BR> srsName: myproj<BR> request: "GetFeature",<BR> featurePrefix: myfeaturePrefix,<BR> typeName: myfeatureType,<BR> outputFormat: "json"<BR> },<BR> filterToParams: function (filter, params) {<BR> // example to demonstrate BBOX serialization<BR> delete params.cql_filter;<BR> if (filter.type === <BR>OpenLayers.Filter.Spatial.BBOX) {<BR> params.bbox = filter.value.toArray();<BR> if (filter.projection) {<BR> <BR>params.bbox.push(filter.projection.getCode());<BR> }<BR> } else if (filter.type === <BR>OpenLayers.Filter.Spatial.DWITHIN) {<BR> var geom = filter.value.clone();<BR> transformGeometry(geom);<BR> if (geom.x >= -180 && geom.x <= 360 && <BR>geom.y >= -180 && geom.y <= 360) { // is this a lat long?<BR> var xx = geom.x;<BR> geom.x = geom.y;<BR> geom.y = xx;<BR> }<BR> params.cql_filter = 'DWITHIN(SHAPE,' + <BR>geom.toString() + ',' + filter.distance + ',meters)';<BR> } else if (filter.type === <BR>OpenLayers.Filter.Spatial.INTERSECTS) {<BR> var geom = filter.value;<BR> transformGeometry(geom);<BR> geom.components[0].swapXY();<BR> params.cql_filter = 'INTERSECTS(SHAPE,' <BR>+ geom.toString() + ')';<BR> } else if <BR>(OpenLayers.Format.QueryStringFilter) {<BR> var format = new <BR>OpenLayers.Format.QueryStringFilter({<BR> srsInBBOX: this.srsInBBOX<BR> });<BR> params = format.writecql(filter, <BR>params, this.options.url.indexOf('server21') > 0);<BR> }<BR> return params;<BR> }<BR> });<BR><BR>The complicated bit the filterToParams. If you dont have any filter, <BR>then no problem. If you do, they you need to convert the filter to CQL. <BR>The code above handles spatial filters. I havent attempted others. Gets <BR>complicated fast. CQL filters dont respect SRS (at least on geoserver). <BR>You have to make sure that any geometry is transformed to native SRS <BR>(that's what my application function transformGeometry is doing). You <BR>also have switch x,y if it is lat/long.<BR><BR><BR>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.<BR><BR>_______________________________________________<BR>Users mailing list<BR>Users@lists.osgeo.org<BR><A href="http://lists.osgeo.org/mailman/listinfo/openlayers">http://lists.osgeo.org/mailman/listinfo/openlayers</A>-users<BR></DIV><br><br>
<P align=center><FONT style="BACKGROUND-COLOR: #ffffff">This email and any attachments are confidential and intended solely for the addressee(s). If you are not the intended recipient, please notify us immediately and then delete this email from your system.</FONT></P>
<P align=center><FONT style="BACKGROUND-COLOR: #ffffff">This message has been scanned for Malware and Viruses by Websense Hosted Security. </FONT><A href="http://www.websense.com/"><FONT style="BACKGROUND-COLOR: #ffffff" color=#000000>www.websense.com</FONT></A></P>
</body></HTML>