// Geometry retrieves an up-to-date version of the this window's geometry.
// It also loads the geometry into the Geom member of Window.
1656
func (w *Window) Geometry() (xrect.Rect, error) {
	geom, err := RawGeometry(w.X, xproto.Drawable(w.Id))
	if err != nil {
		return nil, err
	}
	w.Geom = geom
	return geom, err
}
966573
func (p *PGeometry) Covers(other *Geometry) (bool, error) {
	return p.predicate("covers", cGEOSPreparedCovers, other)
}
476841
func DesktopGeometryReq(xu *xgbutil.XUtil, dg *DesktopGeometry) error {
	return ClientEvent(xu, xu.RootWin(), "_NET_DESKTOP_GEOMETRY", dg.Width,
		dg.Height)
}
609275
func (g *Geometry) Simplify(tolerance float64) (*Geometry, error) {
	return g.simplify("simplify", cGEOSSimplify, tolerance)
}
939403
func Clone(g Geometry) Geometry {
	if g == nil {
		return nil
	}

	switch g := g.(type) {
	case Point:
		return g
	case MultiPoint:
		if g == nil {
			return nil
		}
		return g.Clone()
	case LineString:
		if g == nil {
			return nil
		}
		return g.Clone()
	case MultiLineString:
		if g == nil {
			return nil
		}
		return g.Clone()
	case Ring:
		if g == nil {
			return nil
		}
		return g.Clone()
	case Polygon:
		if g == nil {
			return nil
		}
		return g.Clone()
	case MultiPolygon:
		if g == nil {
			return nil
		}
		return g.Clone()
	case Collection:
		if g == nil {
			return nil
		}
		return g.Clone()
	case Bound:
		return g
	}

	panic(fmt.Sprintf("geometry type not supported: %T", g))
}
315785
func (g *GeometryCollection) Push(gs ...T) error {
	g.geoms = append(g.geoms, gs...)
	return nil
}
604285
func newGeometry(input interface{}) interface{} {
	var (
		result      interface{}
		coordinates interface{}
	)
	switch it := input.(type) {
	case map[string]interface{}:
		if _, ok := it[COORDINATES]; ok {
			coordinates = interfaceToArray(it[COORDINATES])
		}
		iType := it[TYPE].(string)
		switch iType {
		case POINT:
			result = NewPoint(coordinates.([]float64))
		case LINESTRING:
			result = NewLineString(coordinates.([][]float64))
		case POLYGON:
			result = NewPolygon(coordinates.([][][]float64))
		case MULTIPOINT:
			result = NewMultiPoint(coordinates.([][]float64))
		case MULTILINESTRING:
			result = NewMultiLineString(coordinates.([][][]float64))
		case MULTIPOLYGON:
			result = NewMultiPolygon(coordinates.([][][][]float64))
		case GEOMETRYCOLLECTION:
			geometries := it["geometries"].([]interface{})
			for inx, geometry := range geometries {
				geometries[inx] = newGeometry(geometry)
			}
			result = NewGeometryCollection(geometries)
		}
	case *Point, *LineString, *Polygon, *MultiPoint, *MultiLineString, *MultiPolygon, *GeometryCollection:
		result = it
	}
	return result
}
121331
func (g *Geometry) Coords() ([]Coord, error) {
	ptr := cGEOSGeom_getCoordSeq(g.g)
	if ptr == nil {
		return nil, Error()
	}
	//cs := coordSeqFromPtr(ptr)
	cs := &coordSeq{c: ptr}
	return coordSlice(cs)
}
1192042
func UnmarshalGeometry(data []byte) (*Geometry, error) {
	g := &Geometry{}
	err := json.Unmarshal(data, g)
	if err != nil {
		return nil, err
	}

	return g, nil
}
1255646
func (p *PGeometry) Within(other *Geometry) (bool, error) {
	return p.predicate("within", cGEOSPreparedWithin, other)
}
185174
func (g *Geometry) Interpolate(dist float64) (*Geometry, error) {
	return geomFromC("Interpolate", cGEOSInterpolate(g.g, C.double(dist)))
}
118438
func Area(g orb.Geometry) float64 {
	if g == nil {
		return 0
	}

	switch g := g.(type) {
	case orb.Point, orb.MultiPoint, orb.LineString, orb.MultiLineString:
		return 0
	case orb.Ring:
		return math.Abs(ringArea(g))
	case orb.Polygon:
		return polygonArea(g)
	case orb.MultiPolygon:
		return multiPolygonArea(g)
	case orb.Collection:
		return collectionArea(g)
	case orb.Bound:
		return Area(g.ToRing())
	}

	panic(fmt.Sprintf("geometry type not supported: %T", g))
}
1049515
func (t *GeometryCollection) AddGeometry(g interface{}) error {
	switch c := g.(type) {
	case []interface{}:
		t.AddGeometries(c...)
		break
	case interface{}:
		t.AddGeometries(c)
		break
	default:
		return errors.New(fmt.Sprintf("AssertionError %v", g))
	}
	return nil
}
780367
func (g *Geometry) Overlaps(other *Geometry) (bool, error) {
	return g.binaryPred("Overlaps", cGEOSOverlaps, other)
}
103463
func (g *Geometry) Scan(value interface{}) error {
	var data []byte

	switch value.(type) {
	case string:
		data = []byte(value.(string))
	case []byte:
		data = value.([]byte)
	default:
		return errors.New("unable to parse this type into geojson")
	}

	return g.UnmarshalJSON(data)
}
1276906
func (g *Geometry) String() string {
	str, err := g.ToWKT()
	if err != nil {
		return "" // XXX: better to panic?
	}
	return str
}
1070955
func (p *Path) Intersects(geometry interface{}) bool {
	var result bool

	switch g := geometry.(type) {
	case Line:
		result = p.IntersectsLine(&g)
	case *Line:
		result = p.IntersectsLine(g)
	case Path:
		result = p.IntersectsPath(&g)
	case *Path:
		result = p.IntersectsPath(g)
	default:
		panic("can only determine intersection with lines and paths")
	}

	return result
}