From aa632e2bd6796ac450b606b91c0fa73b1daa03bd Mon Sep 17 00:00:00 2001 From: Oliver Tonnhofer Date: Mon, 11 Nov 2013 09:41:41 +0100 Subject: [PATCH] do not add prepared geometries to index --- geom/geos/index.go | 9 +++------ geom/limit/limit.go | 20 +++++++------------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/geom/geos/index.go b/geom/geos/index.go index 3a1bba6..9239c34 100644 --- a/geom/geos/index.go +++ b/geom/geos/index.go @@ -19,11 +19,9 @@ import ( ) // IndexGeom is a struct for indexed geometries used by Index -// and returned by IndexQuery. Access to Prepared requires acquiring .Lock() +// and returned by IndexQuery. type IndexGeom struct { - *sync.Mutex // Mutex for Prepared - Geom *Geom - Prepared *PreparedGeom + Geom *Geom } type Index struct { v *C.GEOSSTRtree @@ -45,8 +43,7 @@ func (this *Geos) IndexAdd(index *Index, geom *Geom) { defer index.mu.Unlock() id := len(index.geoms) C.IndexAdd(this.v, index.v, geom.v, C.size_t(id)) - prep := this.Prepare(geom) - index.geoms = append(index.geoms, IndexGeom{&sync.Mutex{}, geom, prep}) + index.geoms = append(index.geoms, IndexGeom{geom}) } // IndexQuery queries the index for intersections with geom. diff --git a/geom/limit/limit.go b/geom/limit/limit.go index 5c76a8c..db50329 100644 --- a/geom/limit/limit.go +++ b/geom/limit/limit.go @@ -287,19 +287,13 @@ func (l *Limiter) Clip(geom *geos.Geom) ([]*geos.Geom, error) { var intersections []*geos.Geom // intersect with each part... for _, hit := range hits { - hit.Lock() - if g.PreparedIntersects(hit.Prepared, geom) { - hit.Unlock() - newPart := g.Intersection(hit.Geom, geom) - if newPart == nil { - continue - } - newParts := filterGeometryByType(g, newPart, geomType) - for _, p := range newParts { - intersections = append(intersections, p) - } - } else { - hit.Unlock() + newPart := g.Intersection(hit.Geom, geom) + if newPart == nil { + continue + } + newParts := filterGeometryByType(g, newPart, geomType) + for _, p := range newParts { + intersections = append(intersections, p) } } // and merge parts back to our clipped intersection