.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Geo::Gpx 3pm" .TH Geo::Gpx 3pm "2018-07-19" "perl v5.26.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Geo::Gpx \- Create and parse GPX files. .SH "VERSION" .IX Header "VERSION" This document describes Geo::Gpx version 0.26 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 4 \& # Version 0.10 compatibility \& use Geo::Gpx; \& my $gpx = Geo::Gpx\->new( @waypoints ); \& my $xml = $gpx\->xml; \& \& # New API, generate GPX \& my $gpx = Geo::Gpx\->new(); \& $gpx\->waypoints( \e@wpt ); \& my $xml = $gpx\->xml( \*(Aq1.0\*(Aq ); \& \& # Parse GPX \& my $gpx = Geo::Gpx\->new( xml => $xml ); \& my $waypoints = $gpx\->waypoints(); \& my $tracks = $gpx\->tracks(); \& \& # Parse GPX from open file \& my $gpx = Geo::Gpx\->new( input => $fh ); \& my $waypoints = $gpx\->waypoints(); \& my $tracks = $gpx\->tracks(); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The original goal of this module was to produce \s-1GPX/XML\s0 files which were parseable by both \s-1GPX\s0 Spinner and EasyGPS. As of version 0.13 it has been extended to support general parsing and generation of \s-1GPX\s0 data. \s-1GPX 1.0\s0 and 1.1 are supported. .SH "INTERFACE" .IX Header "INTERFACE" .ie n .SS """new( { args } )""" .el .SS "\f(CWnew( { args } )\fP" .IX Subsection "new( { args } )" The original purpose of \f(CW\*(C`Geo::Gpx\*(C'\fR was to allow an array of Geo::Cache objects to be converted into a \s-1GPX\s0 file. This behaviour is maintained by this release: .PP .Vb 3 \& use Geo::Gpx; \& my $gpx = Geo::Gpx\->new( @waypoints ); \& my $xml = $gpx\->xml; .Ve .PP New applications can use C to parse a \s-1GPX\s0 file : .PP .Vb 1 \& my $gpx = Geo::Gpx\->new( xml => $gpx_document ); .Ve .PP or from an open filehandle : .PP .Vb 1 \& my $gpx = Geo::Gpx\->new( input => $fh ); .Ve .PP or can create an empty container to which waypoints, routes and tracks can then be added: .PP .Vb 2 \& my $gpx = Geo::Gpx\->new(); \& $gpx\->waypoints( \e@wpt ); .Ve .PP The following additional options can be specified: .ie n .IP """ use_datetime """ 4 .el .IP "\f(CW use_datetime \fR" 4 .IX Item " use_datetime " If true time values in parsed \s-1GPX\s0 will be DateTime objects rather than epoch times. .ie n .SS """add_waypoint( waypoint ... )""" .el .SS "\f(CWadd_waypoint( waypoint ... )\fP" .IX Subsection "add_waypoint( waypoint ... )" Add one or more waypoints. Each waypoint must be a reference to a hash. Each waypoint must include the keys \f(CW\*(C`lat\*(C'\fR and \f(CW\*(C`lon\*(C'\fR and may include others: .PP .Vb 10 \& my $wpt = { \& lat => 54.786989, \& lon => \-2.344214, \& ele => 512, \& time => 1164488503, \& magvar => 0, \& geoidheight => 0, \& name => \*(AqMy house & home\*(Aq, \& cmt => \*(AqWhere I live\*(Aq, \& desc => \*(Aq<>\*(Aq, \& src => \*(AqTesting\*(Aq, \& link => { \& href => \*(Aqhttp://hexten.net/\*(Aq, \& text => \*(AqHexten\*(Aq, \& type => \*(AqBlah\*(Aq \& }, \& sym => \*(Aqpin\*(Aq, \& type => \*(Aqunknown\*(Aq, \& fix => \*(Aqdgps\*(Aq, \& sat => 3, \& hdop => 10, \& vdop => 10, \& pdop => 10, \& ageofdgpsdata => 45, \& dgpsid => 247 \& }; \& \& $gpx\->add_waypoint( $wpt ); .Ve .PP Time values may either be an epoch offset or a DateTime. If you wish to specify the timezone use a DateTime. .ie n .SS """iterate_waypoints()""" .el .SS "\f(CWiterate_waypoints()\fP" .IX Subsection "iterate_waypoints()" Get an iterator that visits all the waypoints in a \f(CW\*(C`Geo::Gpx\*(C'\fR. .ie n .SS """iterate_routepoints()""" .el .SS "\f(CWiterate_routepoints()\fP" .IX Subsection "iterate_routepoints()" Get an iterator that visits all the routepoints in a \f(CW\*(C`Geo::Gpx\*(C'\fR. .ie n .SS """iterate_trackpoints()""" .el .SS "\f(CWiterate_trackpoints()\fP" .IX Subsection "iterate_trackpoints()" Get an iterator that visits all the trackpoints in a \f(CW\*(C`Geo::Gpx\*(C'\fR. .ie n .SS """iterate_points()""" .el .SS "\f(CWiterate_points()\fP" .IX Subsection "iterate_points()" Get an iterator that visits all the points in a \f(CW\*(C`Geo::Gpx\*(C'\fR. For example .PP .Vb 4 \& my $iter = $gpx\->iterate_points(); \& while ( my $pt = $iter\->() ) { \& print "Point: ", join( \*(Aq, \*(Aq, $pt\->{lat}, $pt\->{lon} ), "\en"; \& } .Ve .ie n .SS """bounds( [ $iterator ] )""" .el .SS "\f(CWbounds( [ $iterator ] )\fP" .IX Subsection "bounds( [ $iterator ] )" Compute the bounding box of all the points in a \f(CW\*(C`Geo::Gpx\*(C'\fR returning the result as a hash reference. For example: .PP .Vb 2 \& my $gpx = Geo::Gpx\->new( xml => $some_xml ); \& my $bounds = $gpx\->bounds(); .Ve .PP returns a structure like this: .PP .Vb 6 \& $bounds = { \& minlat => 57.120939, \& minlon => \-2.9839832, \& maxlat => 57.781729, \& maxlon => \-1.230902 \& }; .Ve .PP \&\f(CW$iterator\fR defaults to \f(CW\*(C`$self\->iterate_points\*(C'\fR. .ie n .SS """xml( [ $version ] )""" .el .SS "\f(CWxml( [ $version ] )\fP" .IX Subsection "xml( [ $version ] )" Generate \s-1GPX XML.\s0 .PP .Vb 2 \& my $gpx10 = $gpx\->xml( \*(Aq1.0\*(Aq ); \& my $gpx11 = $gpx\->xml( \*(Aq1.1\*(Aq ); .Ve .PP If the version is omitted it defaults to the value of the \f(CW\*(C`version\*(C'\fR attribute. Parsing a \s-1GPX\s0 document sets the version. If the \f(CW\*(C`version\*(C'\fR attribute is unset defaults to 1.0. .PP \&\f(CW\*(C`Geo::Gpx\*(C'\fR version 0.10 used Geo::Cache to render each of the points. Geo::Cache generates a number of hardwired values to suit the original application of that module which aren't appropriate for general purpose \s-1GPX\s0 manipulation. Legacy mode is triggered by passing a list of Geo::Cache points to the constructor; this should probably be avoided for new applications. .ie n .SS """TO_JSON""" .el .SS "\f(CWTO_JSON\fP" .IX Subsection "TO_JSON" For compatibility with \s-1JSON\s0 modules. Converts this object to a hash with keys that correspond to the above methods. Generated ala: .PP .Vb 4 \& my %json = map { $_ => $self\->$_ } \& qw(name desc author keywords copyright \& time link waypoints tracks routes version ); \& $json{bounds} = $self\->bounds( $iter ); .Ve .PP With one difference: the keys will only be set if they are defined. .ie n .SS """gpx""" .el .SS "\f(CWgpx\fP" .IX Subsection "gpx" Synonym for \f(CW\*(C`xml()\*(C'\fR. Provided for compatibility with version 0.10. .ie n .SS """loc""" .el .SS "\f(CWloc\fP" .IX Subsection "loc" Provided for compatibility with version 0.10. .ie n .SS """gpsdrive""" .el .SS "\f(CWgpsdrive\fP" .IX Subsection "gpsdrive" Provided for compatibility with version 0.10. .ie n .SS """name( [ $newname ] )""" .el .SS "\f(CWname( [ $newname ] )\fP" .IX Subsection "name( [ $newname ] )" Accessor for the element of a \s-1GPX.\s0 To get the name: .PP .Vb 1 \& my $name = $gpx\->name(); .Ve .PP and to set it: .PP .Vb 1 \& $gpx\->name( \*(AqMy big adventure\*(Aq ); .Ve .ie n .SS """desc( [ $newdesc ] )""" .el .SS "\f(CWdesc( [ $newdesc ] )\fP" .IX Subsection "desc( [ $newdesc ] )" Accessor for the element of a \s-1GPX.\s0 To get the the description: .PP .Vb 1 \& my $desc = $gpx\->desc(); .Ve .PP and to set it: .PP .Vb 1 \& $gpx\->desc(\*(AqGot lost, wandered around for ages, got cold, got hungry.\*(Aq); .Ve .ie n .SS """author( [ $newauthor ] )""" .el .SS "\f(CWauthor( [ $newauthor ] )\fP" .IX Subsection "author( [ $newauthor ] )" Accessor for the author structure of a \s-1GPX.\s0 The author information is stored in a hash that reflects the structure of a \s-1GPX 1.1\s0 document: .PP .Vb 12 \& my $author = $gpx\->author(); \& $author = { \& link => { \& text => \*(AqHexten\*(Aq, \& href => \*(Aqhttp://hexten.net/\*(Aq \& }, \& email => { \& domain => \*(Aqhexten.net\*(Aq, \& id => \*(Aqandy\*(Aq \& }, \& name => \*(AqAndy Armstrong\*(Aq \& }, .Ve .PP When setting the author data a similar structure must be supplied: .PP .Vb 3 \& $gpx\->author({ \& name => \*(AqMe!\*(Aq \& }); .Ve .PP The bizarre encoding of email addresses as id and domain is a feature of \s-1GPX.\s0 .ie n .SS """time( [ $newtime ] )""" .el .SS "\f(CWtime( [ $newtime ] )\fP" .IX Subsection "time( [ $newtime ] )" Accessor for the