// RawGeometry isn't smart. It just queries the window given for geometry.
163543
func RawGeometry(xu *xgbutil.XUtil, win xproto.Drawable) (xrect.Rect, error) {
	xgeom, err := xproto.GetGeometry(xu.Conn(), win).Reply()
	if err != nil {
		return nil, err
	}
	return xrect.New(int(xgeom.X), int(xgeom.Y),
		int(xgeom.Width), int(xgeom.Height)), nil
}
77628
func (g *Geometry) UnmarshalJSON(data []byte) error {
	var object map[string]interface{}
	err := json.Unmarshal(data, &object)
	if err != nil {
		return err
	}

	return decodeGeometry(g, object)
}
79149
func (c *Connection) RawQuery(stmt string, args ...interface{}) *Query {
	return Q(c).RawQuery(stmt, args...)
}
451056
func (d *wktDecoder) decode(wkt string) (*Geometry, error) {
	cstr := C.CString(wkt)
	defer C.free(unsafe.Pointer(cstr))
	g := cGEOSWKTReader_read(d.r, cstr)
	if g == nil {
		return nil, Error()
	}
	return geomFromPtr(g), nil
}
147130
func DesktopGeometryGet(xu *xgbutil.XUtil) (*DesktopGeometry, error) {
	geom, err := xprop.PropValNums(xprop.GetProperty(xu, xu.RootWin(),
		"_NET_DESKTOP_GEOMETRY"))
	if err != nil {
		return nil, err
	}

	return &DesktopGeometry{Width: int(geom[0]), Height: int(geom[1])}, nil
}
801289
func (g *GeometryCollection) Layout() Layout {
	maxLayout := NoLayout
	for _, g := range g.geoms {
		switch l := g.Layout(); l {
		case XYZ:
			if maxLayout == XYM {
				maxLayout = XYZM
			} else if l > maxLayout {
				maxLayout = l
			}
		case XYM:
			if maxLayout == XYZ {
				maxLayout = XYZM
			} else if l > maxLayout {
				maxLayout = l
			}
		default:
			if l > maxLayout {
				maxLayout = l
			}
		}
	}
	return maxLayout
}
1169464
func (c *Client) rawQuery(endpoint string, q *QueryOptions) (io.ReadCloser, error) {
	r, err := c.newRequest("GET", endpoint)
	if err != nil {
		return nil, err
	}
	r.setQueryOptions(q)
	_, resp, err := requireOK(c.doRequest(r))
	if err != nil {
		return nil, err
	}

	return resp.Body, nil
}
384014
func (w *Window) GetFramebufferSize() (width, height int) {
	var wi, h C.int
	C.glfwGetFramebufferSize(w.data, &wi, &h)
	return int(wi), int(h)
}
1353230
func DesktopGeometrySet(xu *xgbutil.XUtil, dg *DesktopGeometry) error {
	return xprop.ChangeProp32(xu, xu.RootWin(), "_NET_DESKTOP_GEOMETRY",
		"CARDINAL", uint(dg.Width), uint(dg.Height))
}
1156568
func (a *MovFnAggregation) Window(window int) *MovFnAggregation {
	a.window = window
	return a
}
896119
func (a *MovAvgAggregation) Window(window int) *MovAvgAggregation {
	a.window = &window
	return a
}
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)
}
1114087
func (surface *XlibSurface) GetWidth() int {
	ret := int(C.cairo_xlib_surface_get_width(surface.Ptr))
	if err := surface.status(); err != nil {
		panic(err)
	}
	return ret
}
1276906
func (g *Geometry) String() string {
	str, err := g.ToWKT()
	if err != nil {
		return "" // XXX: better to panic?
	}
	return str
}
888103
func (s *Block) SetGeometry(v *Geometry) *Block {
	s.Geometry = v
	return s
}
520226
func Encode(g geom.T) (*Geometry, error) {
	switch g := g.(type) {
	case *geom.Point:
		var coords json.RawMessage
		coords, err := json.Marshal(g.Coords())
		if err != nil {
			return nil, err
		}
		return &Geometry{
			Type:        "Point",
			Coordinates: &coords,
		}, nil
	case *geom.LineString:
		var coords json.RawMessage
		coords, err := json.Marshal(g.Coords())
		if err != nil {
			return nil, err
		}
		return &Geometry{
			Type:        "LineString",
			Coordinates: &coords,
		}, nil
	case *geom.Polygon:
		var coords json.RawMessage
		coords, err := json.Marshal(g.Coords())
		if err != nil {
			return nil, err
		}
		return &Geometry{
			Type:        "Polygon",
			Coordinates: &coords,
		}, nil
	case *geom.MultiPoint:
		var coords json.RawMessage
		coords, err := json.Marshal(g.Coords())
		if err != nil {
			return nil, err
		}
		return &Geometry{
			Type:        "MultiPoint",
			Coordinates: &coords,
		}, nil
	case *geom.MultiLineString:
		var coords json.RawMessage
		coords, err := json.Marshal(g.Coords())
		if err != nil {
			return nil, err
		}
		return &Geometry{
			Type:        "MultiLineString",
			Coordinates: &coords,
		}, nil
	case *geom.MultiPolygon:
		var coords json.RawMessage
		coords, err := json.Marshal(g.Coords())
		if err != nil {
			return nil, err
		}
		return &Geometry{
			Type:        "MultiPolygon",
			Coordinates: &coords,
		}, nil
	case *geom.GeometryCollection:
		geometries := make([]*Geometry, len(g.Geoms()))
		for i, subGeometry := range g.Geoms() {
			var err error
			geometries[i], err = Encode(subGeometry)
			if err != nil {
				return nil, err
			}
		}
		return &Geometry{
			Type:       "GeometryCollection",
			Geometries: geometries,
		}, nil
	default:
		return nil, geom.ErrUnsupportedType{Value: g}
	}
}
542840
func (q *QueryString) Raw(name string) (string, bool) {
	v, ok := q.fields[name]
	return v, ok
}