Hi,

For my mind the behavior is consistent. FID (in this case named as ogc_fid)
is a unique feature ID and tracks table contains tracks so it is natural
that FID is increasing when more tracks are added - and it must increase or
otherwise the FID is not unique. The track_points table contains points and
FID is unique for each point. If you add more track points the ogc_fid will
increase from the maximum existing ogc_fid value. The track id in the
track_points column in just a normal attribute and it is read directly from
the GPX data.

-Jukka Rahkonen-


Michael Saupe-2 wrote
> Hi Evan,
> 
> thank you for the explanation. That makes sense. However, in my opinion
> ogr2ogr behavior is not really consistent in this case: The column ogc_fid
> , which is in fact the track id, is incremented on each gpx file import (
> regardless if you use -update -appendĀ  or not ).
> 
> Michael
> 
> Am 02.01.2021 um 14:03 schrieb Even Rouault:
>> Michael,
>>
>> You have a single track in each file, so it is expected that track_fid
>> doesn't 
>> change and is set at 0 (as there's no attribute to uniquely identify a
>> track)
>> For what you want to do (that is have distinct track_fid for each file), 
>> you'll likely have to use an intermediate postgresql schema, where you
>> would 
>> correct the value of track_fid, before merging them together
>>
>> Even
>>
>>> clarification: second table of my points is 'track_points'.
>>>
>>> Also adding my 2 gpx files for reference:
>>>
>>> *file1.gpx:*
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> 
> <gpx version="1.1" xmlns="http://www.topografix.com/GPX/1/1";>
>>>   
> <metadata>
>>>   
> </metadata>
>>>   
> <trk>
>>>     
> <trkseg>
>>>       
> <trkpt lat="49.250324000" lon="8.687196000">
>>>         
> <ele>
> 1
> </ele>
>>>       
> </trkpt>
>>>       
> <trkpt lat="49.250019001" lon="8.687469003">
>>>         
> <ele>
> 1
> </ele>
>>>       
> </trkpt>
>>>       
> <trkpt lat="49.249714001" lon="8.687742003">
>>>         
> <ele>
> 1
> </ele>
>>>       
> </trkpt>
>>>     
> </trkseg>
>>>     
> <trkseg>
>>>       
> <trkpt lat="49.125652000" lon="8.714194000">
>>>         
> <ele>
> 2
> </ele>
>>>       
> </trkpt>
>>>       
> <trkpt lat="49.125519000" lon="8.714731000">
>>>         
> <ele>
> 2
> </ele>
>>>       
> </trkpt>
>>>       
> <trkpt lat="49.125414000" lon="8.715057001">
>>>         
> <ele>
> 2
> </ele>
>>>       
> </trkpt>
>>>     
> </trkseg>
>>>   
> </trk>
>>> 
> </gpx>
>>>
>>> *file2.gpx:*
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> 
> <gpx version="1.1" xmlns="http://www.topografix.com/GPX/1/1";>
>>>   
> <metadata>
>>>   
> </metadata>
>>>   
> <trk>
>>>     
> <trkseg>
>>>       
> <trkpt lat="49.11" lon="8.7">
>>>         
> <ele>
> 3
> </ele>
>>>       
> </trkpt>
>>>       
> <trkpt lat="49.12" lon="8.7">
>>>         
> <ele>
> 3
> </ele>
>>>       
> </trkpt>
>>>       
> <trkpt lat="49.13" lon="8.7">
>>>         
> <ele>
> 3
> </ele>
>>>       
> </trkpt>
>>>     
> </trkseg>
>>>   
> </trk>
>>> 
> </gpx
>>
>>
>>> Am 01.01.2021 um 18:04 schrieb Michael Saupe:
>>>> Hello folks,
>>>>
>>>> I am importing multiple gpx files into a postgis database. The tables
>>>> 'tracks' and 'track_points' are created / updated.
>>>>
>>>> The column track_fid in in the track_points table should be a reference
>>>> to
>>>> the track feature id as documented in
>>>> https://gdal.org/drivers/vector/gpx.html, however it is always zero. 
>>>>
>>>> Is this a bug or am I missing something?
>>>>
>>>>       Details
>>>>
>>>> I am creating an empty database, then create postgis extension with
>>>> 'CREATE EXTENSION POSTGIS'
>>>>
>>>> I have two simple gpx files ( see attachments )
>>>>
>>>>   * file1.gpx - containing 2 track segments - each with 3 track points
>>>>   * file2.gpx - containing 1 track segment  with 3 track points
>>>>
>>>> I am using commands
>>>>
>>>> ogr2ogr -f PostgreSQL -update -append "PG:dbname=testdb host=localhost
>>>> user=postgres password=xx port=5432" file1.gpx
>>>>
>>>> ogr2ogr -f PostgreSQL -update -append "PG:dbname=testdb host=localhost
>>>> user=postgres password=xx port=5432" file2.gpx
>>>>
>>>> Resulting data in 'tracks'
>>>>
>>>> ogc_fid    name    cmt     desc    src     link1_href      link1_text      
>>>> link1_type
>>>>    link2_href      link2_text      link2_type      number  type    
>>>> wkb_geometry 1  
>> NULL
>>>>    NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    
>>>> NULL    
>> NULL         ... 2
>>>>    NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    
>>>> NULL    
>> NULL         NULL
>>>>    ...
>>> Resulting data in 'track_points'
>>>
>>> ogc_fid     track_fid       track_seg_id    track_seg_point_id      ele     
>>> time    .... 
>> other
>>> columns omitted ... 1       0       0       0       1       NULL
>>> 2   0       0       1       1       NULL
>>> 3   0       0       2       1       NULL
>>> 4   0       1       0       2       NULL
>>> 5   0       1       1       2       NULL
>>> 6   0       1       2       2       NULL
>>> 7   0       0       0       3       NULL
>>> 8   0       0       1       3       NULL
>>> 9   0       0       2       3       NULL
>>>
>>>> Expected:
>>>>
>>>> ogc_fid    track_fid       track_seg_id    track_seg_point_id      ele     
>>>> time    ....
>>>> other columns omitted ... 1        1
>>>>
>>>>    0       0       1       NULL
>>>>
>>>> 2  1
>>>>
>>>>    0       1       1       NULL
>>>>
>>>> 3  1
>>>>
>>>>    0       2       1       NULL
>>>>
>>>> 4  1
>>>>
>>>>    1       0       2       NULL
>>>>
>>>> 5  1
>>>>
>>>>    1       1       2       NULL
>>>>
>>>> 6  1
>>>>
>>>>    1       2       2       NULL
>>>>
>>>> 7  2
>>>>
>>>>    0       0       3       NULL
>>>>
>>>> 8  2
>>>>
>>>>    0       1       3       NULL
>>>>
>>>> 9  2
>>>>
>>>>    0       2       3       NULL
>>>>
>>>> I also tried to omit -update -append, but same result.
>>>>
>>>> Versions:
>>>>   * Postgres: "PostgreSQL 12.5 on x86_64-pc-linux-musl, compiled by gcc
>>>>   (Alpine 9.3.0) 9.3.0, 64-bit" * Postgis: "POSTGIS="3.0.3 0"
>>>> [EXTENSION]
>>>>   PGSQL="120" GEOS="3.8.1-CAPI-1.13.3" PROJ="7.0.1" LIBXML="2.9.10"
>>>>   LIBJSON="0.14" LIBPROTOBUF="1.3.3" WAGYU="0.4.3 (Internal)"" * Gdal:
>>>>   3.2.0
>>
> 
> _______________________________________________
> gdal-dev mailing list

> [email protected]

> https://lists.osgeo.org/mailman/listinfo/gdal-dev





--
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html
_______________________________________________
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to