antimeridian

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

README

antimeridian

PkgGoDev Go Report Card

Package antimeridian fixes shapes that cross the antimeridian.

Example Polygon

Lines and Polygons that cross the antimeridian are problematic for many web mapping packages and PostGIS. The official GeoJSON spec recommends features that cross the antimeridian, "SHOULD be represented by cutting it in two such that neither part's representation crosses the antimeridian."

This package will cut polygons and multi-polygons that cross the anti-meridian into multiple polygons that do not cross the anti-meridian. It will also force polygons to use the right-hand rule for polygon winding. Exterior rings must be wound in counter-clockwise order and interior rings are wound clockwise.

Usage

go get github.com/go-geospatial/antimeridian

Then:

fixedGeom := antimeridian.Cut(geomCrossingAntiMeridian)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedType   = errors.New("unsupported geometry type")
	ErrUnsupportedLayout = errors.New("unsupported geometry layout")
)

Functions

func Contains

func Contains(polygon *geom.Polygon, containedBy *geom.Polygon) bool

Contains checks if polygon is contained by the polygon containedBy

func ContainsPoint

func ContainsPoint(pt geom.Coord, ring *geom.LinearRing) bool

ContainsPoint checks if the point pt is within the linear ring

func Cut

func Cut(obj geom.T, fixWinding ...bool) (geom.T, error)

Cut divides a geometry at the antimeridian and the poles. A multi-geometry is returned with the cut portions of the original geometry.

By default Cut attempts to fix improperly wound geometries Howevever, there are instances where the polygon may be correctly but antimeridian cannot determine this to be so; for example, when the polygon extends over both the north and south pole. For these instances, pass fixWinding = false

Types

This section is empty.

Jump to

Keyboard shortcuts

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