Recently I loaded a colleague
\u0026lt;
gpx xmlns = " http://www.topografix.com/GPX/1/1 " tc2 = " ... \u0026lt;Trkseg > 46:55 Z \u0026lt;/ name> : \u0026lt; trk > \u0026lt; name > 2010-11-16T03 \u0026lt;trkpt lat = "51.4799802" lon = "7.9678522" > \u0026lt; he > 270.7484131 \u0026lt;/ it> \u0026lt; team > 2010-11-16T03: 46:55 Z \u0026lt;/ time> \u0026lt;/ trkpt> \u0026lt; trkpt lat = "51.4799436" lon = "7.9678679" > \u0026lt; he > 264.0192871 \u0026lt;/ it> \u0026lt; team > 2010-11-16T03: 47:06 Z \u0026lt;/ time> \u0026lt;/ trkpt> \u0026lt; trkpt lat = "51.4797696" lon = "7.9681059" > \u0026lt; he > 264.4998779 \u0026lt;/ it> \u0026lt; team > 2010-11-16T03: 47:12 Z \u0026lt;/ time> \u0026lt;/ trkpt> \u0026lt; trkpt lat = "51.4797497" lon = "7.9681919" > \u0026lt; he > 264.9805908 \u0026lt;/ he> \u0026lt; time > 2010-11-16T03: 47:14 Z \u0026lt;/ time> \u0026lt;/ trkpt> first I was a little googling for Converter software, but was not quite find (comic license, no conversion to GML or KML, but only in other formats). But since it is an easy-to-understand XML file, I decided I simply write yourself a function that does the work. And here it is ...create
or replace function convert_gpx_to_sdo(Linear Referencing
p_gpxfile in xmltype,
p_lrs in number default 0
) return sdo_geometry is
v_ordinates sdo_ordinate_array := sdo_ordinate_array();
v_gtype number ;
v_cnt pls_integer := 1 ;
v_startts timestamp ;
v_interval interval day ( 9 ) to second ;
c_gpxns varchar2 ( 200 ) := 'xmlns=" http://www.topografix.com/GPX/1/1 "' ;
begin
if p_lrs = 1 then
v_gtype := 3302 ;
else
v_gtype := 2002 ;
end if ;
for tp in (
select
extractvalue( value (tp), '/trkpt/@lon' , c_gpxns) x,
extractvalue( value (tp), '/trkpt/@lat' , c_gpxns) y,
extractvalue( value (tp), '/trkpt/time' , c_gpxns) m
from table (xmlsequence( extract (p_gpxfile, '//trkpt' , c_gpxns))) tp
) loop
if v_cnt = 1 then
v_startts := to_timestamp (tp.m, 'YYYY-MM-DD"T"HH24:MI:SS"Z"' );
end if ;
if p_lrs = 1 then
v_ordinates.extend( 3 );
else
v_ordinates.extend( 2 );
end if ;
v_ordinates(v_cnt) := tp.x;
v_cnt := v_cnt + 1 ;
v_ordinates(v_cnt) := tp.y;
v_cnt := v_cnt + 1 ;
if p_lrs = 1 then
v_interval := to_timestamp (tp.m, 'YYYY-MM-DD"T"HH24:MI:SS"Z"' ) - v_startts;
v_ordinates(v_cnt) :=
extract ( MINUTE from v_interval) +
extract ( HOUR from v_interval) * 60 +
extract ( SECOND from v_interval) / 60 ;
v_cnt := v_cnt + 1 ;
end if ;
end loop ;
return sdo_geometry(v_gtype, 8307 , null , sdo_elem_info_array( 1, 2 , 1) v_ordinates); end convert_gpx_to_sdo; takes / sho err The function of the GPX file ( XMLTYPE ) as the first argument against. The second parameter indicates whether a
geometry to be returned. If so, the Measures be stored in minutes. Give here either "1" or "0" an ... One could certainly do more: the GPX files contain a specified amount - so you could build 3D geometry ... Maybe someone this first version of need - have fun with it!
0 comments:
Post a Comment