1

Is it possible to get GML from a local vector layer (OpenLayers.Layer.Vector)?

What I would like to do is use the output geometry from my buffer tool to spatially limit a WPS gs:Aggregate request using a WFS/OGC filter. I am not sure if it is even possible (and there might very well be a better solution), but I would still be interested in knowing if it is possible to derive GML coordinates from a vector layer. I’m running the Boundless OpenGeo Suite (GeoServer).

2 Answers 2

1

I managed to get the geometry to GML-format by reading these two question: First and second.

Code:

featureadded: function (event) {

 var geometry = event.feature.geometry;

 var gml = new OpenLayers.Format.GML(); 

 var polygonGML = gml.buildGeometry.polygon.apply(gml,[feature.geometry])     
 var plgGMLString = (new XMLSerializer()).serializeToString(polygonGML);

 ...

 }
0

I think it is easier to make a WFS request in your browser (no need to involve OpenLayers):

http://192.168.154.7:8090/geoserver/wfs?
service=wfs&
version=2.0.0&
request=GetPropertyValue&
typeNames=workspace_name:vector_layer_name&
valueReference=geom&
outputFormat=gml2

You'll obtain something like this:

<wfs:member>
  <ACGL:geom>
    <gml:Polygon srsDimension="2" srsName="urn:ogc:def:crs:EPSG::31700">
      <gml:exterior>
        <gml:LinearRing>
          <gml:posList>
            473502.3205767908 693338.8402676274
            473412.06868474645 693167.3616708852
            473428.66570708115 693159.2152727067
            473513.17858519114 693333.7602303769
            473502.3205767908 693338.8402676274
          </gml:posList>
        </gml:LinearRing>
      </gml:exterior>
    </gml:Polygon>
  </ACGL:geom>
</wfs:member>

Read more here.

1
  • That would only work with layers published by GeoServer though, right? Sorry if my question was not clear, the vector layer is just created in the code - it is not published in GeoServer.
    – Markus
    Commented Feb 19, 2014 at 10:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.