[gdal-dev] FileGDBs and FIDs of -21121

Even Rouault even.rouault at spatialys.com
Tue Aug 27 13:03:58 PDT 2024


Seth,

I'm not totally sure to understand the exact scenario. -21121 is a 
special value for OGRField, which is a distinct concept that the Feature 
ID, and normally it shouldn't prevent setting Integer64 fields to the 
value as this canary is set in 2 fields of OGRField.

from osgeo import ogr
layer_defn = ogr.FeatureDefn("test")
layer_defn.AddField(ogr.FieldDefn("i64", ogr.OFTInteger64))
  layer_defn.AddFieldDefn(ogr.FieldDefn("i64", ogr.OFTInteger64))
f = ogr.Feature(layer_defn)
f["i64"] = -21121
f.DumpReadable()
OGRFeature(test):-1
   i64 (Integer64) = -21121

But what is sure is that the OpenFileGDB driver will error out if you 
pass to CreateFeature() a feature with a FID < -1,  = 0 or > INT32_MAX,  
since the FileGDB format only supports FID in the range [1, INT32_MAX], 
and -1 is the OGRNullFID special constant to indicate that you let the 
driver automatically assign a FID.

With GeoJSON, you would likely have an issue with features of FID = -1 
which would get assign a FID by the driver. Basically most formats will 
struggle with negative or null FIDs

What is perhaps missing in MapServer is a FORMATOPTION "SET_FID=FALSE" 
for drivers such as FileGDB  (or "FID_VALID_MIN" and "FIX_VALID_MAX" ?)  
to limit the scope of calls to OGR_F_SetFID() by MapServer.

Even


Le 27/08/2024 à 21:32, Seth G via gdal-dev a écrit :
> Hi all,
>
> I'm using a GDAL within MapServer to export features as a FileGDB. Using the following OUTPUTFORMAT:
>
>      OUTPUTFORMAT
>          NAME "FileGDB"
>          DRIVER "OGR/OpenFileGDB"
>          MIMETYPE "application/x-ogc­filegdb"
>          FORMATOPTION "STORAGE=filesystem"
>          FORMATOPTION "FORM=zip"
>          FORMATOPTION "FILENAME=result.gdb.zip"
>          FORMATOPTION "LCO:FID=FID"
>      END
>
> I ran into an issue where a single feature Id is being set to NULL. After checking various database queries and configs it looks like the issue is when a feature id is -21121 and data exported to a FileGDB. When using GeoJSON the Id is returned correctly.
>
> I searched in the GDAL codebase and found that this is a "magic" number: https://github.com/search?q=repo%3AOSGeo%2Fgdal%20-21121&type=code
>
> #define OGRUnsetMarker -21121
>
> Is there any way round this other than using different Ids?
>
> Thanks,
>
> Seth
>
>
>
> --
> web:https://geographika.net & https://mapserverstudio.net
> twitter: @geographika
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev

-- 
http://www.spatialys.com
My software is free, but my time generally not.



More information about the gdal-dev mailing list