[gdal-dev] Reading an IntegerList from file

Even Rouault even.rouault at mines-paris.org
Wed Sep 19 08:04:24 PDT 2012


Selon Bruno Belarte <bruno.belarte at gmail.com>:

> Hi,
>
> I am currently working on exporting some data (an adjacency graph with
> nodes described by an id (integer), an OGRGeometry and some other fields
> (string and real) into a file. I choose to export the adjacency relation
> as an IntegerList field (for each node, the list contains the id of all
> the adjacent nodes). It works for several file type (KML, GML, SQLite,
> but not shapefile as it doesn't support IntegerList field type).
> Everything works fine and the output files contains all the data that I
> want.

Because KML, GML and SQLite driver have a default case where they will create a
field of String type when encountering an unhandled field type such as
IntegerList, whereas the Shapefile driver will refuse it directly. For those
drivers that consider an IntegerList as a String, they will serialize it's
content as "{N:v1,v2,...,vn}", and potentially truncated if that serialized
content goes above 80 characters.

>
> The problem comes when I want to do the opposite. When I open a file
> that I precedently wrote, the IntegerList give me some trouble. The
> field description is actually in the OGRFeatureDefn but the
> feature->GetFieldAsIntegerList ("name", &size) method returns a NULL
> pointer.

Yes, when reading back those files, the field is presumably of String type, so
GetFieldAsIntegerList() returns NULL. But GetFieldAsString() should return the
serialized content in the "{N:v1,v2,...,vn}" format.

You can confirm that easily by using ogrinfo.

>
> Is there a specific procedure to handle IntegerLists ? Or is it an
> unsupported feature ?

Very few drivers fully support round-tripping of IntegerList, RealList of
StringList types. AFAIR, PostgreSQL is one of them, but that must be about it.

The GML driver supports it in read mode, but not in write mode (although that
could probably be improved)

>
> Thanks,
>
> Bruno Belarte
>
> PS : I work with C++ and gdal 1.9.0 on ubuntu 12.04 64bits
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>




More information about the gdal-dev mailing list