[gdal-dev] Question on using SetFID

Ari Jolma ari.jolma at gmail.com
Wed Feb 17 00:16:42 PST 2016


17.02.2016, 09:33, Gane R kirjoitti:
> Hi all,
>
> I am creating a layer for geopackage, But I don't see the fid I set 
> using setFID here is my code flow.
>
> Step1:
> poLayer = OGRDataSource::CreateLayer(....);
>
> Step2:
> adding all the fields
>
> Step3:
> poFeature = OGRFeature::CreateFeature( poLayer->GetLayerDefn() );
>
> then
> Step 4:
> poFeature->SetFID(100);
>  setting to a layer using
>  poLayer->CreateFeature( poFeature )
>
> Step 5:
>
> OGRFeature::DestroyFeature( poFeature );
> then destroying the poFeature,
> again creating the feature using Step 3:
>
> Every thing is fine but the feature id is set to start from 1, but I 
> was expecting
> as 100 for the code flow above,

Please post the whole code. I did a small test using the Perl bindings 
and code, which should be similar

my $ds = Geo::OGR::Driver('GPKG')->Create('test.db');
my $l = $ds->CreateLayer(GeometryType => 'Point');
my $f = Geo::OGR::Feature->new($l->Schema);
$f->Geometry({WKT => 'POINT (1 2)'});
$f->FID(2);
$l->CreateFeature($f);

and the result is a small database with one spatial table, which has two 
columns: fid and geom, and one row. The fid is 2 on the row.

Ari


>
> did I miss some GDAL API call ?.
>
> Thanks
> Gane
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20160217/cd36195c/attachment.html>


More information about the gdal-dev mailing list