-
Notifications
You must be signed in to change notification settings - Fork 0
/
daps_test.go
77 lines (70 loc) · 1.82 KB
/
daps_test.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
package backendgis
import (
"fmt"
"testing"
)
var dbname = "datajson"
var collname = "get"
// func TestGeoIntersects(t *testing.T) {
// mconn := SetConnection("MONGOSTRING", dbname)
// coordinates := Polygon{
// Coordinates: [][][]float64{
// {
// {107.54190844499595, -6.873854824661734},
// {107.54184261920568, -6.873975211086574},
// {107.54201584497002, -6.874061201371745},
// {107.54208686753464, -6.8739494139982185},
// {107.54190844499595, -6.873854824661734},
// },
// },
// }
// name := GeoIntersects(mconn, collname, coordinates)
// fmt.Println(name)
// }
func TestGeoWithin(t *testing.T) {
mconn := SetConnection("MONGOSTRING", dbname)
coordinates := Polygon{
Coordinates: [][][]float64{
{
{95.31123456789012, 5.553210987654321},
{95.31133456789011, 5.553210987654321},
{95.31133456789011, 5.553310987654321},
{95.31123456789012, 5.553310987654321},
{95.31123456789012, 5.553210987654321},
},
},
}
name := GeoWithin(mconn, collname, coordinates)
fmt.Println(name)
}
func TestNear(t *testing.T) {
mconn := SetConnection2dsphere("MONGOSTRING", "geojson", "get")
coordinates := Point{
Coordinates: []float64{
95.30987654321098, 5.556789012345678,
},
}
name := Near(mconn, "get", coordinates)
fmt.Println(name)
}
func TestNearSphere(t *testing.T) {
mconn := SetConnection("MONGOSTRING", "geojson")
coordinates := Point{
Coordinates: []float64{
95.30987654321098, 5.556789012345678,
},
}
name := NearSphere(mconn, "get", coordinates)
fmt.Println(name)
}
func TestBox(t *testing.T) {
mconn := SetConnection("MONGOSTRING", "geojson")
coordinates := Polyline{
Coordinates: [][]float64{
{107.54165179627012, -6.873347393494967},
{107.54253039713798, -6.873937966575383},
},
}
name := Box(mconn, collname, coordinates)
fmt.Println(name)
}