This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
zhangyang-zerotierone/ext/librethinkdbxx/test/upstream/geo/geojson.yaml
2017-11-02 07:05:11 -07:00

32 lines
2.0 KiB
YAML

desc: Test geoJSON conversion
tests:
# Basic conversion
- cd: r.geojson({'coordinates':[0, 0], 'type':'Point'})
ot: ({'$reql_type$':'GEOMETRY', 'coordinates':[0, 0], 'type':'Point'})
- cd: r.geojson({'coordinates':[[0,0], [0,1]], 'type':'LineString'})
ot: ({'$reql_type$':'GEOMETRY', 'coordinates':[[0,0], [0,1]], 'type':'LineString'})
- cd: r.geojson({'coordinates':[[[0,0], [0,1], [1,0], [0,0]]], 'type':'Polygon'})
ot: ({'$reql_type$':'GEOMETRY', 'coordinates':[[[0,0], [0,1], [1,0], [0,0]]], 'type':'Polygon'})
# Wrong / missing fields
- cd: r.geojson({'coordinates':[[], 0], 'type':'Point'})
ot: err('ReqlQueryLogicError', 'Expected type NUMBER but found ARRAY.', [0])
- cd: r.geojson({'coordinates':true, 'type':'Point'})
ot: err('ReqlQueryLogicError', 'Expected type ARRAY but found BOOL.', [0])
- cd: r.geojson({'type':'Point'})
ot: err('ReqlNonExistenceError', 'No attribute `coordinates` in object:', [0])
- cd: r.geojson({'coordinates':[0, 0]})
ot: err('ReqlNonExistenceError', 'No attribute `type` in object:', [0])
- cd: r.geojson({'coordinates':[0, 0], 'type':'foo'})
ot: err('ReqlQueryLogicError', 'Unrecognized GeoJSON type `foo`.', [0])
- cd: r.geojson({'coordinates':[0, 0], 'type':'Point', 'foo':'wrong'})
ot: err('ReqlQueryLogicError', 'Unrecognized field `foo` found in geometry object.', [0])
# Unsupported features
- cd: r.geojson({'coordinates':[0, 0], 'type':'Point', 'crs':null})
ot: ({'$reql_type$':'GEOMETRY', 'coordinates':[0, 0], 'type':'Point', 'crs':null})
- js: r.geojson({'coordinates':[0, 0], 'type':'Point', 'crs':{'type':'name', 'properties':{'name':'test'}}})
ot: err('ReqlQueryLogicError', 'Non-default coordinate reference systems are not supported in GeoJSON objects. Make sure the `crs` field of the geometry is null or non-existent.', [0])
- cd: r.geojson({'coordinates':[0, 0], 'type':'MultiPoint'})
ot: err('ReqlQueryLogicError', 'GeoJSON type `MultiPoint` is not supported.', [0])