forked from paulsmith/gogeos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeos.go
34 lines (28 loc) · 867 Bytes
/
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
// Package geos provides support for creating and manipulating spatial data.
// At its core, it relies on the GEOS C library for the implementation of
// spatial operations and geometric algorithms.
package geos
/*
#cgo LDFLAGS: -lgeos_c
#include "geos.h"
*/
import "C"
import (
"fmt"
"sync"
)
var (
// Required for the thread-safe GEOS C API (the "*_r" functions).
handle = C.go_geos_initGEOS()
// Protects the handle from being used concurrently in multiple C threads.
handlemu sync.Mutex
)
// XXX: store last error message from handler in a global var (chan?)
// Version returns the version of the GEOS C API in use.
func Version() string {
return C.GoString(cGEOSversion())
}
// Error gets the last error that occured in the GEOS C API as a Go error type.
func Error() error {
return fmt.Errorf("geos: %s", C.GoString(C.go_geos_get_last_error()))
}