smartclip

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: MIT Imports: 4 Imported by: 1

README

orb/clip/smartclip Godoc Reference

This package extends the clip functionality to handle partial 2d geometries. The input polygon rings need to only intersect the bound. The algorithm will use that, plus the orientation, to wrap/close the rings around the edge of the bound.

The use case is OSM multipolyon relations where a ring (inner or outer) contains multiple ways but only one is in the current viewport. With only the ways intersecting the viewport and their orientation the correct shape can be drawn.

Example

bound := orb.Bound{Min: orb.Point{1, 1}, Max: orb.Point{10, 10}}

// a partial ring cutting the bound down the middle.
ring := orb.Ring{{0, 0}, {11, 11}}
clipped := smartclip.Ring(bound, ring, orb.CCW)

// clipped is a multipolyon with one ring that wraps counter-clockwise
// around the top triangle of the box
// [[[[1 1] [10 10] [5.5 10] [1 10] [1 5.5] [1 1]]]]

Documentation

Overview

Package smartclip performs a more advanced clipping algorithm so it can deal with correctly oriented open rings and polygon.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Geometry

func Geometry(box orb.Bound, g orb.Geometry, o orb.Orientation) orb.Geometry

Geometry will do a smart more involved clipping and wrapping of the geometry. It will return simple OGC geometries. Rings that are NOT closed AND have an endpoint in the bound will be implicitly closed.

func MultiPolygon

func MultiPolygon(box orb.Bound, mp orb.MultiPolygon, o orb.Orientation) orb.MultiPolygon

MultiPolygon will smart clip a multipolygon to the bound. Rings that are NOT closed AND have an endpoint in the bound will be implicitly closed.

func Polygon

func Polygon(box orb.Bound, p orb.Polygon, o orb.Orientation) orb.MultiPolygon

Polygon will smart clip a polygon to the bound. Rings that are NOT closed AND have an endpoint in the bound will be implicitly closed.

func Ring

func Ring(box orb.Bound, r orb.Ring, o orb.Orientation) orb.MultiPolygon

Ring will smart clip a ring to the boundary. This may result multiple rings so a multipolygon is possible. Rings that are NOT closed AND have an endpoint in the bound will be implicitly closed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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