-
Notifications
You must be signed in to change notification settings - Fork 16
/
geom.go
60 lines (48 loc) · 1.59 KB
/
geom.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
Package geom holds geometry objects and functions to operate on them.
They can be encoded and decoded by other packages in this repository.*/
package geom
import "github.com/ctessum/geom/proj"
// Geom is an interface for generic geometry types.
type Geom interface {
Bounds() *Bounds
Similar(Geom, float64) bool
Transform(proj.Transformer) (Geom, error)
// Len returns the total number of points in the geometry
Len() int
// Points returns an iterator that returns the points in the
// geometry.
Points() func() Point
}
// Linear is an interface for types that are linear in nature.
type Linear interface {
Geom
Length() float64
// Clip returns the part of the line that falls within the given polygon.
Clip(Polygonal) Linear
Simplify(tolerance float64) Geom
// Within determines whether this geometry is within the Polygonal geometry.
// Points that lie on the edge of the polygon are considered within.
Within(Polygonal) WithinStatus
// Distance calculates the shortest distance to the given Point.
Distance(Point) float64
}
// Polygonal is an interface for types that are polygonal in nature.
type Polygonal interface {
Geom
Polygons() []Polygon
Intersection(Polygonal) Polygonal
Union(Polygonal) Polygonal
XOr(Polygonal) Polygonal
Difference(Polygonal) Polygonal
Area() float64
Simplify(tolerance float64) Geom
Centroid() Point
}
// PointLike is an interface for types that are pointlike in nature.
type PointLike interface {
Geom
//On(l Linear, tolerance float64) bool
// Within determines whether this geometry is within the Polygonal geometry.
Within(Polygonal) WithinStatus
}