func (g Geometry) AsPolygon() Polygon {
	g.check(TypePolygon)
	return *(*Polygon)(g.ptr)
}
AsPolygon returns the geometry as a Polygon. It panics if the geometry is
not a Polygon.
package geom
import (
	"database/sql/driver"
	"fmt"
	"unsafe"
)
type Geometry struct {
	gtype GeometryType
	ptr   unsafe.Pointer
}
type GeometryType int
const (
	TypeGeometryCollection GeometryType = iota
	TypePoint
	TypeLineString
	TypePolygon
	TypeMultiPoint
	TypeMultiLineString
	TypeMultiPolygon
)
func (t GeometryType) String() string {
	switch t {
	case TypeGeometryCollection:
		return "GeometryCollection"
	case TypePoint:
		return "Point"
	case TypeLineString:
		return "LineString"
	case TypePolygon:
		return "Polygon"
	case TypeMultiPoint:
		return "MultiPoint"
	case TypeMultiLineString:
		return "MultiLineString"
	case TypeMultiPolygon:
		return "MultiPolygon"
	default:
		return "invalid"
	}
}
func (g Geometry) Type() GeometryType {
	switch g.gtype {
	case TypeGeometryCollection:
		return g.AsGeometryCollection().Type()
	case TypePoint:
		return g.AsPoint().Type()
	case TypeLineString:
		return g.AsLineString().Type()
	case TypePolygon:
		return g.AsPolygon().Type()
	case TypeMultiPoint:
		return g.AsMultiPoint().Type()
	case TypeMultiLineString:
		return g.AsMultiLineString().Type()
	case TypeMultiPolygon:
		return g.AsMultiPolygon().Type()
	default:
		panic("unknown geometry: " + g.gtype.String())
	}
}
func (g Geometry) IsGeometryCollection() bool { return g.gtype == TypeGeometryCollection }
func (g Geometry) IsPoint() bool { return g.gtype == TypePoint }
func (g Geometry) IsLineString() bool { return g.gtype == TypeLineString }
func (g Geometry) IsPolygon() bool { return g.gtype == TypePolygon }
func (g Geometry) IsMultiPoint() bool { return g.gtype == TypeMultiPoint }
func (g Geometry) IsMultiLineString() bool { return g.gtype == TypeMultiLineString }
func (g Geometry) IsMultiPolygon() bool { return g.gtype == TypeMultiPolygon }
func (g Geometry) check(gtype GeometryType) {
	if g.gtype != gtype {
		panic(fmt.Sprintf("called As%s on Geometry containing %s", gtype, g.gtype))
	}
}
func (g Geometry) AsGeometryCollection() GeometryCollection {
	g.check(TypeGeometryCollection)
	if g.ptr == nil {
		return GeometryCollection{}
	}
	return *(*GeometryCollection)(g.ptr)
}
func (g Geometry) AsPoint() Point {
	g.check(TypePoint)
	return *(*Point)(g.ptr)
}
func (g Geometry) AsLineString() LineString {
	g.check(TypeLineString)
	return *(*LineString)(g.ptr)
}