do not add prepared geometries to index
parent
390edea938
commit
aa632e2bd6
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue