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

19 lines
836 B
Go
Raw Normal View History

package geojson
import "testing"
func TestGeometryCollection(t *testing.T) {
p := expectJSON(t, `{"type":"GeometryCollection","geometries":[{"type":"Point","coordinates":[1,2,3]}]}`, nil)
expect(t, p.Center() == P(1, 2))
expectJSON(t, `{"type":"GeometryCollection"}`, errGeometriesMissing)
expectJSON(t, `{"type":"GeometryCollection","geometries":null}`, errGeometriesInvalid)
expectJSON(t, `{"type":"GeometryCollection","geometries":[{"type":"Point","coordinates":[1,2,3]}],"bbox":null}`, nil)
expectJSON(t, `{"type":"GeometryCollection","geometries":[{"type":"Point"}]}`, errCoordinatesMissing)
}
func TestGeometryCollectionPoly(t *testing.T) {
p := expectJSON(t, `{"type":"GeometryCollection","geometries":[{"type":"Point","coordinates":[1,2]}]}`, nil)
expect(t, p.Intersects(PO(1, 2)))
expect(t, p.Contains(PO(1, 2)))
}