tile38/vendor/github.com/tidwall/geojson/multilinestring_test.go

32 lines
1.1 KiB
Go
Raw Normal View History

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)
}
2019-01-10 19:37:20 +03:00
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)))
}