forked from tidwall/geojson
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultilinestring_test.go
31 lines (27 loc) · 1.06 KB
/
multilinestring_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
package geojson
import "testing"
func TestMultiLineString(t *testing.T) {
expectJSON(t, `{"type":"MultiLineString","coordinates":[[[1,2,3]]]}`, errCoordinatesInvalid)
expectJSON(t, `{"type":"MultiLineString","coordinates":[[[1,2]]],"bbox":null}`, errCoordinatesInvalid)
expectJSON(t, `{"type":"MultiLineString"}`, errCoordinatesMissing)
expectJSON(t, `{"type":"MultiLineString","coordinates":null}`, errCoordinatesInvalid)
expectJSON(t, `{"type":"MultiLineString","coordinates":[1,null]}`, errCoordinatesInvalid)
}
func TestMultiLineStringValid(t *testing.T) {
json := `{"type":"MultiLineString","coordinates":[
[[10,10],[120,190]],
[[50,50],[100,100]]
]}`
expectJSON(t, json, nil)
expectJSONOpts(t, json, errCoordinatesInvalid, &ParseOptions{RequireValid: true})
}
func TestMultiLineStringPoly(t *testing.T) {
p := expectJSON(t, `{"type":"MultiLineString","coordinates":[
[[10,10],[20,20]],
[[50,50],[100,100]]
]}`, nil)
expect(t, p.Intersects(PO(15, 15)))
expect(t, p.Contains(PO(15, 15)))
expect(t, p.Contains(PO(70, 70)))
expect(t, !p.Contains(PO(40, 40)))
}