Geo::Sh...::Index(3)
π Geo::Sh...::Index(3) π
okay bestie, you found it β the Geo::Sh...::Index(3) page, straight out of the User Contributed Perl Documentation collection. it's a whole utility class situation and honestly? it's giving quiet overachiever. let's get into it π«Ά
β¨ NAME β¨
Geo::ShapeFile::Shape β a Geo::ShapeFile utility class. that's the whole name section, no notes. π
πΈ SYNOPSIS πΈ
use Geo::ShapeFile::Shape::Index;
my $index = Geo::ShapeFile::Shape->new;
# $pt1 and $pt2 are point objects in this example.
my $segment = [$pt1, $pt2]; # example of something to pack into the index.
my @bbox = ($x_min, $y_min, $x_max, $y_max);
$index->insert($segment, @bbox);
like, it's that easy. you make an index, you pack a thing in, you hand it a bounding box. slay. β¨
π¦ ABSTRACT π¦
This is a utility class for L<Geo::ShapeFile> that indexes shape objects.
a utility class for L<Geo::ShapeFile> whose whole job is indexing shape objects. iconic behaviour, truly. π
π DESCRIPTION π
so here's the tea: this is a 2-d block-based index class for Geo::ShapeFile::Shape objects. and ngl, it probably has way more generic applications too β it's not gonna gatekeep. π
it uses a flat 2-d structure made up of a series of blocks of full width, which slice the shape along the y-axis. (and lowkey, it should really also use blocks along the x-axis, but that's just how it is rn.)
the index coordinates are literally just the number of blocks across and up from the minimum coordinate you specified in the new() call. they get stored as strings joined by a colon, so 0:0 is the lower left, periodt. β
heads up! negative block coordinates can totally happen if you add data that falls outside the specified bounds. but bestie, don't stress β this should not affect the index, because it's merely a relative offset. π
it's used internally by Geo::ShapeFile::Shape, so go look over there for examples. the method names are adapted from Tree::R to make the transition easier during development, but the arguments have morphed along the way, so it is not a drop-in replacement. iykyk. π§
π EXPORT π
none by default. that's it, that's the export. π
π₯ METHODS π₯
new($n_blocks_y, @bbox)β creates a newGeo::ShapeFile::Shape::Indexobject and returns it, main character energy from the jump.$n_blocks_yis the number of blocks along the y-axis, and@bboxis the bounding box the index represents:(x_min, y_min, x_max, y_max). β¨insert($item, $min_x, $min_y, $max_x, $max_y)β adds item$itemto the blocks that overlap with the specified bounds. returns the number of blocks the item was added to, so you know exactly how much chaos you caused. πquery_point($x, $y)β returns an array of objects on the block that contains point$x,$y. in scalar context it returns an arrayref instead. one method, two vibes. π¦get_x_max()get_x_min()get_y_max()get_y_min()β the bounds of the index, exactly as they were set in the call to->new(). β οΈ there is no guarantee these are the bounds of the data, because data outside the original bounds can still be indexed. so like, don't assume. πget_y_res()β block resolution along the y-axis. short, sweet, to the point. πΈsnap_to_index ($x, $y)β returns the index key associated with point$x,$y. it does not check whether that point is outside the bounds of the index, so negative index values are absolutely possible. proceed accordingly bestie. π
π REPORTING BUGS π
please send any bugs, suggestions, or feature requests to:
<https://github.com/shawnlaffan/Geo-ShapeFile/issues>
we're not mad, we're just asking. π«Ά
π SEE ALSO π
Geo::ShapeFile::Shape
π AUTHOR π
Shawn Laffan, <shawnlaffan@gmail.com>. the icon who made all this happen. β
π COPYRIGHT AND LICENSE π
Copyright 2014-2023 by Shawn Laffan
this library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page, bestie β this one shipped as perl v5.42.0 on 2025-07-25, so go forth and index responsibly. no cap. ππβ¨
π¦ where this page comes from
- fedora 43: perl-Geo-ShapeFile 3.03-7.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms