buffer

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2022 License: LGPL-2.1 Imports: 10 Imported by: 0

Documentation

Overview

Package buffer define geomtry matrix conversion.

Index

Constants

View Source
const (
	Deleted     = 1
	NumPtsCheck = 10
	SafeEpsilon = 1e-15
)

const Defined constant variable

Variables

This section is empty.

Functions

func Buffer

func Buffer(geom matrix.Steric, distance float64, quadrantSegments int) matrix.Steric

Buffer Computes the set of raw offset curves for the buffer. Each offset curve has an attached indicating its left and right location.

func Centroid

func Centroid(geom matrix.Steric) matrix.Matrix

Centroid Computes the centroid point of a geometry.

func ConvexHull

func ConvexHull(geom matrix.Steric) matrix.Steric

ConvexHull Returns a geometry that represents the convex hull of the input geometry. The returned geometry contains the minimal number of points needed to represent the convex hull. In particular, no more than two consecutive points will be collinear.

func InteriorPoint

func InteriorPoint(geom matrix.Steric) (interiorPt matrix.Matrix)

InteriorPoint Computes a location of an interior point in a Geometry.

func OrientationIndex

func OrientationIndex(p1, p2, q matrix.Matrix) int

OrientationIndex Returns the index of the direction of the point q relative to a vector specified by p1-p2.

func ScanLineY

func ScanLineY(poly matrix.PolygonMatrix) float64

ScanLineY Finds a safe scan line Y ordinate by projecting the polygon segments

Types

type CentroidComputer

type CentroidComputer struct {
	AreaBasePt    matrix.Matrix // the point all triangles are based at
	TriangleCent3 matrix.Matrix // temporary variable to hold centroid of triangle
	Areasum2      float64       // Partial area sum
	Cg3           matrix.Matrix // partial centroid sum

	// data for linear centroid computation, if needed
	LineCentSum matrix.Matrix
	TotalLength float64

	PtCount   int
	PtCentSum matrix.Matrix
}

CentroidComputer Computes the centroid of a matrix.Steric of any dimension. For collections the centroid is computed for the collection of non-empty elements of highest dimension. The centroid of an empty matrix.Steric is nil.

func (*CentroidComputer) Add

func (c *CentroidComputer) Add(pt matrix.Steric)

Add Adds a Steric to the centroid accumulator.

func (*CentroidComputer) AddLineSegments

func (c *CentroidComputer) AddLineSegments(lines matrix.LineMatrix)

AddLineSegments Adds the line segments to the linear centroid accumulators.

func (*CentroidComputer) AddPoint

func (c *CentroidComputer) AddPoint(pt matrix.Matrix)

AddPoint Adds a point to the point centroid accumulator.

func (*CentroidComputer) AddPolygon

func (c *CentroidComputer) AddPolygon(poly matrix.PolygonMatrix)

AddPolygon Adds the polygon to the polygon centroid accumulators.

func (*CentroidComputer) GetCentroid

func (c *CentroidComputer) GetCentroid() matrix.Matrix

GetCentroid Gets the computed centroid. returns he computed centroid, or nil if the input is empty

type ComputerBuffer

type ComputerBuffer struct {
	*CurveBuilder
	// contains filtered or unexported fields
}

ComputerBuffer describes a geographic Element buffer

func (*ComputerBuffer) Add

func (eb *ComputerBuffer) Add(geom matrix.Steric)

Add Add a geometry to the graph.

func (*ComputerBuffer) AddRingBothSides added in v1.0.1

func (eb *ComputerBuffer) AddRingBothSides(ring matrix.LineMatrix, distance float64)

AddRingBothSides ...

type ConvexHullComputer added in v1.0.1

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

ConvexHullComputer Computes the convex hull of a Geometry. The convex hull is the smallest convex Geometry that contains all the

points in the input Geometry.

func ConvexHullWithGeom

func ConvexHullWithGeom(geom matrix.Steric) *ConvexHullComputer

ConvexHullWithGeom Create a new convex hull construction for the input geometry.

func (*ConvexHullComputer) ConvexHull added in v1.0.1

