Opened 22 years ago

Closed 11 years ago

Last modified 10 years ago

#249 closed defect (fixed)

[OGR-GML] GML driver doesn't recognize GML files with 0 features

Reported by: Daniel Morissette Owned by: warmerdam
Priority: high Milestone: 1.11.0
Component: default Version: unspecified
Severity: normal Keywords: gml gfs
Cc: Mateusz Łoskot

Description (last modified by Mateusz Łoskot)

The OGR/GML driver doesn't recognize files that contain 0 features. Everything goes well until GMLReader::PrescanForSchema() gets called, it returns false since it doesn't find any feature class.

I guess this makes sense for datasets in general, but when we use the GML driver in the context of a WFS, receiving 0 features is a valid case.

It would be nice if OGR accepted to open GML file, and present it as a file with a single layer with 0 features in it.

What is an OGR driver expected to do if a file is empty? If nothing can be done at the OGR level for this then I guess I'll have to preparse the GML file before .

I try to open it with OGR, which is a bit of a waste of resources.

Any ideas, suggestions?

Change History (9)

comment:1 by warmerdam, 22 years ago


I see your point.

I think it would be OK to treat a file as GML and return a datasource with
zero layers (since there would be no defined feature types) if the file is
clearly GML (it contains the and a featureCollection element).  

Do you really need the driver to return a dataset with one layer?  

Do you want to make these changes or do you want me to?  

comment:2 by Daniel Morissette, 22 years ago

I just realized that I may have to open the XML anyway when the open() call 
fails in order to look for exceptions.  I'll get back to you on this one.

comment:3 by Daniel Morissette, 22 years ago

I modified MapServer to preparse the header of the WFS response and detect 
WFS exceptions, etc (a bit like a testopen) before calling OGR, so this is not 
an issue for me any more.

I'll let you decide if you want to mark this as invalid, or keep this as a 
potential enhancement for later.  I think it would be nice to return a 
datasource with zero layers as you suggested to indicate that the file format 
was recognized.  But this could just confuse applications too, I dunno?  I'll 
leave that up to you to decide.

Thanks for the quick reply earlier today BTW :)

comment:4 by warmerdam, 20 years ago

Review for correction before GDAL 1.2.0 release.

comment:5 by warmerdam, 20 years ago

I'm too nervous to fiddle with this aspect of the GML reader before the release.
Deferring.  This is more of an issue to be revisited on the next substantial 
effort to improve the GML reader. 

comment:6 by Mateusz Łoskot, 17 years ago

Description: modified (diff)

comment:7 by Mateusz Łoskot, 17 years ago

Cc: Mateusz Łoskot added
Keywords: gml gfs added

comment:8 by Even Rouault, 11 years ago

Milestone: 2.0
Resolution: fixed
Status: assignedclosed

trunk r26339 "GML: open successfully GML datasources with 0 layers (#249, #5205)"

comment:9 by Even Rouault, 10 years ago

Note: See TracTickets for help on using tickets.