[gdal-dev] GDAL GML and OpenLayers

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[gdal-dev] GDAL GML and OpenLayers

Ari Jolma-2
Hi,

I'm trying to get OpenLayers (v4.3.2) understand GML made by GDAL (in
the context of a WFS). GDAL has a lot of creation options for GML and
the best results I've got with TARGET_NAMESPACE =
http://ogr.maptools.org/, PREFIX = ogr, and FORMAT = GML2. That has
worked with earlier (v2) OpenLayers but with v4 the features are
understood but not their geometries. This may not be the full issue but
if I produce the geometries the way geoserver seems to do, I get OL to
understand them.

Geometry produced by GDAL as GML2, not working with new OL:

<ogr:geometryProperty>
<gml:Polygon srsName="EPSG:3857">
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates>2423495.53212975,9236910.2942792
2487091.13966301,9293167.94709709 2491983.10947327,9276046.05276121
2440617.42646563,9212450.44522794
2423495.53212975,9236910.2942792</gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</ogr:geometryProperty>

Geometry that works with new OL:

<ogr:geometry>
<gml:Polygon srsName="http://www.opengis.net/gml/srs/epsg.xml#3857"
srsDimension="2">
<gml:exterior>
<gml:LinearRing>
<gml:posList>2423495.53212975 9236910.2942792 2487091.13966301
9293167.94709709 2491983.10947327 9276046.05276121 2440617.42646563
9212450.44522794 2423495.53212975 9236910.2942792</gml:posList>
</gml:LinearRing>
</gml:exterior>
</gml:Polygon>
</ogr:geometry>

I'm using ol.format.WFS to parse the GML. If I give it a constructor
option gmlFormat:ol.format.GML2, the parsing causes an error because
ol.format.GML2 does not have a feature collection parser.

Ari


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: GDAL GML and OpenLayers

Even Rouault-2

On mercredi 13 septembre 2017 10:39:50 CEST Ari Jolma wrote:

> Hi,

>

> I'm trying to get OpenLayers (v4.3.2) understand GML made by GDAL (in

> the context of a WFS). GDAL has a lot of creation options for GML and

> the best results I've got with TARGET_NAMESPACE =

> http://ogr.maptools.org/, PREFIX = ogr, and FORMAT = GML2. That has

> worked with earlier (v2) OpenLayers but with v4 the features are

> understood but not their geometries. This may not be the full issue but

> if I produce the geometries the way geoserver seems to do, I get OL to

> understand them.

>

> Geometry produced by GDAL as GML2, not working with new OL:

>

> <ogr:geometryProperty>

> <gml:Polygon srsName="EPSG:3857">

> <gml:outerBoundaryIs>

> <gml:LinearRing>

> <gml:coordinates>2423495.53212975,9236910.2942792

> 2487091.13966301,9293167.94709709 2491983.10947327,9276046.05276121

> 2440617.42646563,9212450.44522794

> 2423495.53212975,9236910.2942792</gml:coordinates>

> </gml:LinearRing>

> </gml:outerBoundaryIs>

> </gml:Polygon>

> </ogr:geometryProperty>

>

> Geometry that works with new OL:

>

> <ogr:geometry>

> <gml:Polygon srsName="http://www.opengis.net/gml/srs/epsg.xml#3857"

> srsDimension="2">

> <gml:exterior>

 

--> gml:exterior isn't GML2, but GML3. Perhaps you should try FORMAT=GML3 instead then.

 

> <gml:LinearRing>

> <gml:posList>2423495.53212975 9236910.2942792 2487091.13966301

> 9293167.94709709 2491983.10947327 9276046.05276121 2440617.42646563

> 9212450.44522794 2423495.53212975 9236910.2942792</gml:posList>

> </gml:LinearRing>

> </gml:exterior>

> </gml:Polygon>

> </ogr:geometry>

>

> I'm using ol.format.WFS to parse the GML. If I give it a constructor

> option gmlFormat:ol.format.GML2, the parsing causes an error because

> ol.format.GML2 does not have a feature collection parser.

>

> Ari

>

>

> _______________________________________________

> gdal-dev mailing list

> [hidden email]

> https://lists.osgeo.org/mailman/listinfo/gdal-dev

 

 

--

Spatialys - Geospatial professional services

http://www.spatialys.com


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: GDAL GML and OpenLayers

Even Rouault-2

> It don't work - no features at all - with GML3 and other default

> options. But, when I set FORMAT = GML3, TARGET_NAMESPACE =

> http://www.opengis.net/gml, and PREFIX = ogr (to avoid a namespace

> collision) then it works.

>

 

Note that if you throw this in a reader that validates against the schema, it will error out because the generated .xsd will have targetNamespace="http://www.opengis.net/gml" which will conflict with the OGC GML schemas... So this is definitely a hack and I would not recommend distributing widely such datasets.

 

> I don't understand why the default is to put FeatureCollection etc into

> 'http://ogr.maptools.org/'?

 

Excellent question. Short answer: GML is a mess

 

Long answer:

 

gml:FeatureCollection didn't exist in GML 2.1.2. There was only an abstract _FeatureCollection element of type gml:AbstractFeatureCollectionType, so you had to subclass it. Then GML 3.1 brought a new gml:FeatureCollection element. Which GML 3.2.1 immediately deprecated ! (it is now in

http://schemas.opengis.net/gml/3.2.1/deprecatedTypes.xsd ), probably for some pedantic reasons.

 

When the GML driver was upgraded for GML 3.1, it tried to follow the recommandations of the OGC 06-049r1 "Geography Markup Language (GML) simple features profile" (for GML 3.1.1) and OGC 10-100r3 "Geography Markup Language (GML) simple features

profile (with Corrigendum)" (for GML 3.2), that both mention

 

"""This FeatureCollectionNameType does NOT extend gml:AbstractFeatureCollectionType because that type has been deprecated in GML 3.2."""

 

So basically they ask to define in your own namespace an element that is a substitution group of gml:AbstractFeature (for GML 3.2) or gml:_GML (for GML 3.1.1)

 

I guess OpenLayers doesn't try to read & understand the .xsd that comes with the .gml, and even if it does, it can actually be challenging to understand that the type that is defined is actually a feature collection (apart from having FeatureCollection in its name).

 

~~~~~

 

Anyway, I've just committed a new dataset creation option, GML_FEATURE_COLLECTION=YES/NO, that applies only for GML >= 3, and will use gml:FeatureCollection and gml:featureMember, whatever they are deprecated or not...

 

 

Even

 

--

Spatialys - Geospatial professional services

http://www.spatialys.com


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev