---
name: "Boost::Geometry::Utils"
section: "3pm"
platform: "linux"
package: "libboost-geometry-utils-perl"
version: "0.15-3+b4"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Boost::Geometry::Utils"
---

# Boost::Geometry::Utils(3pm)

Bindings for the Boost Geometry library

## NAME

Boost::Geometry::Utils - Bindings for the Boost Geometry library

## VERSION

version 0.07

## SYNOPSIS

```
    use Boost::Geometry::Utils qw(polygon linestring polygon_linestring_intersection);

    my $square = [  # ccw
        [10, 10],
        [20, 10],
        [20, 20],
        [10, 20],
    ];
    my $hole_in_square = [  # cw
        [14, 14],
        [14, 16],
        [16, 16],
        [16, 14],
    ];
    my $polygon = polygon($square, $hole_in_square);
    my $linestring = linestring([ [5, 15], [30, 15] ]);

    my $intersection = polygon_linestring_intersection($polygon, $linestring);

    # $intersection is:
    # [
    #     [ [10, 15], [14, 15] ],
    #     [ [16, 15], [20, 15] ],
    # ]
```

## ABSTRACT

This module provides bindings to perform some geometric operations using the Boost Geometry library. It does not aim at providing full bindings for such library, and that's why I left the *Boost::Geometry* namespace free. I'm unsure about the optimal architectural for providing full  bindings, but I'm interested in such a project -- so, if you have ideas please get in touch with me.

**Warning:** the API could change in the future.

## METHODS

### polygon\_linestring\_intersection

Performs an intersection between the supplied polygon and linestring, and returns an arrayref of linestrings (represented as arrayrefs of points). Note that such an intersection is also called *clipping*.

### polygon\_multi\_linestring\_intersection

Same as *polygon\_linestring\_intersection* but it accepts a multilinestring object to perform multiple clippings in a single batch.

### multi\_polygon\_multi\_linestring\_intersection

Same as *polygon\_multi\_linestring\_intersection* but it accepts a multipolygon object to perform multiple clippings in a single batch.

### multi\_linestring\_multi\_polygon\_difference

Performs a difference between the supplied multilinestring and the supplied multipolygon. It returns a multilinestring object.

### polygon\_to\_wkt

Converts one or more arrayref(s) of points to a WKT representation of a polygon (with holes).

### linestring\_to\_wkt

Converts an arrayref of points to a WKT representation of a multilinestring.

### wkt\_to\_multilinestring

Parses a MULTILINESTRING back to a Perl data structure.

### linestring\_simplify

Accepts an arrayref of points representing a linestring and a numeric tolerance  and returns an arrayref of points representing the simplified linestring.

### multi\_linestring\_simplify

Accepts an arrayref of arrayrefs of points representing a multilinestring and a  numeric tolerance and returns an arrayref of arrayrefs of points representing  the simplified linestrings.

### point\_covered\_by\_polygon

Accepts a point and an arrayref of points representing a polygon and returns true  or false according to the 'cover\_by' strategy.

### point\_covered\_by\_multi\_polygon

Same as above but accepts a multipolygon arrayref.

### point\_within\_polygon

Accepts a point and an arrayref of points representing a polygon and returns true  or false according to the 'within' strategy.

### point\_within\_multi\_polygon

Same as above but accepts a multipolygon arrayref.

### linestring\_length

Returns length of a linestring.

### polygon\_centroid

Returns the centroid point of a given polygon.

### linestring\_centroid

Returns the centroid point of a given linestring.

### multi\_linestring\_centroid

Returns the centroid point of a given multi\_linestring.

### correct\_polygon

Corrects the orientation(s) of the given polygon.

### correct\_multi\_polygon

Corrects the orientation(s) of the given multi\_polygon.

### polygon\_area

Returns the area of the given polygon.

## ACKNOWLEDGEMENTS

Thanks to mauke and mst (Matt S. Trout (cpan:MSTROUT) \<mst@shadowcat.co.uk\>) for their valuable help in getting this to compile under Windows (MinGW) too. Thanks to Mark Hindness for his work on data types conversion.

## AUTHOR

Alessandro Ranellucci \<aar@cpan.org\>

## COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Alessandro Ranellucci.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
