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/operations.yaml
2017-11-02 07:05:11 -07:00

98 lines
6.8 KiB
YAML

desc: Test basic geometry operators
tests:
# Distance
# coerce_to('STRING') because the test utility has some issues with rounding and I'm too lazy to investigate that now.
- cd: r.distance(r.point(-122, 37), r.point(-123, 37)).coerce_to('STRING')
ot: ("89011.26253835332")
- cd: r.distance(r.point(-122, 37), r.point(-122, 36)).coerce_to('STRING')
ot: ("110968.30443995494")
- cd: r.distance(r.point(-122, 37), r.point(-122, 36)).eq(r.distance(r.point(-122, 36), r.point(-122, 37)))
ot: true
- cd: r.point(-122, 37).distance(r.point(-123, 37)).coerce_to('STRING')
ot: ("89011.26253835332")
- def: someDist = r.distance(r.point(-122, 37), r.point(-123, 37))
js: someDist.eq(r.distance(r.point(-122, 37), r.point(-123, 37), {unit:'m'}))
py: someDist.eq(r.distance(r.point(-122, 37), r.point(-123, 37), unit='m'))
rb: someDist.eq(r.distance(r.point(-122, 37), r.point(-123, 37), :unit=>'m'))
ot: true
- js: someDist.mul(1.0/1000.0).eq(r.distance(r.point(-122, 37), r.point(-123, 37), {unit:'km'}))
py: someDist.mul(1.0/1000.0).eq(r.distance(r.point(-122, 37), r.point(-123, 37), unit='km'))
rb: someDist.mul(1.0/1000.0).eq(r.distance(r.point(-122, 37), r.point(-123, 37), :unit=>'km'))
ot: true
- js: someDist.mul(1.0/1609.344).eq(r.distance(r.point(-122, 37), r.point(-123, 37), {unit:'mi'}))
py: someDist.mul(1.0/1609.344).eq(r.distance(r.point(-122, 37), r.point(-123, 37), unit='mi'))
rb: someDist.mul(1.0/1609.344).eq(r.distance(r.point(-122, 37), r.point(-123, 37), :unit=>'mi'))
ot: true
- js: someDist.mul(1.0/0.3048).eq(r.distance(r.point(-122, 37), r.point(-123, 37), {unit:'ft'}))
py: someDist.mul(1.0/0.3048).eq(r.distance(r.point(-122, 37), r.point(-123, 37), unit='ft'))
rb: someDist.mul(1.0/0.3048).eq(r.distance(r.point(-122, 37), r.point(-123, 37), :unit=>'ft'))
ot: true
- js: someDist.mul(1.0/1852.0).eq(r.distance(r.point(-122, 37), r.point(-123, 37), {unit:'nm'}))
py: someDist.mul(1.0/1852.0).eq(r.distance(r.point(-122, 37), r.point(-123, 37), unit='nm'))
rb: someDist.mul(1.0/1852.0).eq(r.distance(r.point(-122, 37), r.point(-123, 37), :unit=>'nm'))
ot: true
- js: someDist.eq(r.distance(r.point(-122, 37), r.point(-123, 37), {'geo_system':'WGS84'}))
py: someDist.eq(r.distance(r.point(-122, 37), r.point(-123, 37), geo_system='WGS84'))
rb: someDist.eq(r.distance(r.point(-122, 37), r.point(-123, 37), :geo_system=>'WGS84'))
ot: true
# Mearth is a small planet, just 1/10th of earth's size.
- js: someDist.div(10).eq(r.distance(r.point(-122, 37), r.point(-123, 37), {'geo_system':{'a':637813.7, 'f':(1.0/298.257223563)}}))
py: someDist.div(10).eq(r.distance(r.point(-122, 37), r.point(-123, 37), geo_system={'a':637813.7, 'f':(1.0/298.257223563)}))
rb: someDist.div(10).eq(r.distance(r.point(-122, 37), r.point(-123, 37), :geo_system=>{'a':637813.7, 'f':(1.0/298.257223563)}))
ot: true
- py: r.distance(r.point(-122, 37), r.point(-123, 37), geo_system='unit_sphere').coerce_to('STRING')
rb: r.distance(r.point(-122, 37), r.point(-123, 37), :geo_system=>'unit_sphere').coerce_to('STRING')
js: r.distance(r.point(-122, 37), r.point(-123, 37), {'geo_system':'unit_sphere'}).coerce_to('STRING')
ot: ("0.01393875509649327")
- cd: r.distance(r.point(0, 0), r.point(0, 0)).coerce_to('STRING')
ot: ("0")
# These two give the earth's circumference through the poles
- cd: r.distance(r.point(0, 0), r.point(180, 0)).mul(2).coerce_to('STRING')
ot: ("40007862.917250897")
- cd: r.distance(r.point(0, -90), r.point(0, 90)).mul(2).coerce_to('STRING')
ot: ("40007862.917250897")
- cd: r.distance(r.point(0, 0), r.line([0,0], [0,1])).coerce_to('STRING')
ot: ("0")
- cd: r.distance(r.line([0,0], [0,1]), r.point(0, 0)).coerce_to('STRING')
ot: ("0")
- cd: r.distance(r.point(0, 0), r.line([0.1,0], [1,0])).eq(r.distance(r.point(0, 0), r.point(0.1, 0)))
ot: true
- cd: r.distance(r.point(0, 0), r.line([5,-1], [4,2])).coerce_to('STRING')
ot: ("492471.4990055255")
- cd: r.distance(r.point(0, 0), r.polygon([5,-1], [4,2], [10,10])).coerce_to('STRING')
ot: ("492471.4990055255")
- cd: r.distance(r.point(0, 0), r.polygon([0,-1], [0,1], [10,10])).coerce_to('STRING')
ot: ("0")
- cd: r.distance(r.point(0.5, 0.5), r.polygon([0,-1], [0,1], [10,10])).coerce_to('STRING')
ot: ("0")
# Fill
- js: r.circle([0,0], 1, {fill:false}).eq(r.circle([0,0], 1, {fill:true}))
py: r.circle([0,0], 1, fill=false).eq(r.circle([0,0], 1, fill=true))
rb: r.circle([0,0], 1, :fill=>false).eq(r.circle([0,0], 1, :fill=>true))
ot: false
- js: r.circle([0,0], 1, {fill:false}).fill().eq(r.circle([0,0], 1, {fill:true}))
py: r.circle([0,0], 1, fill=false).fill().eq(r.circle([0,0], 1, fill=true))
rb: r.circle([0,0], 1, :fill=>false).fill().eq(r.circle([0,0], 1, :fill=>true))
ot: true
# Subtraction
- cd: r.polygon([0,0], [1,0], [1,1], [0,1]).polygon_sub(r.polygon([0.1,0.1], [0.9,0.1], [0.9,0.9], [0.1,0.9]))
ot: ({'$reql_type$':'GEOMETRY', 'coordinates':[[[0,0],[1,0],[1,1],[0,1],[0,0]],[[0.1,0.1],[0.9,0.1],[0.9,0.9],[0.1,0.9],[0.1,0.1]]], 'type':'Polygon'})
- cd: r.polygon([0,0], [1,0], [1,1], [0,1]).polygon_sub(r.polygon([0.1,0.9], [0.9,0.0], [0.9,0.9], [0.1,0.9]))
ot: err('ReqlQueryLogicError', 'The second argument to `polygon_sub` is not contained in the first one.', [0])
- cd: r.polygon([0,0], [1,0], [1,1], [0,1]).polygon_sub(r.polygon([0,0], [2,0], [2,2], [0,2]))
ot: err('ReqlQueryLogicError', 'The second argument to `polygon_sub` is not contained in the first one.', [0])
- cd: r.polygon([0,0], [1,0], [1,1], [0,1]).polygon_sub(r.polygon([0,-2], [1,-2], [-1,1], [0,-1]))
ot: err('ReqlQueryLogicError', 'The second argument to `polygon_sub` is not contained in the first one.', [0])
- cd: r.polygon([0,0], [1,0], [1,1], [0,1]).polygon_sub(r.polygon([0,-1], [1,-1], [1,0], [0,0]))
ot: err('ReqlQueryLogicError', 'The second argument to `polygon_sub` is not contained in the first one.', [0])
- cd: r.polygon([0,0], [1,0], [1,1], [0,1]).polygon_sub(r.polygon([0.1,-1], [0.9,-1], [0.9,0.5], [0.1,0.5]))
ot: err('ReqlQueryLogicError', 'The second argument to `polygon_sub` is not contained in the first one.', [0])
- cd: r.polygon([0,0], [1,0], [1,1], [0,1]).polygon_sub(r.polygon([0,0],[0.1,0.9],[0.9,0.9],[0.9,0.1]))
ot: ({'$reql_type$':'GEOMETRY', 'coordinates':[[[0,0],[1,0],[1,1],[0,1],[0,0]],[[0,0],[0.1,0.9],[0.9,0.9],[0.9,0.1],[0,0]]], 'type':'Polygon'})
- cd: r.polygon([0,0], [1,0], [1,1], [0,1]).polygon_sub(r.polygon([0,0],[0.1,0.9],[0.9,0.9],[0.9,0.1]).polygon_sub(r.polygon([0.2,0.2],[0.5,0.8],[0.8,0.2])))
ot: err('ReqlQueryLogicError', 'Expected a Polygon with only an outer shell. This one has holes.', [0])
- cd: r.polygon([0,0], [1,0], [1,1], [0,1]).polygon_sub(r.line([0,0],[0.9,0.1],[0.9,0.9],[0.1,0.9]))
ot: err('ReqlQueryLogicError', 'Expected a Polygon but found a LineString.', [])