1Geo::Shape(3) User Contributed Perl Documentation Geo::Shape(3)
2
3
4
6 Geo::Shape - base class for 2-dimensional points on the earth surface
7
9 Geo::Shape is extended by
10 Geo::Line
11 Geo::Point
12 Geo::Space
13 Geo::Surface
14
16 use Geo::Shape;
17
18 my $p1 = Geo::Point->new(lat => 2.17, ...);
19 my $p2 = Geo::Point->latlong(2.17, 3.14); # wgs84 is default
20
21 my $p3 = $p1->in('wgs84'); # conversion
22 my $p4 = $p1->in('utm'); # conversion
23
25 Base class for the many geo-spatial objects defined by the GeoPoint
26 distribution.
27
29 Constructors
30 $obj->new(%options)
31 Geo::Shape->new(%options)
32 Create a new object.
33
34 -Option--Default
35 proj see Geo::Proj::defaultProjection()
36
37 proj => LABEL
38
39 Attributes
40 $obj->proj()
41 Returns the nickname of the projection used by the component. Be
42 warned: this is not a Geo::Point object, but just a label.
43
44 $obj->proj4()
45 Returns the proj4 object which handles the projection.
46
47 Projections
48 $obj->in( <$label|'utm'> )
49 The coordinates of this point in a certain projection, referred to
50 with the $label. The projection is defined with new(). When
51 simply 'utm' is provided, the best UTM zone is selected.
52
53 In LIST context, the coordinates are returned. In SCALAR context,
54 a new object is returned.
55
56 example:
57
58 my $gp = Geo::Point->latlong(1,2);
59
60 # implicit conversion to wgs84, if not already in latlong
61 my ($lat, $long) = $pr->latlong;
62
63 # will select an utm zone for you
64 my $p_utm = $gp->in('utm');
65 my ($x, $y) = $p_utm->xy;
66 my $label = $p_utm->proj;
67 my ($datum, $zone) = $label =~ m/^utm-(\w+)-(\d+)$/;
68
69 $obj->projectOn($nick, @points)
70 The @points are ARRAYs with each an X and Y coordinate of a single
71 point in space. A list of transformed points is returned, which is
72 empty if no change is needed. The returned list is preceded by the
73 projection nick of the result; usually the same as the provided
74 $nick, but in some cases (for instance UTM) it may differ.
75
76 Geometry
77 $obj->area()
78 Returns the area covered by the geo structure. Points will return
79 zero.
80
81 $obj->bbox()
82 Returns the bounding box of the object as four coordinates,
83 respectively xmin, ymin, xmax, ymax. The values are expressed in
84 the coordinate system of the object.
85
86 $obj->bboxCenter()
87 Returns a Geo::Point which represent the middle of the object. It
88 is the center of the bounding box. The values is cached, once
89 computed.
90
91 Be warned that the central point in one projection system may be
92 quite different from the central point in some other
93 projectionsystem .
94
95 $obj->bboxRing( [$xmin, $ymin, $xmax, $ymax, [$proj]] )
96 Geo::Shape->bboxRing( [$xmin, $ymin, $xmax, $ymax, [$proj]] )
97 Returns a Geo::Line which describes the outer bounds of the object
98 called upon, counter-clockwise and left-bottom first. As class
99 method, you need to specify the limits and the PROJection.
100
101 $obj->distance( $object, [$unit] )
102 Calculate the distance between this object and some other object.
103 For many combinations of objects this is not supported or only
104 partially supported.
105
106 This calculation is performed with Geo::Distance in accurate mode.
107 The default $unit is kilometers. Other units are provided in the
108 manual page of Geo::Distance. As extra unit, "degrees" and
109 "radians" are added as well as the "km" alias for kilometer.
110
111 $obj->perimeter()
112 Returns the length of the outer border of the object's components.
113 For points, this returns zero.
114
115 Display
116 $obj->deg2dm($degrees, $pos, $neg)
117 Geo::Shape->deg2dm($degrees, $pos, $neg)
118 Like deg2dms() but without showing seconds.
119
120 example:
121
122 print $point->deg2dm(0.12, 'e', 'w');
123 print Geo::Shape->deg2dm(0.12, 'e', 'w');
124
125 $obj->deg2dms($degrees, $pos, $neg)
126 Geo::Shape->deg2dms($degrees, $pos, $neg)
127 Translate floating point $degrees into a "degrees minutes seconds"
128 notation. An attempt is made to handle rounding errors.
129
130 example:
131
132 print $point->deg2dms(-12.34, 'E', 'W');' # --> 12d20'24"W
133 print Geo::Shape->deg2dms(52.1234, 'E', 'W'); # --> 52d07'24"E
134
135 $obj->dms2deg($dms)
136 Geo::Shape->dms2deg($dms)
137 Accepts for instance 3d12'24.123, 3d12"E, 3.12314w, n2.14, s3d12",
138 -12d34, and returns floating point degrees.
139
141 overload: '""' (stringification)
142 Returns a string "$proj($lat,$long)" or "$proj($x,$y)". The $proj
143 is the nickname you have assigned to the projection.
144
145 overload: 'bool' (truth value)
146 A point is always true: defined.
147
149 Error: distance calculation not implemented between a $kind and a $kind
150 Only a subset of all objects can be used in the distance
151 calculation. The limitation is purely caused by lack of time to
152 implement this.
153
154 Error: in() not implemented for a $class
155
157 This module is part of Geo-Point distribution version 0.98, built on
158 February 01, 2019. Website: http://perl.overmeer.net/CPAN/
159
161 Copyrights 2005-2019 by [Mark Overmeer]. For other contributors see
162 ChangeLog.
163
164 This program is free software; you can redistribute it and/or modify it
165 under the same terms as Perl itself. See http://dev.perl.org/licenses/
166
167
168
169perl v5.30.0 2019-07-26 Geo::Shape(3)