1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
|
package rethinkdb
import (
p "gopkg.in/rethinkdb/rethinkdb-go.v6/ql2"
)
// CircleOpts contains the optional arguments for the Circle term.
type CircleOpts struct {
NumVertices interface{} `rethinkdb:"num_vertices,omitempty"`
GeoSystem interface{} `rethinkdb:"geo_system,omitempty"`
Unit interface{} `rethinkdb:"unit,omitempty"`
Fill interface{} `rethinkdb:"fill,omitempty"`
}
func (o CircleOpts) toMap() map[string]interface{} {
return optArgsToMap(o)
}
// Circle constructs a circular line or polygon. A circle in RethinkDB is
// a polygon or line approximating a circle of a given radius around a given
// center, consisting of a specified number of vertices (default 32).
func Circle(point, radius interface{}, optArgs ...CircleOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructRootTerm("Circle", p.Term_CIRCLE, []interface{}{point, radius}, opts)
}
// DistanceOpts contains the optional arguments for the Distance term.
type DistanceOpts struct {
GeoSystem interface{} `rethinkdb:"geo_system,omitempty"`
Unit interface{} `rethinkdb:"unit,omitempty"`
}
func (o DistanceOpts) toMap() map[string]interface{} {
return optArgsToMap(o)
}
// Distance calculates the Haversine distance between two points. At least one
// of the geometry objects specified must be a point.
func (t Term) Distance(point interface{}, optArgs ...DistanceOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "Distance", p.Term_DISTANCE, []interface{}{point}, opts)
}
// Distance calculates the Haversine distance between two points. At least one
// of the geometry objects specified must be a point.
func Distance(point1, point2 interface{}, optArgs ...DistanceOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructRootTerm("Distance", p.Term_DISTANCE, []interface{}{point1, point2}, opts)
}
// Fill converts a Line object into a Polygon object. If the last point does not
// specify the same coordinates as the first point, polygon will close the
// polygon by connecting them
func (t Term) Fill() Term {
return constructMethodTerm(t, "Fill", p.Term_FILL, []interface{}{}, map[string]interface{}{})
}
// GeoJSON converts a GeoJSON object to a ReQL geometry object.
func GeoJSON(args ...interface{}) Term {
return constructRootTerm("GeoJSON", p.Term_GEOJSON, args, map[string]interface{}{})
}
// ToGeoJSON converts a ReQL geometry object to a GeoJSON object.
func (t Term) ToGeoJSON(args ...interface{}) Term {
return constructMethodTerm(t, "ToGeoJSON", p.Term_TO_GEOJSON, args, map[string]interface{}{})
}
// GetIntersectingOpts contains the optional arguments for the GetIntersecting term.
type GetIntersectingOpts struct {
Index interface{} `rethinkdb:"index,omitempty"`
}
func (o GetIntersectingOpts) toMap() map[string]interface{} {
return optArgsToMap(o)
}
// GetIntersecting gets all documents where the given geometry object intersects
// the geometry object of the requested geospatial index.
func (t Term) GetIntersecting(args interface{}, optArgs ...GetIntersectingOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "GetIntersecting", p.Term_GET_INTERSECTING, []interface{}{args}, opts)
}
// GetNearestOpts contains the optional arguments for the GetNearest term.
type GetNearestOpts struct {
Index interface{} `rethinkdb:"index,omitempty"`
MaxResults interface{} `rethinkdb:"max_results,omitempty"`
MaxDist interface{} `rethinkdb:"max_dist,omitempty"`
Unit interface{} `rethinkdb:"unit,omitempty"`
GeoSystem interface{} `rethinkdb:"geo_system,omitempty"`
}
func (o GetNearestOpts) toMap() map[string]interface{} {
return optArgsToMap(o)
}
// GetNearest gets all documents where the specified geospatial index is within a
// certain distance of the specified point (default 100 kilometers).
func (t Term) GetNearest(point interface{}, optArgs ...GetNearestOpts) Term {
opts := map[string]interface{}{}
if len(optArgs) >= 1 {
opts = optArgs[0].toMap()
}
return constructMethodTerm(t, "GetNearest", p.Term_GET_NEAREST, []interface{}{point}, opts)
}
// Includes tests whether a geometry object is completely contained within another.
// When applied to a sequence of geometry objects, includes acts as a filter,
// returning a sequence of objects from the sequence that include the argument.
func (t Term) Includes(args ...interface{}) Term {
return constructMethodTerm(t, "Includes", p.Term_INCLUDES, args, map[string]interface{}{})
}
// Intersects tests whether two geometry objects intersect with one another.
// When applied to a sequence of geometry objects, intersects acts as a filter,
// returning a sequence of objects from the sequence that intersect with the
// argument.
func (t Term) Intersects(args ...interface{}) Term {
return constructMethodTerm(t, "Intersects", p.Term_INTERSECTS, args, map[string]interface{}{})
}
// Line constructs a geometry object of type Line. The line can be specified in
// one of two ways:
// - Two or more two-item arrays, specifying longitude and latitude numbers of
// the line's vertices;
// - Two or more Point objects specifying the line's vertices.
func Line(args ...interface{}) Term {
return constructRootTerm("Line", p.Term_LINE, args, map[string]interface{}{})
}
// Point constructs a geometry object of type Point. The point is specified by
// two floating point numbers, the longitude (−180 to 180) and latitude
// (−90 to 90) of the point on a perfect sphere.
func Point(lon, lat interface{}) Term {
return constructRootTerm("Point", p.Term_POINT, []interface{}{lon, lat}, map[string]interface{}{})
}
// Polygon constructs a geometry object of type Polygon. The Polygon can be
// specified in one of two ways:
// - Three or more two-item arrays, specifying longitude and latitude numbers of the polygon's vertices;
// - Three or more Point objects specifying the polygon's vertices.
func Polygon(args ...interface{}) Term {
return constructRootTerm("Polygon", p.Term_POLYGON, args, map[string]interface{}{})
}
// PolygonSub "punches a hole" out of the parent polygon using the polygon passed
// to the function.
// polygon1.PolygonSub(polygon2) -> polygon
// In the example above polygon2 must be completely contained within polygon1
// and must have no holes itself (it must not be the output of polygon_sub itself).
func (t Term) PolygonSub(args ...interface{}) Term {
return constructMethodTerm(t, "PolygonSub", p.Term_POLYGON_SUB, args, map[string]interface{}{})
}
|