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