This repository has been archived by the owner on Dec 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathinw_area_selector.go
92 lines (76 loc) · 2.79 KB
/
inw_area_selector.go
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
package t38c
import (
"strconv"
geojson "github.com/paulmach/go.geojson"
)
// InwAreaSelector struct
// Intersects Nearby Within
type InwAreaSelector struct {
client tile38Client
cmd string
key string
}
func newInwAreaSelector(client tile38Client, cmd, key string) InwAreaSelector {
return InwAreaSelector{
client: client,
cmd: cmd,
key: key,
}
}
// Get any object that already exists in the database.
func (selector InwAreaSelector) Get(key, objectID string) InwQueryBuilder {
area := newCmd("GET", key, objectID)
return newInwQueryBuilder(selector.client, selector.cmd, selector.key, area)
}
// Bounds - a minimum bounding rectangle.
func (selector InwAreaSelector) Bounds(minlat, minlon, maxlat, maxlon float64) InwQueryBuilder {
area := newCmd("BOUNDS", floatString(minlat), floatString(minlon), floatString(maxlat), floatString(maxlon))
return newInwQueryBuilder(selector.client, selector.cmd, selector.key, area)
}
// FeatureCollection - GeoJSON Feature Collection object.
func (selector InwAreaSelector) FeatureCollection(fc *geojson.FeatureCollection) InwQueryBuilder {
b, err := fc.MarshalJSON()
if err != nil {
panic(err)
}
area := newCmd("OBJECT", string(b))
return newInwQueryBuilder(selector.client, selector.cmd, selector.key, area)
}
// Feature - GeoJSON Feature object.
func (selector InwAreaSelector) Feature(ft *geojson.Feature) InwQueryBuilder {
b, err := ft.MarshalJSON()
if err != nil {
panic(err)
}
area := newCmd("OBJECT", string(b))
return newInwQueryBuilder(selector.client, selector.cmd, selector.key, area)
}
// Geometry - GeoJSON Geometry object.
func (selector InwAreaSelector) Geometry(gm *geojson.Geometry) InwQueryBuilder {
b, err := gm.MarshalJSON()
if err != nil {
panic(err)
}
area := newCmd("OBJECT", string(b))
return newInwQueryBuilder(selector.client, selector.cmd, selector.key, area)
}
// Circle - a circle with the specified center and radius.
func (selector InwAreaSelector) Circle(lat, lon, meters float64) InwQueryBuilder {
area := newCmd("CIRCLE", floatString(lat), floatString(lon), floatString(meters))
return newInwQueryBuilder(selector.client, selector.cmd, selector.key, area)
}
// Tile - an XYZ Tile.
func (selector InwAreaSelector) Tile(x, y, z int) InwQueryBuilder {
area := newCmd("TILE", strconv.Itoa(x), strconv.Itoa(y), strconv.Itoa(z))
return newInwQueryBuilder(selector.client, selector.cmd, selector.key, area)
}
// Quadkey - a QuadKey.
func (selector InwAreaSelector) Quadkey(quadkey string) InwQueryBuilder {
area := newCmd("QUADKEY", quadkey)
return newInwQueryBuilder(selector.client, selector.cmd, selector.key, area)
}
// Hash - a Geohash.
func (selector InwAreaSelector) Hash(hash string) InwQueryBuilder {
area := newCmd("HASH", hash)
return newInwQueryBuilder(selector.client, selector.cmd, selector.key, area)
}