Beispiel #1
0
func (this *Geos) Polygon(exterior *Geom, interiors []*Geom) *Geom {
	if len(interiors) == 0 {
		geom := C.GEOSGeom_createPolygon_r(this.v, exterior.v, nil, C.uint(0))
		if geom == nil {
			return nil
		}
		err := C.GEOSNormalize_r(this.v, geom)
		if err != 0 {
			C.GEOSGeom_destroy(geom)
			return nil
		}
		return &Geom{geom}
	}

	interiorPtr := make([]*C.GEOSGeometry, len(interiors))
	for i, geom := range interiors {
		interiorPtr[i] = geom.v
	}
	geom := C.GEOSGeom_createPolygon_r(this.v, exterior.v, &interiorPtr[0], C.uint(len(interiors)))
	if geom == nil {
		return nil
	}
	err := C.GEOSNormalize_r(this.v, geom)
	if err != 0 {
		C.GEOSGeom_destroy(geom)
		return nil
	}
	return &Geom{geom}
}
Beispiel #2
0
func destroyGeom(geom *Geom) {
	C.GEOSGeom_destroy(geom.v)
}
Beispiel #3
0
func DestroyPt(p Point) {
	C.GEOSGeom_destroy(p.pointptr)
}
Beispiel #4
0
func GeosDestroy(geom Geom) {
	C.GEOSPreparedGeom_destroy(geom.preped)
	C.GEOSGeom_destroy(geom.geom)
}