Create a new point from a STRING. The coordinates can be separated by a comma (preferrably), or blanks. When the coordinates end on NSEW, the order does not matter, otherwise lat-long or xy order is presumed.
This routine is very smart. It understands:
PROJLABEL VALUE VALUE PROJLABEL: VALUE VALUE PROJLABEL, VALUE, VALUE PROJLABEL: VALUE, VALUE VALUE VALUE VALUE, VALUE utm: ZONE, VALUE, VALUE # also without commas and ':' utm: VALUE, VALUE, ZONE # also without commas and ':' utm: VALUE, VALUE # also without commas and ':' ZONE, VALUE, VALUE # also without commas and ':' VALUE, VALUE, ZONE # also without commas and ':'
The VALUE must be suitable for projection. If only two values are
provided, a d
, single or double quote, or trailing/leading e
, w
,
n
, s
(either lower or upper-case) will force a latlong projection.
Those coordinates must follow the rules of dms2deg().
my $x = 'utm 31n 12311.123 34242.12'; # utm zone 31N my $x = '12311.123 34242.12 31'; # utm zone 31 my $x = '123.123E 12.34'; # wgs84 latlong my $x = 'clrk66 123.123 12.34'; # clrk66 latlong my $x = '12d34'123.1W 11.1123'; # wgs84 longlat my $p = Geo::Point->fromString($x); # When parsing user applications, you probably want: my $p = eval { Geo::Point->fromString($x) }; warn $@ if $@;
See dms2deg() for permitted formats.
See dms2deg() for permitted formats.
A UTM zone can be detected at the beginning or at the end of the input. It contains a number (from 1 upto 60) and an optional latitude indication (C upto X, except I and O).
Most projection require two parameters, but utm requires three (with zone).
Most projection require two parameters, but utm requires three (with zone).
The projection you used (or is set as default) is not defined. See Geo::Proj::new() about how to defined them.
When called as class method, you create a new point. Provide a LATitude and LONGitude. The optional PROJection tells in which coordinate system.
As instance method, the latitude and longitude are reported. You can ask it to be translated into the PROJ coordinate system first.
When PROJ is undefined, none is presumed. The project must be specified as string, which referse to a projection defined by Geo::Proj. See also longlat(), xy(), and yx().
Option | Defined in | Default |
---|---|---|
lat | undef | |
latitude | undef | |
long | undef | |
longitude | undef | |
proj | Geo::Shape | |
x | undef | |
y | undef |
The accessors only work correctly when you are sure that the point is in the right coordinate systems.
Be sure the that coordinates are between -180/180 longitude, -90/90 lattitude. No changes for non-latlong projections.
Always returns zero.
The bounding box of a point contains twice itself.
Compute the distance between the current point and some other POINT in UNITS. The GEODIST object will do the calculations. See distance().
Returns a true value if this point is inside the bounding box of the specified OBJECT. The borders of the bbox are included. This is relatively fast to check, even for complex objects. When the projections differ, the point is translated into the OBJECT's coordinate system, because that one must stay square.
Always returns zero.
Returns the coordinates in their usual order, formatted as string with a joining blank;
Returns the coordinates in the order which is usual for the projection used.
Show the point as DMS value-pair. You must be sure that the coordinate is a projection for which is it usefull to represent the values in DMS. In SCALAR context, one string is returned. In LIST context, the values are returned separately in latlong order.
Be warned, that the returned string may contain single and double quote characters, which may confuse HTML (see dmsHTML()).
Move a point from the eastern calculations into the western calculations, resulting in a value below -180. This is usefull when this point is part of a larger construct, like the corners of a satellite image, which are both sides of the -180 meridian.
my $point = Geo::Point->latlong(24, 179); $point->moveWest; print $point->long; # -181;