[OpenLayers-Users] boundedBy undefined with GML with defined
boundedBy
bartvde at osgis.nl
bartvde at osgis.nl
Fri Jul 31 02:18:13 EDT 2009
Hi,
IIRC OpenLayers does not read the boundedBy of the whole
FeatureCollection, only of individual features. I've added my own custom
patch but it's only for GML v3, maybe you can do something similar for
GML.v2.
--- lib/OpenLayers/Format/GML/v3.js 2009-06-12 14:12:20.000000000 +0200
+++ v3.js 2009-06-12 14:17:46.000000000 +0200
@@ -229,6 +229,15 @@
var obj = {};
this.readers.gml.pos.apply(this, [node, obj]);
container.points[1] = obj.points[0];
+ },
+ "boundedBy": function(node, container) {
+ if (!this.boundedBy) {
+ var obj = {};
+ this.readChildNodes(node, obj);
+ if (obj.components && obj.components.length > 0) {
+ this.boundedBy = obj.components[0];
+ }
+ }
}
}, OpenLayers.Format.GML.Base.prototype.readers["gml"]),
"feature": OpenLayers.Format.GML.Base.prototype.readers["feature"],
Best regards,
Bart
>
> Hello,
>
> I'm trying to get the boundedBy of a whole feature collection (in this
> example
> there is only on feature).
>
> I follow this exemple http://trac.openlayers.org/ticket/1613
> var g = new OpenLayers.Format.GML.v2(options);
> var features = g.read(response.responseXML || response.responseText);
> // boundedBy will contain the boundary of the whole feature collection
> // easy for zooming to the selection / collection
> console.log(g.boundedBy);
>
> The result in my log is: undefined
>
> here is my script:
> <script type="text/javascript">
> function parseData(req) {
>
> var format = new OpenLayers.Format.GML.v2({
> featureType: "states",
> featureNS: "http://www.openplans.org/topp",
> geometryName: "the_geom",
> xy: false
> });
>
> var features = format.read(req.responseXML || req.responseText);
> console.log(features.boundedBy);
>
> }
> function load() {
> OpenLayers.loadURL("owls1.xml", "", null, parseData);
> }
> </script>
>
> The beginning of my owls1.xml:
> "<?xml version="1.0" encoding="utf-8"?>
> <wfs:FeatureCollection xmlns="http://www.opengis.net/wfs"
> xmlns:wfs="http://www.opengis.net/wfs"
> xmlns:topp="http://www.openplans.org/topp"
> xmlns:gml="http://www.opengis.net/gml"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.openplans.org/topp
> http://localhost:8080/geoserver/wfs?service=WFS&version=1.0.0&request=DescribeFeatureType&typeName=topp:states
> http://www.opengis.net/wfs
> http://localhost:8080/geoserver/schemas/wfs/1.0.0/WFS-basic.xsd">
>
> <gml:boundedBy>
> <gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
>
> <gml:coordinates xmlns:gml="http://www.opengis.net/gml"
> decimal="." cs="," ts="">-75.791435,38.44949
> -75.045998,39.840008</gml:coordinates>
> </gml:Box>
> </gml:boundedBy>
> <gml:featureMember>
> <topp:states fid="states.3">
> <gml:boundedBy>
> <gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
>
> <gml:coordinates xmlns:gml="http://www.opengis.net/gml"
> decimal="." cs="," ts="">-75.791435,38.44949
> -75.045998,39.840008</gml:coordinates>
> </gml:Box>
> </gml:boundedBy>
> ... "
>
> Thanks for your help,
>
> Spirifer
> --
> View this message in context:
> http://n2.nabble.com/boundedBy-undefined-with-GML-with-defined-boundedBy-tp3358976p3358976.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
More information about the Users
mailing list