<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>clarification: second table of my points is 'track_points'.</p>
<p>Also adding my 2 gpx files for reference:</p>
<p><b>file1.gpx:</b></p>
<p><font face="monospace"><?xml version="1.0"
encoding="UTF-8"?><br>
<gpx version="1.1"
xmlns=<a class="moz-txt-link-rfc2396E" href="http://www.topografix.com/GPX/1/1">"http://www.topografix.com/GPX/1/1"</a>><br>
<metadata><br>
</metadata><br>
<trk><br>
<trkseg><br>
<trkpt lat="49.250324000" lon="8.687196000"><br>
<ele>1</ele><br>
</trkpt><br>
<trkpt lat="49.250019001" lon="8.687469003"><br>
<ele>1</ele><br>
</trkpt><br>
<trkpt lat="49.249714001" lon="8.687742003"><br>
<ele>1</ele><br>
</trkpt><br>
</trkseg><br>
<trkseg><br>
<trkpt lat="49.125652000" lon="8.714194000"><br>
<ele>2</ele><br>
</trkpt><br>
<trkpt lat="49.125519000" lon="8.714731000"><br>
<ele>2</ele><br>
</trkpt><br>
<trkpt lat="49.125414000" lon="8.715057001"><br>
<ele>2</ele><br>
</trkpt><br>
</trkseg><br>
</trk><br>
</gpx></font></p>
<p><b>file2.gpx:</b></p>
<p><font face="monospace"><?xml version="1.0"
encoding="UTF-8"?><br>
<gpx version="1.1"
xmlns=<a class="moz-txt-link-rfc2396E" href="http://www.topografix.com/GPX/1/1">"http://www.topografix.com/GPX/1/1"</a>><br>
<metadata><br>
</metadata><br>
<trk><br>
<trkseg><br>
<trkpt lat="49.11" lon="8.7"><br>
<ele>3</ele><br>
</trkpt><br>
<trkpt lat="49.12" lon="8.7"><br>
<ele>3</ele><br>
</trkpt><br>
<trkpt lat="49.13" lon="8.7"><br>
<ele>3</ele><br>
</trkpt><br>
</trkseg><br>
</trk><br>
</gpx<br>
</font></p>
<p><br>
</p>
<div class="moz-cite-prefix">Am 01.01.2021 um 18:04 schrieb Michael
Saupe:<br>
</div>
<blockquote type="cite"
cite="mid:53d70791-f882-3252-3ddf-ec51dd23144f@web.de">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<p>Hello folks,</p>
<p>I am importing multiple gpx files into a postgis database. The
tables 'tracks' and 'track_points' are created / updated.<br>
</p>
<p>The column track_fid in in the track_points table should be a
reference to the track feature id as documented in <a
class="moz-txt-link-freetext"
href="https://gdal.org/drivers/vector/gpx.html"
moz-do-not-send="true">https://gdal.org/drivers/vector/gpx.html</a>,
however it is always zero. <br>
</p>
<p>Is this a bug or am I missing something?</p>
<h3>Details</h3>
<p>I am creating an empty database, then create postgis extension
with 'CREATE EXTENSION POSTGIS'</p>
<p>I have two simple gpx files ( see attachments )<br>
</p>
<ul>
<li>file1.gpx - containing 2 track segments - each with 3 track
points<br>
</li>
<li>file2.gpx - containing 1 track segment with 3 track points</li>
</ul>
<p>I am using commands</p>
<p>ogr2ogr -f PostgreSQL -update -append "PG:dbname=testdb
host=localhost user=postgres password=xx port=5432" file1.gpx<br>
</p>
<p>ogr2ogr -f PostgreSQL -update -append "PG:dbname=testdb
host=localhost user=postgres password=xx port=5432" file2.gpx<br>
</p>
<p>Resulting data in 'tracks'</p>
<p> </p>
<table cellspacing="0" border="0">
<colgroup width="68"></colgroup> <colgroup width="55"></colgroup>
<colgroup width="56"></colgroup> <colgroup width="50"></colgroup>
<colgroup width="56"></colgroup> <colgroup width="87"></colgroup>
<colgroup width="86"></colgroup> <colgroup width="90"></colgroup>
<colgroup width="87"></colgroup> <colgroup width="86"></colgroup>
<colgroup width="90"></colgroup> <colgroup width="70"></colgroup>
<colgroup width="46"></colgroup> <tbody>
<tr>
<td height="21" align="left">ogc_fid</td>
<td align="left">name</td>
<td align="left">cmt</td>
<td align="left">desc</td>
<td align="left">src</td>
<td align="left">link1_href</td>
<td align="left">link1_text</td>
<td align="left">link1_type</td>
<td align="left">link2_href</td>
<td align="left">link2_text</td>
<td align="left">link2_type</td>
<td align="left">number</td>
<td align="left">type</td>
<td valign="top">wkb_geometry<br>
</td>
</tr>
<tr>
<td height="21" align="right">1</td>
<td align="left">NULL</td>
<td align="left">NULL</td>
<td align="left">NULL</td>
<td align="left">NULL</td>
<td align="left">NULL</td>
<td align="left">NULL</td>
<td align="left">NULL</td>
<td align="left">NULL</td>
<td align="left">NULL</td>
<td align="left">NULL</td>
<td align="left">NULL</td>
<td align="left">NULL</td>
<td valign="top">...<br>
</td>
</tr>
<tr>
<td height="21" align="right">2</td>
<td align="left">NULL</td>
<td align="left">NULL</td>
<td align="left">NULL</td>
<td align="left">NULL</td>
<td align="left">NULL</td>
<td align="left">NULL</td>
<td align="left">NULL</td>
<td align="left">NULL</td>
<td align="left">NULL</td>
<td align="left">NULL</td>
<td align="left">NULL</td>
<td align="left">NULL</td>
<td valign="top">...<br>
</td>
</tr>
</tbody>
</table>
<p> </p>
<p> </p>
</blockquote>
<p>Resulting data in 'track_points'</p>
<table width="692" height="267" cellspacing="0" border="0">
<tbody>
<tr>
<td height="21" align="left">ogc_fid</td>
<td align="left">track_fid</td>
<td align="left">track_seg_id</td>
<td align="left">track_seg_point_id</td>
<td align="left">ele</td>
<td align="left">time</td>
<td valign="top">.... other columns omitted ...<br>
</td>
</tr>
<tr>
<td height="21" align="right">1</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">1</td>
<td align="left">NULL</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td height="21" align="right">2</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">1</td>
<td align="right">1</td>
<td align="left">NULL</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td height="21" align="right">3</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">2</td>
<td align="right">1</td>
<td align="left">NULL</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td height="21" align="right">4</td>
<td align="right">0</td>
<td align="right">1</td>
<td align="right">0</td>
<td align="right">2</td>
<td align="left">NULL</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td height="21" align="right">5</td>
<td align="right">0</td>
<td align="right">1</td>
<td align="right">1</td>
<td align="right">2</td>
<td align="left">NULL</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td height="21" align="right">6</td>
<td align="right">0</td>
<td align="right">1</td>
<td align="right">2</td>
<td align="right">2</td>
<td align="left">NULL</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td height="21" align="right">7</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">3</td>
<td align="left">NULL</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td height="21" align="right">8</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">1</td>
<td align="right">3</td>
<td align="left">NULL</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td height="21" align="right">9</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">2</td>
<td align="right">3</td>
<td align="left">NULL</td>
<td valign="top"><br>
</td>
</tr>
</tbody>
</table>
<blockquote type="cite"
cite="mid:53d70791-f882-3252-3ddf-ec51dd23144f@web.de">
<p>Expected:</p>
<p> </p>
<table cellspacing="0" border="0">
<colgroup width="68"></colgroup> <colgroup width="79"></colgroup>
<colgroup width="110"></colgroup> <colgroup width="155"></colgroup>
<colgroup width="35"></colgroup> <colgroup width="46"></colgroup>
<tbody>
<tr>
<td height="21" align="left">ogc_fid</td>
<td align="left">track_fid</td>
<td align="left">track_seg_id</td>
<td align="left">track_seg_point_id</td>
<td align="left">ele</td>
<td align="left">time</td>
<td valign="top">.... other columns omitted ...<br>
</td>
</tr>
<tr>
<td height="21" align="right">1</td>
<td align="right">1<br>
</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">1</td>
<td align="left">NULL</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td height="21" align="right">2</td>
<td align="right">1<br>
</td>
<td align="right">0</td>
<td align="right">1</td>
<td align="right">1</td>
<td align="left">NULL</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td height="21" align="right">3</td>
<td align="right">1<br>
</td>
<td align="right">0</td>
<td align="right">2</td>
<td align="right">1</td>
<td align="left">NULL</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td height="21" align="right">4</td>
<td align="right">1<br>
</td>
<td align="right">1</td>
<td align="right">0</td>
<td align="right">2</td>
<td align="left">NULL</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td height="21" align="right">5</td>
<td align="right">1<br>
</td>
<td align="right">1</td>
<td align="right">1</td>
<td align="right">2</td>
<td align="left">NULL</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td height="21" align="right">6</td>
<td align="right">1<br>
</td>
<td align="right">1</td>
<td align="right">2</td>
<td align="right">2</td>
<td align="left">NULL</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td height="21" align="right">7</td>
<td align="right">2<br>
</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">3</td>
<td align="left">NULL</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td height="21" align="right">8</td>
<td align="right">2<br>
</td>
<td align="right">0</td>
<td align="right">1</td>
<td align="right">3</td>
<td align="left">NULL</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td height="21" align="right">9</td>
<td align="right">2<br>
</td>
<td align="right">0</td>
<td align="right">2</td>
<td align="right">3</td>
<td align="left">NULL</td>
<td valign="top"><br>
</td>
</tr>
</tbody>
</table>
<p>I also tried to omit -update -append, but same result.<br>
</p>
<p>Versions:</p>
<ul>
<li>Postgres: "PostgreSQL 12.5 on x86_64-pc-linux-musl, compiled
by gcc (Alpine 9.3.0) 9.3.0, 64-bit"<br>
</li>
<li>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)""<br>
</li>
<li>Gdal: 3.2.0<br>
</li>
</ul>
</blockquote>
</body>
</html>