Opened 11 years ago

Closed 11 years ago

#3637 closed defect (invalid)

ogr2ogr PG driver doesn't properly set track_points::track_fid

Reported by: wstrzalka Owned by: warmerdam
Priority: normal Milestone:
Component: Utilities Version: 1.7.2
Severity: major Keywords:
Cc:

Description

track_points::track_fid is in no relation to tracks::ogc_fid which is it's parent record.

After importing large gpx file to empty database the result of the following query is:


SELECT COUNT(track_fid) FROM track_points AS tp LEFT JOIN tracks AS t ON (tp.track_fid=t.ogc_fid) WHERE t.ogc_fid IS NULL;

count


538794

(1 row)


While the doc says:


In addition to its GPX attributes, each route point of a route has a route_fid (foreign key to the FID of its belonging route) and a route_point_id which is its sequence number in the route. The same applies for track points with track_fid, track_seg_id and track_seg_point_id.


Of course trying to set an FK there ends with failure.

Change History (1)

comment:1 Changed 11 years ago by Even Rouault

Resolution: invalid
Status: newclosed

Make sure to use the -preserve_fid flag of ogr2ogr when you convert your GPX file into PG tables, so that the FID of the GPX layers is used to fill in the ogc_fid of the PG tables. Without it, PG will begin the ogc_fid sequence at 1, whereas the GPX driver begins at 0... If you don't specify it, you'll get a mismatch : the track_points of the first track won't be associated with any track, and the track_points of the (n+1)th track would be associate with the (n)th track

Note: See TracTickets for help on using tickets.