forked from twpayne/go-geos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
geos.go
87 lines (73 loc) · 2.18 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
// Package geos provides an interface to GEOS. See https://trac.osgeo.org/geos/.
package geos
// #cgo pkg-config: geos
// #include "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
)
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 (
errDimensionOutOfRange = Error("dimension out of range")
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
)
// versionEqualOrGreaterThan returns true if the GEOS version is at least
// major.minor.patch.
func versionEqualOrGreaterThan(major, minor, patch int) bool {
switch {
case VersionMajor > major:
return true
case VersionMajor < major:
return false
}
switch {
case VersionMinor > minor:
return true
case VersionMinor < minor:
return false
}
return VersionPatch >= patch
}