func (c *ConvexHullComputer) ConvexHull() matrix.Steric

ConvexHull Returns a geometry that represents the convex hull of the input geometry. The returned geometry contains the minimal number of points needed to represent the convex hull. In particular, no more than two consecutive points will be collinear.

type Curve

type Curve struct {
	Line matrix.LineMatrix
	// contains filtered or unexported fields
}

Curve A dynamic list of the vertices in a constructed offset curve. Automatically removes adjacent vertices which are closer than a given tolerance.

func CurveWithDistance

func CurveWithDistance(distance float64) *Curve

CurveWithDistance Creates a default curve.

func CurveWithParameters

func CurveWithParameters(parameters *CurveParameters, distance float64) *Curve

CurveWithParameters Creates a default curve.

func (*Curve) Add

func (c *Curve) Add(pts ...matrix.Matrix)

Add add a Pts.

func (*Curve) AddLine

func (c *Curve) AddLine(line matrix.LineMatrix)

AddLine add a line.

func (*Curve) AddLineEndCap

func (c *Curve) AddLineEndCap(p0, p1 matrix.Matrix, distance float64)

AddLineEndCap Add an end cap around point p1, terminating a line segment coming from p0

func (*Curve) AddPt

func (c *Curve) AddPt(p matrix.Matrix)

AddPt add point to OffsetSegmentString.

func (*Curve) CloseRing

func (c *Curve) CloseRing()

CloseRing close ring.

func (*Curve) CreateCircle

func (c *Curve) CreateCircle(p matrix.Matrix, distance float64) matrix.LineMatrix

CreateCircle Creates a CW circle around a point

func (*Curve) CreateSquare

func (c *Curve) CreateSquare(p matrix.Matrix, distance float64) matrix.LineMatrix

CreateSquare Creates a CW square around a point

func (*Curve) SetParameters

func (c *Curve) SetParameters(parameters *CurveParameters)

SetParameters Set a parameters of curve.

type CurveBuilder

type CurveBuilder struct {
	*Curve
	Curves []Curve
	// contains filtered or unexported fields
}

CurveBuilder Computes the raw offset curve for a single Geometry component (ring, line or point).

func (*CurveBuilder) AddCurve

func (c *CurveBuilder) AddCurve(pts matrix.LineMatrix, leftLoc, rightLoc int)

AddCurve Creates a SegmentString for a coordinate list which is a raw offset curve, and adds it to the list of buffer curves. The SegmentString is tagged with a Label giving the topology of the curve. The curve may be oriented in either direction. If the curve is oriented CW, the locations will be: <br>Left: Location.EXTERIOR <br>Right: Location.INTERIOR

func (*CurveBuilder) IsRingCurveInverted added in v1.0.1

func (c *CurveBuilder) IsRingCurveInverted(pts matrix.LineMatrix, distance float64) bool

IsRingCurveInverted Tests whether the offset curve for a ring is fully inverted. An inverted ("inside-out") curve occurs in some specific situations involving a buffer distance which should result in a fully-eroded (empty) buffer. It can happen that the sides of a small, convex polygon produce offset segments which all cross one another to form a curve with inverted orientation. This happens at buffer distances slightly greater than the distance at which the buffer should disappear. The inverted curve will produce an incorrect non-empty buffer (for a shell) or an incorrect hole (for a hole). It must be discarded from the set of offset curves used in the buffer. Heuristics are used to reduce the number of cases which area checked, for efficiency and correctness.

func (*CurveBuilder) LineCurve

func (c *CurveBuilder) LineCurve(pts matrix.LineMatrix, distance float64,
	leftLoc, rightLoc int) matrix.LineMatrix

LineCurve This method handles single points as well as LineStrings. LineStrings are assumed <b>not</b> to be closed (the function will not fail for closed lines, but will generate superfluous line caps).

func (*CurveBuilder) RingCurve

func (c *CurveBuilder) RingCurve(pts matrix.LineMatrix, distance float64, side int, leftLoc, rightLoc int) matrix.LineMatrix

RingCurve This method handles the degenerate cases of single points and lines, as well as valid rings.

type CurveParameters

