Skip to content

Commit

Permalink
Merge pull request #2 from robertogyn19/feature/geos-context
Browse files Browse the repository at this point in the history
geos context
  • Loading branch information
robertogyn19 authored Jun 22, 2016
2 parents ae2130f + de189ca commit 4777c40
Show file tree
Hide file tree
Showing 16 changed files with 1,367 additions and 735 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ go: 1.1
notifications:
irc: "chat.freenode.net#gogeos"
email:
- [email protected]
- [email protected]
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Paul Smith <[email protected]>
Roberto Rodrigues Junior <[email protected]>
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
CHANGELOG

0.2.0 / 2016-06-22
* Add STRTree implementations
* Create custom contexts

0.1.2 / 2014-05-29
* Add LineInterpolatePoint -- returns a point interpolated along a line, ala
similar functionality in PostGIS, useful for geocoding, for example.
Expand Down
File renamed without changes.
24 changes: 12 additions & 12 deletions geos/coordseq.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type coordSeq struct {
}

func newCoordSeq(size, dims int) *coordSeq {
p := cGEOSCoordSeq_create(C.uint(size), C.uint(dims))
p := cGEOSCoordSeq_create(geosGlobalContext, C.uint(size), C.uint(dims))
if p == nil {
return nil
}
Expand All @@ -24,14 +24,14 @@ func newCoordSeq(size, dims int) *coordSeq {
func coordSeqFromPtr(ptr *C.GEOSCoordSequence) *coordSeq {
cs := &coordSeq{c: ptr}
runtime.SetFinalizer(cs, func(*coordSeq) {
cGEOSCoordSeq_destroy(ptr)
cGEOSCoordSeq_destroy(geosGlobalContext, ptr)
})
return cs
}

func coordSeqFromSlice(coords []Coord) (*coordSeq, error) {
// XXX: handle 3-dim
ptr := cGEOSCoordSeq_create(C.uint(len(coords)), C.uint(2))
ptr := cGEOSCoordSeq_create(geosGlobalContext, C.uint(len(coords)), C.uint(2))
if ptr == nil {
return nil, Error()
}
Expand All @@ -48,31 +48,31 @@ func coordSeqFromSlice(coords []Coord) (*coordSeq, error) {
}

func (c *coordSeq) Clone() (*coordSeq, error) {
p := cGEOSCoordSeq_clone(c.c)
p := cGEOSCoordSeq_clone(geosGlobalContext, c.c)
if p == nil {
return nil, Error()
}
return coordSeqFromPtr(p), nil
}

func (c *coordSeq) setX(idx int, val float64) error {
i := cGEOSCoordSeq_setX(c.c, C.uint(idx), C.double(val))
i := cGEOSCoordSeq_setX(geosGlobalContext, c.c, C.uint(idx), C.double(val))
if i == 0 {
return Error()
}
return nil
}

func (c *coordSeq) setY(idx int, val float64) error {
i := cGEOSCoordSeq_setY(c.c, C.uint(idx), C.double(val))
i := cGEOSCoordSeq_setY(geosGlobalContext, c.c, C.uint(idx), C.double(val))
if i == 0 {
return Error()
}
return nil
}

func (c *coordSeq) setZ(idx int, val float64) error {
i := cGEOSCoordSeq_setZ(c.c, C.uint(idx), C.double(val))
i := cGEOSCoordSeq_setZ(geosGlobalContext, c.c, C.uint(idx), C.double(val))
if i == 0 {
return Error()
}
Expand All @@ -81,7 +81,7 @@ func (c *coordSeq) setZ(idx int, val float64) error {

func (c *coordSeq) x(idx int) (float64, error) {
var val C.double
i := cGEOSCoordSeq_getX(c.c, C.uint(idx), &val)
i := cGEOSCoordSeq_getX(geosGlobalContext, c.c, C.uint(idx), &val)
if i == 0 {
return 0.0, Error()
}
Expand All @@ -90,7 +90,7 @@ func (c *coordSeq) x(idx int) (float64, error) {

func (c *coordSeq) y(idx int) (float64, error) {
var val C.double
i := cGEOSCoordSeq_getY(c.c, C.uint(idx), &val)
i := cGEOSCoordSeq_getY(geosGlobalContext, c.c, C.uint(idx), &val)
if i == 0 {
return 0.0, Error()
}
Expand All @@ -99,7 +99,7 @@ func (c *coordSeq) y(idx int) (float64, error) {

func (c *coordSeq) z(idx int) (float64, error) {
var val C.double
i := cGEOSCoordSeq_getZ(c.c, C.uint(idx), &val)
i := cGEOSCoordSeq_getZ(geosGlobalContext, c.c, C.uint(idx), &val)
if i == 0 {
return 0.0, Error()
}
Expand All @@ -108,7 +108,7 @@ func (c *coordSeq) z(idx int) (float64, error) {

func (c *coordSeq) size() (int, error) {
var val C.uint
i := cGEOSCoordSeq_getSize(c.c, &val)
i := cGEOSCoordSeq_getSize(geosGlobalContext, c.c, &val)
if i == 0 {
return 0, Error()
}
Expand All @@ -117,7 +117,7 @@ func (c *coordSeq) size() (int, error) {

func (c *coordSeq) dims() (int, error) {
var val C.uint
i := cGEOSCoordSeq_getDimensions(c.c, &val)
i := cGEOSCoordSeq_getDimensions(geosGlobalContext, c.c, &val)
if i == 0 {
return 0, Error()
}
Expand Down
Loading

0 comments on commit 4777c40

Please sign in to comment.