writer: do not check for validity of simple polygons
Skips slow GEOS IsValid calls for polygons with only 4 corners. They can be invalid, but its more unlikely to get simple polygons wrong and even if, it should affect only small polygons like buildings.master
parent
e245e01b95
commit
a367850f6f
|
@ -112,6 +112,11 @@ func (this *Geos) NumGeoms(geom *Geom) int32 {
|
|||
return count
|
||||
}
|
||||
|
||||
func (this *Geos) NumCoordinates(geom *Geom) int32 {
|
||||
count := int32(C.GEOSGetNumCoordinates_r(this.v, geom.v))
|
||||
return count
|
||||
}
|
||||
|
||||
func (this *Geos) Geoms(geom *Geom) []*Geom {
|
||||
count := this.NumGeoms(geom)
|
||||
var result []*Geom
|
||||
|
|
|
@ -139,7 +139,10 @@ func (ww *WayWriter) buildAndInsert(g *geos.Geos, w *element.Way, matches []mapp
|
|||
if isPolygon {
|
||||
geosgeom, err = geomp.Polygon(g, way.Nodes)
|
||||
if err == nil {
|
||||
geosgeom, err = g.MakeValid(geosgeom)
|
||||
if g.NumCoordinates(geosgeom) > 5 {
|
||||
// only check for valididty for non-simple geometries
|
||||
geosgeom, err = g.MakeValid(geosgeom)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
geosgeom, err = geomp.LineString(g, way.Nodes)
|
||||
|
|
Loading…
Reference in New Issue