1Geo::ShapeFile::Shape(3U)ser Contributed Perl DocumentatiGoeno::ShapeFile::Shape(3)
2
3
4

NAME

6       Geo::ShapeFile::Shape - Geo::ShapeFile utility class.
7

SYNOPSIS

9         use Geo::ShapeFile::Shape;
10
11         my $shape = Geo::ShapeFile::Shape->new;
12         $shape->parse_shp($shape_data);
13

ABSTRACT

15         This is a utility class for Geo::ShapeFile that represents shapes.
16

DESCRIPTION

18       This is the Geo::ShapeFile utility class that actually contains shape
19       data for an individual shape from the shp file.
20
21   EXPORT
22       None by default.
23

METHODS

25       new()
26           Creates a new Geo::ShapeFile::Shape object, takes no arguments and
27           returns the created object.  Normally Geo::ShapeFile does this for
28           you when you call its get_shp_record() method, so you shouldn't
29           need to create a new object.  (Eventually this module will have
30           support for _creating_ shapefiles rather than just reading them,
31           then this method will become important.
32
33       num_parts()
34           Returns the number of parts that make up this shape.
35
36       num_points()
37           Returns the number of points that make up this shape.
38
39       points()
40           Returns an array of Geo::ShapeFile::Point objects that contains all
41           the points in this shape.  Note that because a shape can contain
42           multiple segments, which may not be directly connected, you
43           probably don't want to use this to retrieve points which you are
44           going to plot.  If you are going to draw the shape, you probably
45           want to use get_part() to retrieve the individual parts instead.
46
47       get_part($part_index);
48           Returns the specified part of the shape.  This is the information
49           you want if you intend to draw the shape.  You can iterate through
50           all the parts that make up a shape like this:
51
52             for(1 .. $obj->num_parts) {
53               my $part = $obj->get_part($_);
54               # ... do something here, draw a map maybe
55             }
56
57       shape_type()
58           Returns the numeric type of this shape, use Geo::ShapeFile::type()
59           to determine the human-readable name from this type.
60
61       shape_id()
62           Returns the id number for this shape, as contained in the shp file.
63
64       x_min() x_max() y_min() y_max()
65       z_min() z_max() m_min() m_max()
66           Returns the minimum/maximum ranges of the X, Y, Z, or M values for
67           this shape, as contained in it's header information.
68
69       has_point($point)
70           Returns true if the point object provided matches one of the points
71           in the shape.  Note that this does a simple comparison with the
72           points that make up the shape, it will not find a point that falls
73           along a vertex between two points in the shape.  See the
74           Geo::ShapeFile::Point documentation for a note about how to exclude
75           Z and/or M data from being considered when matching points.
76
77       contains_point($point); =item contains_point($point, $use_index);
78           Returns true if the specified point falls in the interior of this
79           shape and false if the point is outside the shape.  Return value is
80           unspecified if the point is one of the vertices or lies on some
81           segment of the bounding polygon.
82
83           Passing $use_index uses a spatial index if defined (building it if
84           needed).  See build_spatial_index for more details.  This will be
85           the default behaviour in a future release.
86
87           Note that the algorithm uses a sidedness algorithm ignoring Z and M
88           fields and so will likely not work if the point is contained within
89           a shape winding the wrong way.  Polygon shapes should be
90           anticlockwise for outer boundaries, and clockwise for inner void
91           polygons.
92
93       build_spatial_index ($index_res)
94           Builds a spatial index for use in contains_point().  $index_res is
95           a positive integer which sets the nnumber of along the y-axis.  A
96           value of 0 lets the system determine the number.
97
98       get_spatial_index()
99           Gets the spatial index.  This is a hash indexed by part number.
100           Returns a hash reference in scalar context.
101
102       bounds
103           Returns the object's bounds as an array (x_min, y_min, x_max,
104           y_max).  Returns an array ref in scalar context.
105
106       get_segments($part)
107           Returns an array consisting of array hashes, which contain the
108           points for each segment of a multi-segment part.
109
110       vertex_centroid( $part );
111           Returns a Geo::ShapeFile::Point that represents the calculated
112           centroid of the shapes vertices.  If given a part index, calculates
113           just for that part, otherwise calculates it for the entire shape.
114           See "centroid" for more on vertex_centroid vs area_centroid.
115
116       area_centroid( $part );
117           Returns a Geo::ShapeFile::Point that represents the calculated area
118           centroid of the shape.  If given a part index, calculates just for
119           that part, otherwise calculates it for the entire shape. See
120           "centroid" for more on vertex_centroid vs area_centroid.
121
122       centroid($part)
123           For backwards-compatibility reasons, centroid() is currently an
124           alias to vertex_centroid(), although it would probably make more
125           sense for it to point to area_centroid().  To avoid confusion (and
126           possible future deprecation), you should avoid this and use either
127           vertex_centroid or area_centroid.
128
129       dump()
130           Returns a text dump of the object, showing the shape type, id
131           number, number of parts, number of total points, the bounds for the
132           X, Y, Z, and M ranges, and the coordinates of the points in each
133           part of the shape.
134

REPORTING BUGS

136       Please send any bugs, suggestions, or feature requests to
137         <https://github.com/shawnlaffan/Geo-ShapeFile/issues>.
138

SEE ALSO

140       Geo::ShapeFile
141

AUTHOR

143       Jason Kohles, <email@jasonkohles.com>
144
145       Shawn Laffan, <shawnlaffan@gmail.com>
146
148       Copyright 2002-2013 by Jason Kohles
149
150       Copyright 2014 by Shawn Laffan
151
152       This library is free software; you can redistribute it and/or modify it
153       under the same terms as Perl itself.
154
155
156
157perl v5.32.0                      2020-07-28          Geo::ShapeFile::Shape(3)
Impressum