[gdal-dev] GML / NAS code redundancy
Even Rouault
even.rouault at mines-paris.org
Sat Apr 5 04:17:21 PDT 2014
Martin,
gmlregistry.diff looks fine, but it would be good to document elementValue in
drv_gml.html
As far as gmlhandler.diff is concerned, serveral issues :
- naming convention : "CPLString pszFilteredElementName" should be "CPLString
osFilteredElementName"
- if ( pszElementName[m_poReader->GetState()->osPath.size()] == '|' ) : there
should be an extra test to check that strlen(pszElementName) > m_poReader-
>GetState()->osPath.size()
- the casts to (char*) are useless
All in all, I think that the more simpler solution would be to drop that patch
and rather modify the call to SetFilteredClassName() at line 130 of
ogrgmllayer.cpp to something like this :
if (poDS->GetLayerCount() > 1 && poDS->GetReadMode() == STANDARD)
{
const char* pszElementName = poFClass->GetElementName();
const char* pszLastPipe = strrchr(pszElementName, '|');
if( pszLastPipe != NULL )
pszElementName = pszLastPipe + 1;
poDS->GetReader()->SetFilteredClassName(pszElementName);
}
This is completely untested of course...
Even
> Dear Even,
>
> 2014-03-19 11:17 GMT+01:00 Even Rouault <even.rouault at mines-paris.org>:
> > Just for Martin's enlightment, the GML driver manages to recognize
> > several layers in that case since the RekisteriyksikonTietoja is the top
> > feature present in the first bytes of the file, and the other feature
> > types are sub feature types, also defined in
> > RekisteriyksikonTietoja.xsd. In the case, the schema were simple enough
> > so that the XSD parser could understand them.
> >
> > For Martin's case, I think that a .gfs will be necessary to extract
> > properties in nested XML elements.
>
> thanks a lot for your notes, it helped a lot. When working on support
> for this format in OGR I found two problems.
>
> First is related to GML registry. The input file contains different
> layers based on its internal type (TypSouboru). For each of these
> types are prepared separated GFS file.
>
> <!-- Czech VFR schame-->
> <namespace prefix="vf"
> uri="urn:cz:isvs:ruian:schemas:VymennyFormatTypy:v1
> ../ruian/xsd/vymenny_format/VymennyFormatTypy.xsd"
> useGlobalSRSName="true">
> <featureType elementName="TypSouboru"
> elementValue="OB_UKSH"
> gfsSchemaLocation="vfr_ob_uksh_v1.gfs"/>
> <featureType elementName="TypSouboru"
> elementValue="ST_UKSH"
> gfsSchemaLocation="vfr_st_uksh_v1.gfs"/>
> <featureType elementName="TypSouboru"
> elementValue="ST_UKSG"
> gfsSchemaLocation="vfr_st_uksg_v1.gfs"/>
> </namespace>
>
> I have added a new attribute to 'osElementValue' to
> 'GMLRegistryFeatureType' class (see attached 'gmlregistry.diff' file).
> Then the library also checks value of 'elementName' and if it's
> defined and than uses related GFS.
>
> The second problem is related to class and tag names. The layer names
> are in plural form, features in singular form, eg.
>
> <data>
> <cities>
> <city>
> ...
> </city>
> </cities>
> </data>
>
> To allow GML driver to create layer 'cities' I need to modify
> 'GMLHandler::startElementDefault()' method, see 'gmlhandler.diff'.
>
> Thanks for any comments in advance, Martin
--
Geospatial professional services
http://even.rouault.free.fr/services.html
More information about the gdal-dev
mailing list