NAME
Geo::Geos - Perl interface for GEOS C++ library
SYNOPSIS
my
$srid
= 3857;
# coordinate system
my
$pm
= Geo::Geos::PrecisionModel->new(TYPE_FLOATING);
my
$gf
= Geo::Geos::GeometryFactory::create(
$pm
, 3857);
my
$lr
=
$gf
->createLinearRing([
Geo::Geos::Coordinate->new(1,2),
Geo::Geos::Coordinate->new(5,2),
Geo::Geos::Coordinate->new(5,0),
Geo::Geos::Coordinate->new(1,0),
Geo::Geos::Coordinate->new(1,2),
], 2);
my
$polygon
=
$gf
->createPolygon(
$lr
);
my
$point
=
$gf
->createPoint(Geo::Geos::Coordinate->new(5,4));
# query
$polygon
->getArea;
# => is 8
$polygon
->getLength;
# => is 12
$polygon
->distance(
$point
);
# => is 2
$polygon
->getCentroid;
# => is 'POINT (3.0000000000000000 1.0000000000000000)'
# operations
$polygon
->symDifference(
$polygon
);
# => is 'GEOMETRYCOLLECTION EMPTY'
$polygon
->intersection(
$point
);
# => is 'GEOMETRYCOLLECTION EMPTY'
# relations
$polygon
->within(
$point
);
# => ''
$polygon
->contains(
$point
);
# => ''
$polygon
->covers(
$point
);
# => ''
$polygon
->touches(
$point
);
# => ''
$polygon
->intersects(
$point
);
# => ''
$polygon
->isValid;
# => success
# Well-Known Text (WKT) I/O
use
Geo::Geos::WKTWriter;
use
Geo::Geos::WKTReader;
my
$string0
= Geo::Geos::WKTWriter->new->
write
(
$point
);
# => 'POINT (5.0000000000000000 4.0000000000000000)'
my
$g0
= Geo::Geos::WKTReader::
read
(
$string0
);
# => isa 'Geo::Geos::Geometry'
# Well-Known Binary (WKB) I/O
use
Geo::Geos::WKBReader;
use
Geo::Geos::WKBWriter;
my
$writer
= Geo::Geos::WKBWriter->new;
my
$string1
=
$writer
->
write
(
$point
);
my
$string2
=
$writer
->writeHEX(
$point
);
my
$g1
= Geo::Geos::WKBReader::
read
(
$string1
);
# => isa 'Geo::Geos::Geometry'
my
$g2
= Geo::Geos::WKBReader::readHEX(
$string2
);
# => isa 'Geo::Geos::Geometry'
DESCRIPTION
This is Perl interface for GEOS C++ library. It is build around C++ API, which is a bit more convenient, but without stability guarantees.
Capabilities include:
- Geometries: Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, GeometryCollection
- Predicates: Intersects, Touches, Disjoint, Crosses, Within, Contains, Overlaps, Equals, Covers
- Operations: Union, Distance, Intersection, Symmetric Difference, Convex Hull, Envelope, Buffer, Simplify, Polygon Assembly, Valid, Area, Length
- Prepared geometries (pre-spatially indexed)
- STR spatial index
- OGC Well Known Text (WKT) and Well Known Binary (WKB) encoders and decoders.
The GEOS C++ is used by PostGIS project.
EXCLUDED C++ CLASSES
It is not possible or there is no need to have perl interface for all C++ classes of the library, partly because it is not possible to have perlish interface (safe, without memory leaks, without explicit dispose
calls), partly because classes are not documented and/or buggy and some classes are seems internal to the library and no need to export them.
Here is a list of C++ classes, without Perl interface:
geos::geom::CoordinateFilter
geos::geom::CoordinateLessThen
geos::geom::CoordinateSequence (use Array of Coordinate*)
geos::geom::CoordinateSequenceFactory
geos::geom::CoordinateSequenceFilter
geos::geom::CoordinateArraySequence (use Array of Coordinate*)
geos::geom::GeometryFilter
geos::geom::GeometryComponentFilter
geos::geom::Location
geos::algorithm::RayCrossingCounter (duplicates methods in CGAlgorithms)
geos::noding::SegmentNodeList
geos::noding::snapround::HotPixel
geos::noding::MCIndexNoder
geos::noding::MCIndexSegmentSetMutualIntersector
geos::noding::SegmentSetMutualIntersector
geos::index::chain::MonotoneChainSelectAction
geos::index::bintree::* (Buggy interface)
geos::index::quadtree::* (See high-level wrapper Geo::Geos::Index::Quadtree)
geos::index::strtree::* (See high-level wrapper Geo::Geos::Index::STRtree)
geos::index::ItemVisitor (use CODEREF instead)
geos::index::sweepline::SweepLineIndex
geos::index::intervalrtree::SortedPackedIntervalRTree
geos::planargraph::* (Safe interface is not possible)
geos::geomgraph::* (Safe interface is not possible)
geos::operation::* (All main operations are wrapped as methods of Geo::Geos::Operation)
AUTHOR
Ivan Baidakou <i.baydakov@crazypanda.ru>, Crazy Panda, CP Decision LTD
SEE ALSO
Geo::Geos::Algorithm::HCoordinate
Geo::Geos::Algorithm::LineIntersector
Geo::Geos::Algorithm::MinimumDiameter
Geo::Geos::Index::MonotoneChain
Geo::Geos::Index::MonotoneChainOverlapAction
Geo::Geos::Index::SpatialIndex
Geo::Geos::Noding::BasicSegmentString
Geo::Geos::Noding::IntersectionAdder
Geo::Geos::Noding::IntersectionFinderAdder
Geo::Geos::Noding::IteratedNoder
Geo::Geos::Noding::NodedSegmentString
Geo::Geos::Noding::ScaledNoder
Geo::Geos::Noding::SegmentIntersectionDetector
Geo::Geos::Noding::SegmentIntersector
Geo::Geos::Noding::SegmentNode
Geo::Geos::Noding::SegmentString
Geo::Geos::Noding::SimpleNoder
Geo::Geos::Noding::SimpleSnapRounder
Geo::Geos::Noding::SingleInteriorIntersectionFinder
Geo::Geos::Noding::SinglePassNoder
Geo::Geos::Precision::GeometryPrecisionReducer
Geo::Geos::Precision::SimpleGeometryPrecisionReducer
Geo::Geos::Prep::GeometryFactory
Geo::Geos::Triangulate::DelaunayTriangulationBuilder
Geo::Geos::Triangulate::VoronoiDiagramBuilder
LICENSE
You may distribute this code under the same terms as Perl itself.