diff --git a/geom/geos/geos.go b/geom/geos/geos.go index e311b6f..559cb13 100644 --- a/geom/geos/geos.go +++ b/geom/geos/geos.go @@ -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 diff --git a/writer/ways.go b/writer/ways.go index 3ba3af4..5ca184a 100644 --- a/writer/ways.go +++ b/writer/ways.go @@ -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)