op

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2022 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package op provides implementation of algorithms for geometry operations. For further details, consult the description of Polygon.Construct method.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Area

func Area(g geom.Geom) float64

Function Area returns the area of a polygon, or the combined area of a MultiPolygon, assuming that none of the polygons in the MultiPolygon overlap and that nested polygons have alternating winding directions.

func Centroid

func Centroid(g geom.Geom) (geom.Point, error)

Calculate the centroid of a polygon, from wikipedia: http://en.wikipedia.org/wiki/Centroid#Centroid_of_polygon. The polygon can have holes, but each ring must be closed (i.e., p[0] == p[n-1], where the ring has n points) and must not be self-intersecting. The algorithm will not check to make sure the holes are actually inside the outer rings.

func Clone

func Clone(p geom.Polygon) geom.Polygon

Clone returns a duplicate of a polygon.

func Distance

func Distance(a, b geom.Geom) float64

Distance returns the distance between the closest parts of two geometries. Currently, only points are supported.

func FixOrientation

func FixOrientation(g geom.Geom) error

Change the winding direction of the outer and inner rings so the outer ring is counter-clockwise and nesting rings alternate directions.

func Length

func Length(g geom.Geom) float64

Function Length returns the length of a LineString, or the combined length of a MultiLineString.

func PointEquals

func PointEquals(p1, p2 geom.Point) bool

Equals returns true if both p1 and p2 describe the same point within a tolerance limit.

func PointOnSurface

func PointOnSurface(g geom.Geom) (geom.Point, error)

Function PointOnSurface returns a point guaranteed to lie on the surface of the shape. It will usually be the centroid, except for when the centroid is not with the shape.

func Within

func Within(inner, outer geom.Geom) (bool, error)

Within checks whether inner is within outer.

Types

type InfiniteLoopError

type InfiniteLoopError struct {
	// contains filtered or unexported fields
}

func (InfiniteLoopError) Error

func (e InfiniteLoopError) Error() string

type Op

type Op int

Op describes an operation which can be performed on two polygons.

const (
	UNION Op = iota
	INTERSECTION
	DIFFERENCE
	XOR
)

type UnsupportedGeometryError

type UnsupportedGeometryError struct {
	G geom.Geom
}

func (UnsupportedGeometryError) Error

func (e UnsupportedGeometryError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL