-
Notifications
You must be signed in to change notification settings - Fork 9
/
geos.go
112 lines (92 loc) · 3.24 KB
/
geos.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// Package geos provides an interface to GEOS. See https://trac.osgeo.org/geos/.
package geos
// #cgo pkg-config: geos
// #include "go-geos.h"
import "C"
// Version.
const (
VersionMajor = C.GEOS_VERSION_MAJOR
VersionMinor = C.GEOS_VERSION_MINOR
VersionPatch = C.GEOS_VERSION_PATCH
)
// A TypeID is a geometry type id.
type TypeID int
// Geometry type ids.
const (
TypeIDPoint TypeID = C.GEOS_POINT
TypeIDLineString TypeID = C.GEOS_LINESTRING
TypeIDLinearRing TypeID = C.GEOS_LINEARRING
TypeIDPolygon TypeID = C.GEOS_POLYGON
TypeIDMultiPoint TypeID = C.GEOS_MULTIPOINT
TypeIDMultiLineString TypeID = C.GEOS_MULTILINESTRING
TypeIDMultiPolygon TypeID = C.GEOS_MULTIPOLYGON
TypeIDGeometryCollection TypeID = C.GEOS_GEOMETRYCOLLECTION
)
// A BoundaryNodeRule is a boundary node rule.
type RelateBoundaryNodeRule int
// Boundary node rules.
const (
RelateBoundaryNodeRuleMod2 RelateBoundaryNodeRule = C.GEOSRELATE_BNR_MOD2
RelateBoundaryNodeRuleOGC RelateBoundaryNodeRule = C.GEOSRELATE_BNR_OGC
RelateBoundaryNodeRuleEndpoint RelateBoundaryNodeRule = C.GEOSRELATE_BNR_ENDPOINT
RelateBoundaryNodeRuleMultivalentEndpoint RelateBoundaryNodeRule = C.GEOSRELATE_BNR_MULTIVALENT_ENDPOINT
RelateBoundaryNodeRuleMonovalentEndpoint RelateBoundaryNodeRule = C.GEOSRELATE_BNR_MONOVALENT_ENDPOINT
)
type BufCapStyle int
// Buffer cap styles.
const (
BufCapStyleRound BufCapStyle = C.GEOSBUF_CAP_ROUND
BufCapStyleFlat BufCapStyle = C.GEOSBUF_CAP_FLAT
BufCapStyleSquare BufCapStyle = C.GEOSBUF_CAP_SQUARE
)
type BufJoinStyle int
// Buffer join styles.
const (
BufJoinStyleRound BufJoinStyle = C.GEOSBUF_JOIN_ROUND
BufJoinStyleMitre BufJoinStyle = C.GEOSBUF_JOIN_MITRE
BufJoinStyleBevel BufJoinStyle = C.GEOSBUF_JOIN_BEVEL
)
// An Error is an error returned by GEOS.
type Error string
func (e Error) Error() string {
return string(e)
}
var (
errContextMismatch = Error("context mismatch")
errDimensionOutOfRange = Error("dimension out of range")
errDuplicateValue = Error("duplicate value")
errIndexOutOfRange = Error("index out of range")
)
type PrecisionRule int
// Precision rules.
const (
PrecisionRuleNone PrecisionRule = 0
PrecisionRuleValidOutput PrecisionRule = C.GEOS_PREC_VALID_OUTPUT
PrecisionRuleNoTopo PrecisionRule = C.GEOS_PREC_NO_TOPO
PrecisionRulePointwise PrecisionRule = C.GEOS_PREC_NO_TOPO
PrecisionRuleKeepCollapsed PrecisionRule = C.GEOS_PREC_KEEP_COLLAPSED
)
type MakeValidMethod int
// MakeValidMethods.
const (
MakeValidLinework MakeValidMethod = C.GEOS_MAKE_VALID_LINEWORK
MakeValidStructure MakeValidMethod = C.GEOS_MAKE_VALID_STRUCTURE
)
type MakeValidCollapsed int
// MakeValidMethods.
const (
MakeValidDiscardCollapsed MakeValidCollapsed = 0
MakeValidKeepCollapsed MakeValidCollapsed = 1
)
// VersionCompare returns a negative number if the GEOS version is less than the
// given major.minor.patch version, zero if it is equal, or a positive number
// otherwise.
func VersionCompare(major, minor, patch int) int {
if majorDelta := VersionMajor - major; majorDelta != 0 {
return majorDelta
}
if minorDelta := VersionMinor - minor; minorDelta != 0 {
return minorDelta
}
return VersionPatch - patch
}