0

I am trying to read features with ol.format.GML (using OL3). As a result I get feature but not it's geometry. GML file looks like this:

var gmlString = '<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://ogr.maptools.org/ GML_TEST.xsd"
 xmlns:ogr="http://ogr.maptools.org/"
 xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
  <gml:coord><gml:X>500854.9199360001</gml:X><gml:Y>5055411.41149136</gml:Y></gml:coord>
  <gml:coord><gml:X>501608.1199360002</gml:X><gml:Y>5056276.611491146</gml:Y></gml:coord>
</gml:Box>
 </gml:boundedBy>

<gml:featureMember>
<ogr:GML_TEST fid="GML_TEST.0">
  <ogr:geometryProperty><gml:Polygon srsName="EPSG:3765"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>500854.919936,5055897.21149124 501155.919936,5056210.81149116 501223.119936,5056276.61149115 501608.119936,5055821.61149126 501405.119936,5055589.21149132 501237.119936,5055411.41149136 501017.319936,5055684.41149129 500878.719936,5055855.21149125 500854.919936,5055897.21149124</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
  <ogr:Name xsi:nil="true"/>
  <ogr:description></ogr:description>
  <ogr:timestamp xsi:nil="true"/>
  <ogr:begin xsi:nil="true"/>
  <ogr:end xsi:nil="true"/>
  <ogr:altitudeMode xsi:nil="true"/>
  <ogr:tessellate>-1</ogr:tessellate>
  <ogr:extrude>0</ogr:extrude>
  <ogr:visibility>-1</ogr:visibility>
  <ogr:drawOrder xsi:nil="true"/>
  <ogr:icon xsi:nil="true"/>
</ogr:GML_TEST>
</gml:featureMember>
</ogr:FeatureCollection>'



 var gmlParser = new ol.format.GML();
 var result = gmlParser.readFeatures(gmlString);

As a result : result => [ol.feature], result[0].getGeometry() => undefined

Does someone know where is the problem ?

1
  • I played a bit with OL versions and GML formats. The GML format is definitely ol.format.GML2, and the first OL version that works is OL5. – TomazicM May 12 '20 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.