Example #1
0
// UnionPolygons tries to merge polygons.
// Returns a single (Multi)Polygon.
// Destroys polygons and returns new allocated (Multi)Polygon as necessary.
func (this *Geos) UnionPolygons(polygons []*Geom) *Geom {
	if len(polygons) == 0 {
		return nil
	}
	if len(polygons) == 1 {
		return polygons[0]
	}
	multiPolygon := this.MultiPolygon(polygons)
	if multiPolygon == nil {
		return nil
	}
	defer this.Destroy(multiPolygon)

	result := C.GEOSUnaryUnion_r(this.v, multiPolygon.v)
	if result == nil {
		return nil
	}
	return &Geom{result}
}
Example #2
0
func cGEOSUnaryUnion(g *C.GEOSGeometry) *C.GEOSGeometry {
	handlemu.Lock()
	defer handlemu.Unlock()
	return C.GEOSUnaryUnion_r(handle, g)
}