poly

package
v0.0.0-...-0108d89 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2021 License: MIT, MIT Imports: 2 Imported by: 0

README

Poly

Build Status GoDoc

Polygon detection methods for Go.

Contact

Josh Baker @tidwall

License

Poly source code is available under the MIT License.

Documentation

Overview

Package poly provides polygon detection methods.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Point

type Point struct {
	X, Y, Z float64
}

Point is simple 2D point

func (Point) Inside

func (p Point) Inside(exterior Polygon, holes []Polygon) bool

Inside returns true if point is inside of exterior and not in a hole. The validity of the exterior and holes must be done elsewhere and are assumed valid.

A valid exterior is a near-linear ring.
A valid hole is one that is full contained inside the exterior.
A valid hole may not share the same segment line as the exterior.

func (Point) InsideRect

func (p Point) InsideRect(rect Rect) bool

InsideRect detects point is inside of another rect

func (Point) Intersects

func (p Point) Intersects(exterior Polygon, holes []Polygon) bool

Intersects detects if a point intersects another polygon

func (Point) IntersectsLineString

func (p Point) IntersectsLineString(exterior Polygon) bool

IntersectsLineString detect if a point intersects a linestring

type Polygon

type Polygon []Point

Polygon is series of points that make up a polygon

func (Polygon) Inside

func (shape Polygon) Inside(exterior Polygon, holes []Polygon) bool

Inside returns true if shape is inside of exterior and not in a hole.

func (Polygon) InsideRect

func (p Polygon) InsideRect(rect Rect) bool

InsideRect detects polygon is inside of another rect

func (Polygon) Intersects

func (shape Polygon) Intersects(exterior Polygon, holes []Polygon) bool

Intersects detects if a polygon intersects another polygon

func (Polygon) IntersectsRect

func (p Polygon) IntersectsRect(rect Rect) bool

IntersectsRect detects polygon is inside of another rect

func (Polygon) LineStringIntersects

func (shape Polygon) LineStringIntersects(exterior Polygon, holes []Polygon) bool

LineStringIntersects detects if a polygon intersects a linestring assume shape is a linestring

func (Polygon) LineStringIntersectsLineString

func (shape Polygon) LineStringIntersectsLineString(exterior Polygon) bool

LineStringIntersectsLineString detects if a linestring intersects a linestring assume shape and exterior are actually linestrings

func (Polygon) Rect

func (p Polygon) Rect() Rect

Rect returns the bounding box rectangle for the polygon

func (Polygon) String

func (p Polygon) String() string

String returns a string representation of the polygon.

type Rect

type Rect struct {
	Min, Max Point
}

Rect is rectangle

func (Rect) Inside

func (r Rect) Inside(exterior Polygon, holes []Polygon) bool

Inside detects if a rect intersects another polygon

func (Rect) InsideRect

func (r Rect) InsideRect(rect Rect) bool

InsideRect detects rect is inside of another rect

func (Rect) Intersects

func (r Rect) Intersects(exterior Polygon, holes []Polygon) bool

Intersects detects if a rect intersects another polygon

func (Rect) IntersectsRect

func (r Rect) IntersectsRect(rect Rect) bool

IntersectsRect detects if two bboxes intersect.

func (Rect) Polygon

func (r Rect) Polygon() Polygon

Polygon returns a polygon for the rect

Jump to

Keyboard shortcuts

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