NAME

OSM::Tree::Polygon -- helperclass for OSM::Tree

SYNOPSIS

 #!/usr/bin/perl
 use strict;
 use warnings;
 use OSM::Tree;
 use OSM::Tree::Poligon;
 use Data::Dumper;

 my $osm=OSM::Tree->new('map.osm');

 my $poly1=OSM::Tree::Polygon->new( ($osm->way_list())[0] );
 print Dumper($poly1->center());

 my $poly2=($osm->way_list())[1]->polygon();
 print Dumper($poly2->center());

 my $poly3=OSM::Tree::Polygon->new(($osm->node_list())[0..5]);
 print Dumper($poly3->center());

DESCRIPTION

Class to handle ways and Nodelists as Polygons

Base Class is Math::Polygon Look there for all other Methods

All listed methods understands OSM::Tree Objects.

AUTHOR

ToPeG

METHODS

new(POINTS)

create new OSM::Tree::Polygon object;

The points can be Arrayrefs with two values or an OSM::Tree::Node or OSM::Tree::Way

equal((OTHER|ARRAY, [TOLERANCE])|POINTS)

Compare two polygons, on the level of points. When the polygons are the same but rotated, this will return false. See same().

Function Math::Polygon::Calc::polygon_equal().

The points can be Arrayrefs with two values or an OSM::Tree::Node or OSM::Tree::Way

same((OTHER|ARRAY, [TOLERANCE])|POINTS)

Compare two polygons, where the polygons may be rotated wrt each other. This is (much) slower than equal(), but some algorithms will cause un unpredictable rotation in the result.

Function Math::Polygon::Calc::polygon_same().

The points can be Arrayrefs with two values or an OSM::Tree::Node or OSM::Tree::Way

contains(POINT)

Returns a truth value indicating whether the point is inside the polygon. On the edge is inside.

The point can be an Arrayref with two values or an OSM::Tree::Node or OSM::Tree::Way

contains_all(POINTS)

Returns a truth value indicating whether all points are inside the polygon. On the edge is inside.

The points can be an Arrayref with two values or an OSM::Tree::Node or OSM::Tree::Way

contains_one(POINTS)

Returns a truth value indicating whether one of all points is inside the polygon. On the edge is inside.

The points can be an Arrayref with two values or an OSM::Tree::Node or OSM::Tree::Way

contains_list(POINTS)

Returns a list of points, who are inside the Polygon. On the edge is inside.

The points can be an Arrayref with two values or an OSM::Tree::Node or OSM::Tree::Way

force_close()

close open Polynome

crossing((OTHER|ARRAY, [TOLERANCE])|POINTS)

Returns a list of points. The ponits reperents the location where the two Lines crossing

The points can be an Arrayref with two values or an OSM::Tree::Node or OSM::Tree::Way

switch_polygon_contains_function(<'count'|'angle'|'origin'>)

Class Method. Sets the Value for all OSM::Tree::Polygon objects!

Set the algorithmus for detecting when an point is inside a polygon.

Default is the function Function Math::Polygon::Calc::polygon_contains_point.

'origin' set Math::Polygon::Calc::polygon_contains_point

'count' a reimplemetation of polygon_contains_point

'angle' is an implementation is to compute the sum of the angles made between the test point and each pair of points making up the polygon. This algorithmus is used in many CAD-Applications.

See also

OSM::Tree::BASE

OSM::Tree::Node

OSM::Tree::Way

OSM::Tree::Relation

OSM::Tree::TagList

OSM::Tree