type CurveParameters struct {
	QuadrantSegments, EndCapStyle, JoinStyle int
	MitreLimit, SimplifyFactor               float64
	IsSingleSided                            bool
}

CurveParameters A value containing the parameters which specify how a buffer should be constructed..

func DefaultCurveParameters

func DefaultCurveParameters() *CurveParameters

DefaultCurveParameters Creates a default set of parameters.

func (*CurveParameters) IsEmpty

func (c *CurveParameters) IsEmpty() bool

IsEmpty returns test Curve Parameters.

type Interior

type Interior interface {
	InteriorPoint() matrix.Matrix
	Add(geom matrix.Steric)
}

Interior interface Computes a location of an interior point in a Geometry.

type InteriorPointArea

type InteriorPointArea struct {
	InteriorPointPoint
	// contains filtered or unexported fields
}

InteriorPointArea Computes a point in the interior of an areal geometry. The point will lie in the geometry interior in all except certain pathological cases.

func (*InteriorPointArea) Add

func (ip *InteriorPointArea) Add(poly matrix.Steric)

Add Processes a geometry to determine the best interior point for all component polygons.

func (*InteriorPointArea) ScanLineY

func (ip *InteriorPointArea) ScanLineY(polygon matrix.PolygonMatrix) float64

ScanLineY ...

func (*InteriorPointArea) Width

func (ip *InteriorPointArea) Width() float64

Width Gets the width of the scanline section containing the interior point. Used to determine the best point to use.

type InteriorPointLine

type InteriorPointLine struct {
	InteriorPointPoint
}

InteriorPointLine Computes a point in the interior of an linear geometry. Find an interior vertex which is closest to the centroid of the linestring. If there is no interior vertex, find the endpoint which is

closest to the centroid.

func (*InteriorPointLine) Add

func (ip *InteriorPointLine) Add(line matrix.Steric)

Add Tests the interior vertices (if any) defined by a linear Geometry for the best inside point.

type InteriorPointPoint

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

InteriorPointPoint Computes a point in the interior of an point geometry. Find a point which is closest to the centroid of the geometry.

func (*InteriorPointPoint) Add

func (ip *InteriorPointPoint) Add(point matrix.Steric)

Add Tests the point(s) defined by a Geometry for the best inside point. If a Geometry is not of dimension 0 it is not tested.

func (*InteriorPointPoint) InteriorPoint

func (ip *InteriorPointPoint) InteriorPoint() matrix.Matrix

InteriorPoint returns InteriorPoint.

type LineSimplifier

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

LineSimplifier Simplifies a buffer input line to remove concavities with shallow depth.

func (*LineSimplifier) IsShallowConcavity added in v1.0.1

func (l *LineSimplifier) IsShallowConcavity(p0, p1, p2 matrix.Matrix, distanceTol float64) bool

IsShallowConcavity ...

func (*LineSimplifier) Simplify

func (l *LineSimplifier) Simplify(distanceTol float64) matrix.LineMatrix

Simplify the input coordinate list. If the distance tolerance is positive, concavities on the LEFT side of the line are simplified. If the supplied distance tolerance is negative, concavities on the RIGHT side of the line are simplified.

type RadialComparator

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

RadialComparator Compares Matrixes for their angle and distance relative to an origin.

func (*RadialComparator) Len

func (r *RadialComparator) Len() int

Len ...

func (*RadialComparator) Less

func (r *RadialComparator) Less(i, j int) bool

Less ...

func (RadialComparator) Swap

func (r RadialComparator) Swap(i, j int)

Swap ...

type ScanLineYOrdinateFinder

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

ScanLineYOrdinateFinder Finds a safe scan line Y ordinate by projecting the polygon segments

func (*ScanLineYOrdinateFinder) ScanLineY

func (s *ScanLineYOrdinateFinder) ScanLineY() float64

ScanLineY Finds a safe scan line Y ordinate by projecting the polygon segments

Directories

Path Synopsis
Package simplify define Douglas Peucker and Topology Preserving simplify.
Package simplify define Douglas Peucker and Topology Preserving simplify.

Jump to

Keyboard shortcuts

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