GPXRead
Signatures
GPXRead(VARCHAR path);
GPXRead(VARCHAR path, BOOLEAN deleteTable);
GPXRead(VARCHAR path, VARCHAR tableName);
GPXRead(VARCHAR path, VARCHAR tableName, BOOLEAN deleteTable);
GPXRead(VARCHAR path, VARCHAR tableName, VARCHAR fileEncoding);
GPXRead(VARCHAR path, VARCHAR tableName, VARCHAR fileEncoding, BOOLEAN deleteTable);
Description
Reads a GPX file from path and creates several tables prefixed by tableName representing the file’s contents.
Tables are produced depending on the content of the GPX file, and may include:
TABLENAME_WAYPOINTTABLENAME_ROUTETABLENAME_ROUTEPOINTTABLENAME_TRACKTABLENAME_TRACKPOINTTABLENAME_TRACKSEGMENT
Define fileEncoding to force encoding (useful when the header is missing encoding information) (default value is ISO-8859-1).
If:
the
tablenameparameter is not specified, then the resulting tables are prefixed with the same name as the GPX file.the
deleteTableparameter istrueand tables prefixed withtableNamealready exists in the database, then tablestableNamewill be removed / replaced by the new ones. Else (nodeleteTableparameter ordeleteTableequal tofalse), an error indicating that the tables prefixed withtableNamealready exists will be throwned.
Warning on the input file name
When a tablename is not specified, special caracters in the input file name are not allowed. The possible caracters are as follow: A to Z, _ and 0 to 9.
Examples
In the following example, we are using two .gpx files presented below (and coming from this webpage) and stored in /home/user/:
Track file : road.gpx
<trk>
<name>ACTIVE LOG</name>
<trkseg>
<trkpt lat="43.858259" lon="11.097178">
<ele>66.468262</ele>
<time>2005-03-20T07:20:37Z</time>
</trkpt>
<trkpt lat="43.858280" lon="11.097243">
<ele>40.032104</ele>
<time>2005-03-20T07:20:49Z</time>
</trkpt>
<trkpt lat="43.858280" lon="11.097114">
<ele>40.512817</ele>
<time>2005-03-20T07:20:57Z</time>
</trkpt>
</trkseg>
</trk>
Waypoints file : station.gpx
<wpt lat="43.148408839" lon="10.853555845">
<ele>74.387085</ele>
<name>020</name>
<cmt>020</cmt>
<desc>020</desc>
<sym>Flag</sym>
</wpt>
1. Using path
a. With a track file
CALL GPXRead('/home/user/road.gpx');
Returns the following tables:
ROAD_TRACK
ROAD_TRACKPOINT
ROAD_TRACKSEGMENT
b. With a waypoints file
CALL GPXRead('/home/user/station.gpx');
Returns the following table:
STATION_WAYPOINT
2. Using path and tableName
CALL GPXRead('/home/user/road.gpx', 'GPXROAD');
Returns the following tables:
GPXROAD_TRACK
GPXROAD_TRACKPOINT
GPXROAD_TRACKSEGMENT
3. Case with fileEncoding
CALL GPXRead('/home/user/road.gpx', 'GPXROAD', 'utf-8');
4. Case with deleteTable
Load the road.gpx file
CALL GPXRead('/home/user/road.gpx', 'GPXROAD');
→ the tables GPXROAD_TRACK, GPXROAD_TRACKPOINT and GPXROAD_TRACKSEGMENT are created.
Now, load once again, using deleteTable = true
CALL GPXRead('/home/user/road.gpx', 'GPXROAD', true);
→ the already existing GPXROAD_ tables are removed / replaced.
Now, load once again, using deleteTable = false
CALL GPXRead('/home/user/road.gpx', 'GPXROAD', false);
→ Error message: The table "GPXROAD_TRACK" already exists.