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
|
// 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 {
|
type IndexGeom struct {
|
||||||
*sync.Mutex // Mutex for Prepared
|
Geom *Geom
|
||||||
Geom *Geom
|
|
||||||
Prepared *PreparedGeom
|
|
||||||
}
|
}
|
||||||
type Index struct {
|
type Index struct {
|
||||||
v *C.GEOSSTRtree
|
v *C.GEOSSTRtree
|
||||||
|
@ -45,8 +43,7 @@ func (this *Geos) IndexAdd(index *Index, geom *Geom) {
|
||||||
defer index.mu.Unlock()
|
defer index.mu.Unlock()
|
||||||
id := len(index.geoms)
|
id := len(index.geoms)
|
||||||
C.IndexAdd(this.v, index.v, geom.v, C.size_t(id))
|
C.IndexAdd(this.v, index.v, geom.v, C.size_t(id))
|
||||||
prep := this.Prepare(geom)
|
index.geoms = append(index.geoms, IndexGeom{geom})
|
||||||
index.geoms = append(index.geoms, IndexGeom{&sync.Mutex{}, geom, prep})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IndexQuery queries the index for intersections with 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
|
var intersections []*geos.Geom
|
||||||
// intersect with each part...
|
// intersect with each part...
|
||||||
for _, hit := range hits {
|
for _, hit := range hits {
|
||||||
hit.Lock()
|
newPart := g.Intersection(hit.Geom, geom)
|
||||||
if g.PreparedIntersects(hit.Prepared, geom) {
|
if newPart == nil {
|
||||||
hit.Unlock()
|
continue
|
||||||
newPart := g.Intersection(hit.Geom, geom)
|
}
|
||||||
if newPart == nil {
|
newParts := filterGeometryByType(g, newPart, geomType)
|
||||||
continue
|
for _, p := range newParts {
|
||||||
}
|
intersections = append(intersections, p)
|
||||||
newParts := filterGeometryByType(g, newPart, geomType)
|
|
||||||
for _, p := range newParts {
|
|
||||||
intersections = append(intersections, p)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
hit.Unlock()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// and merge parts back to our clipped intersection
|
// and merge parts back to our clipped intersection
|
||||||
|
|
Loading…
Reference in New Issue