[gdal-dev] Namespaces in GMLAS

Ari Jolma ari.jolma at gmail.com
Mon Oct 16 03:03:32 PDT 2017


Thanks,

After fixing srsName attribute in the returned gml (the HTTP errors i 
mention below) I can now read the features in the file (GetNextFeature 
on the dataset object).

As a second step I try to make the download implicit (assuming the 
srsName would be ok) and use the /vsicurl mechanism, i.e., open

/vsicurl/https://opaskartta.turku.fi/TeklaOGCWeb/WFS.ashx?request=GetFeature&typename=akaava:Suojelualue

directly.

That seems difficult (impossible?) since GMLAS driver expects the name 
to start with GMLAS prefix. I don't see any obvious way to go around 
that. I can force GDAL to try only GMLAS but that does not help. Would 
it be possible to make OGRGMLASDriverIdentify return true using some option?

Best,

Ari

Even Rouault kirjoitti 14.10.2017 klo 01:09:
> On vendredi 13 octobre 2017 23:19:02 CEST Ari Jolma wrote:
>> I've been looking into a GML file ('akaava:Suojelualue') with ogrinfo
>> I've got from a Finnish WFS
>>
>> https://opaskartta.turku.fi/TeklaOGCWeb/WFS.ashx?request=GetCapabilities
>>
>> First, the XSD files needed a bit of fixing: link GML to 3.1.1 instead
>> of 2.1.2 in opaskartta.turku.fi_Tekl..., and fix [-] to [\-] in
>> www.paikkatietopalvelu.fi_gml_yhteiset_2.1.6_yhteiset.xsd
>>
>> After that, ogrinfo does not complain but does not find anything in the
>> GML file. I dug in a bit and it turns out that
>> GMLASSchemaAnalyzer::Analyze did not use the correct schema files (gml,
>> asemakaava, etc) in the 2nd and 3rd passes it does through the
>> namespaces -- it did in the first pass. For some reason only the
>> namespace -> schema pairs in the GML get into aoNamespaces array. The
>> correct ones are available in oMapURIToPrefixWithEmpty.
>>
>> Probably the way Tekla constructs the GML file is unusual (my guess, I'm
>> no expert on this subject). The xsi:schemaLocation in the GML file
>> contains only two pairs: wfs -> wfs-schema and kuntagml -> describe
>> featuretype request URL. These are in aoNamespaces. The latter then
>> imports the gml and asemakaava schemas.
>>
>> Modifying the code to read the namespaces in the 2nd and 3rd pass
>> similarly as in 1st pass I get a long list of layers with ogrinfo and
>> can read something real out of the GML file with ogr2ogr. However,
>> there's two HTTP 404 errors -- probably some schemas are not where
>> expected(?).
>>
>> Could you Even sched some light on what's going on?
> Hi Ari,
>
> Oh no, I only do GMLAS stuff as a punishment when I have done some really evil
> action ;-)
>
> I've downloaded the content of
> "https://opaskartta.turku.fi/TeklaOGCWeb/WFS.ashx?
> request=GetFeature&service=WFS&typename=kanta:Kiinteisto&version=1.1.0"
> I didn't had to do schema fixing, but I probably already did try with that
> schema in the past since I had it cached, so perhaps I already fixed stuff.
>
> Regarding the namespace issue, the core issue was that the .xml file only
> points to the wfs and kuntagml namespaces, but none of them has "interesting"
> elements. The kuntagml namespace happens to be a "wrapper" around the gml and
> kantakartta namespaces, and that's this latter one that has interesting
> elements.
> The rational for that behaviour is that generally only the namespaces directly
> pointed by the document contain interesting elements. Indirectly imported
> namespaces just contain technical stuff you don't really want to expose as
> layers. But yes that heuristics wasn't bullet proof.
>
> So a workaround is to add "http://www.paikkatietopalvelu.fi/gml/kantakartta
> http://www.paikkatietopalvelu.fi/gml/kantakartta/2.1.1/kantakartta.xsd" in the
> xsi:schemaLocation.
> But I did a fix in https://trac.osgeo.org/gdal/changeset/40429 to avoid doing
> that: when "first choice" namespaces contain nothing interesting, fallback to
> the namespaces they indirectly import
> I also pushed before a fix for gml:PolyhedralSurface parsing
>
> With the fix (or manual workaround):
>
> $ ogrinfo GMLAS:kanta.xml  -oo remove_unused_layers=yes
> INFO: Open of `GMLAS:kanta.xml'
>        using driver `GMLAS' successful.
> 1: kiinteisto (None)
> 2: labelit (None)
> 3: labelit_label (Point)
> 4: sijainnit (None)
> 5: sijainnit_sijainti (Curve, Curve, Surface)
> 6: referenssipiste (Point, Point)
>
> Even
>



More information about the gdal-dev mailing list