Geo::Gpx::Point(3pm)

πŸ“¦
version 1.11 Β· 3 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

okay so bestie, welcome to the Geo::Gpx::Point(3pm) page ✨ this is the class that stores and edits GPX Waypoints β€” like, the little dots on a map, but make it code πŸŽ€


🌸 SYNOPSIS 🌸

use Geo::Gpx::Point;

that's it. that's the whole vibe. go off πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

Geo::Gpx::Point hands you a data structure for GPX points, plus a whole lil squad of accessor methods so you can read and edit the point data. no cap πŸ’œ

✨ Constructor Method ✨

  • new( lat => $lat, lon => $lon [, ele => $ele, desc => $desc, … ] ) β€” makes a brand new point and returns it, using whatever fields you gave it. the fields can be any of lat lon ele time magvar geoidheight name cmt desc src link sym type fix sat hdop vdop pdop ageofdgpsdata dgpsid. most of them want number-y values, EXCEPT name, cmt, desc, src, sym, type, fix which are allowed to be strings 🫢

lat and lon are required, every other key is optional, so don't stress.

%fields = ( lat => 47.0871, lon => 70.9318, ele => 808.000, name => 'MSA', desc => 'A nice view of the River at the top');
$pt = Geo::Gpx::Point->new( %fields );

the link field needs to be structured like this, iykyk:

link => { href => 'http://hexten.net/', text => 'Hexten', type => 'Blah' },
  • flex_coordinates( $lat, $lon, %fields ) β€” takes latitude and longitude as decimal values or strings and returns a Geo::Gpx::Point object. latitude always comes before longitude, no exceptions bestie. both can be in formatted form (aka Degrees, Minutes, Seconds, aka dms) and the constructor will try to convert them to decimals. any other %fields are optional ✨
$pt = Geo::Gpx::Point->flex_coordinates( '47.0871', '-70.9318', desc => 'Mont Ste-Anne' );

now if you pass a string reference as the first argument (instead of $lat and $lon), the constructor will try to parse it as coordinates β€” decimal-form only tho, don't get cute. so you can literally just call flex_coordinates( '47.0871 -70.9318' ) with or without a comma, plus optional fields πŸ’…

$str_ref = \'47.0871 -70.9318';
$pt = Geo::Gpx::Point->flex_coordinates($str_ref, desc => 'Mont Ste-Anne' );
  • clone() β€” returns a deep copy of the Geo::Gpx::Point. yes, a deep copy. it's giving main character energy, not shared references 😌
$clone = $ggp->clone;

πŸŽ€ AUTOLOAD Methods πŸŽ€

  • field( $value ) β€” methods relating to the object's fields can be autoloaded. iconic behaviour tbh.

the possible fields are the ones listed and accepted by new(), specifically: lat, lon, ele, time, magvar, geoidheight, name, cmt, desc, src, link, sym, type, fix, sat, hdop, vdop, pdop, ageofdgpsdata, and dgpsid ⭐

⚠️ some fields can hold a value of 0, so it is safer to check if a field is defined with if (defined $point->ele) rather than if ($point->ele). because 0 is falsy and that's a trap, bestie 😭
⚠️ also, caution should be used if setting a $value β€” no checks are performed to make sure the value is appropriate or in the proper format. so it's your world, but you could absolutely shoot your own foot πŸ’€

🌈 Object Methods 🌈

  • distance_to( $pt or lat => $lat, lon => $lon, [ %options ] ) β€” returns the distance in meters from the Geo::Gpx::Point $pt, or from the coordinates given by $lat and $lon. it's calculated as the straight-line distance, ignoring any topography β€” so like, it does not care about the mountain in your way πŸ”οΈ. $pt must be the first argument if you specify it.

%options can be any of these key/value pairs (all optional, all slay):

  • "dec => $decimals" β€” how many digits to return after the decimal point. defaults to 6 but this will change to 1 or 2 in the future πŸ‘€
  • "km => boole" β€” scale the return value to kilometers rather than meters (default is false).
  • "rad => $radius" β€” the earth's radius in kilometers (see below).

$radius should rarely be specified unless the user knows what they are doing. the default is the global average of 6371 kilometers, and any value outside the 6357 to 6378 range will be ignored. this implies that a given value would affect the returned distance by at most 0.16 percent versus the global average. so yeah, leave it alone fr fr πŸ™ˆ

  • to_geocalc() β€” returns a point as a Geo::Calc object. (requires that the Geo::Calc module be installed.) 🧚
  • to_tcx() β€” returns a point as a basic Geo::TCX::Trackpoint object, i.e. a point with only Position information. (requires that the Geo::TCX module be installed.) πŸ¦‹
  • time_datetime () β€” returns a DateTime object corresponding to the time of the point. the time_zone of the object will be 'UTC'. specify time_zone => $tz to set a different one πŸ’œ
  • summ() β€” for debugging purposes mostly. summarizes the fields of the point by printing to screen. returns nothing. it's giving "just vibes, no return value" 😌
  • as_string() β€” returns a string with the coordinates, e.g. lat="47.0871" lon="-70.9318" ✨

πŸ‘‘ Overloaded Methods πŸ‘‘

as_string() is called when you use a Geo::Gpx::Point instance as a string. so it just... becomes a string when you need it to. main character behaviour honestly πŸ’…


πŸ’€ EXAMPLES πŸ’€

Coming soon. (not me leaving you on read, i promise more is coming πŸ™ˆ)


πŸ’– AUTHOR πŸ’–

Patrick Joly <patjol@cpan.org>.


⭐ VERSION ⭐

1.11


🫢 SEE ALSO 🫢

perl(1).


and that's a wrap bestie 🌸 this lil page came to you from perl v5.38.2, dated 2024-06-26, and it's the Geo::Gpx::Point(3pm) manual β€” go plot some waypoints, you absolute icon πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from