def test_within(self): l = session.query(Lake).filter(Lake.lake_name=='Lake Blue').one() p1 = session.query(Spot).get(2) p2 = session.query(Spot).get(3) spots_within = session.query(Spot).filter(Spot.spot_location.within(l.lake_geom)).all() ok_(session.scalar(p1.spot_location.within(l.lake_geom))) ok_(not session.scalar(p2.spot_location.within(l.lake_geom))) ok_(p1 in spots_within) ok_(p2 not in spots_within) eq_(session.scalar(functions.within('LINESTRING(0 1, 2 1)', 'POLYGON((-1 -1, 3 -1, 3 2, -1 2, -1 -1))')), True)
def test_buffer(self): r = session.query(Road).filter(Road.road_name=='Graeme Ave').one() assert_almost_equal(float(session.scalar(functions.area(r.road_geom.buffer(10.0), diminfo_))), 1094509.76889366) ok_(session.query(Spot).filter(functions.within( 'POINT(-88.5945861592357 42.9480095987261)', Spot.spot_location.buffer(10))).first() is not None) assert_almost_equal(float(session.scalar(functions.area(functions.buffer( 'POINT(-88.5945861592357 42.9480095987261)', diminfo_, 10, 'unit=km arc_tolerance=0.05'), diminfo_))), 312144711.50297302)
def test_buffer(self): r = session.query(Road).filter(Road.road_name == "Graeme Ave").one() assert_almost_equal(session.scalar(functions.area(r.road_geom.buffer(10.0))), 323.99187776147323) ok_( session.query(Spot) .filter(functions.within("POINT(-88.5945861592357 42.9480095987261)", Spot.spot_location.buffer(10))) .first() is not None ) assert_almost_equal( session.scalar(functions.area(functions.buffer("POINT(-88.5945861592357 42.9480095987261)", 10))), 314.12087152405275, )
def test_within(self): l = session.query(Lake).filter(Lake.lake_name=='Lake Blue').one() p1 = session.query(Spot).filter(Spot.spot_height==102.34).one() p2 = session.query(Spot).filter(Spot.spot_height==388.62).one() spots_within = session.query(Spot).filter(Spot.spot_location.within(l.lake_geom)).all() ok_(session.scalar(p1.spot_location.within(l.lake_geom))) ok_(not session.scalar(p2.spot_location.within(l.lake_geom))) ok_(p1 in spots_within) ok_(p2 not in spots_within) eq_(session.scalar(functions.within('LINESTRING(0 1, 2 1)', 'POLYGON((-1 -1, 3 -1, 3 2, -1 2, -1 -1))')), True) buffer_geom = DBSpatialElement(session.scalar(l.lake_geom.buffer(10.0))) spots_within = session.query(Spot).filter(l.lake_geom.within(buffer_geom)).all() ok_(p1 in spots_within) ok_(p2 in spots_within)
def test_buffer(self): r = session.query(Road).filter(Road.road_name == 'Graeme Ave').one() assert_almost_equal( session.scalar(functions.area(r.road_geom.buffer(10.0))), 323.99187776147323) ok_( session.query(Spot).filter( functions.within('POINT(-88.5945861592357 42.9480095987261)', Spot.spot_location.buffer(10))).first() is not None) assert_almost_equal( session.scalar( functions.area( functions.buffer( 'POINT(-88.5945861592357 42.9480095987261)', 10))), 314.12087152405275)
def test_buffer(self): r = session.query(Road).filter(Road.road_name == 'Graeme Ave').one() assert_almost_equal( session.scalar(functions.area(r.road_geom.buffer(10.0, 8))), 321.93380659099699) ok_( session.query(Spot).filter( functions.within('POINT(-88.5945861592357 42.9480095987261)', Spot.spot_location.buffer(10))).first() is not None) assert_almost_equal( session.scalar( functions.area( functions.buffer( 'POINT(-88.5945861592357 42.9480095987261)', 10, 2))), 282.84271247461902)
def test_buffer_with_tolerance(self): r = session.query(Road).filter(Road.road_name == "Graeme Ave").one() assert_almost_equal( session.scalar(functions.area(r.road_geom.buffer_with_tolerance(10.0, 20, 1))), 214.63894668789601 ) assert_almost_equal( session.scalar(functions.area(r.road_geom.buffer_with_tolerance(10.0, 20, 0))), 214.63894668789601 ) ok_( session.query(Spot) .filter(functions.within("POINT(-88.5945861592357 42.9480095987261)", Spot.spot_location.buffer(10))) .first() is not None ) assert_almost_equal( session.scalar( functions.area( ms_functions.buffer_with_tolerance("POINT(-88.5945861592357 42.9480095987261)", 10, 2, 0) ) ), 306.21843345678644, )
def test_buffer_with_tolerance(self): r = session.query(Road).filter(Road.road_name == 'Graeme Ave').one() assert_almost_equal( session.scalar( functions.area(r.road_geom.buffer_with_tolerance(10.0, 20, 1))), 214.63894668789601) assert_almost_equal( session.scalar( functions.area(r.road_geom.buffer_with_tolerance(10.0, 20, 0))), 214.63894668789601) ok_( session.query(Spot).filter( functions.within('POINT(-88.5945861592357 42.9480095987261)', Spot.spot_location.buffer(10))).first() is not None) assert_almost_equal( session.scalar( functions.area( ms_functions.buffer_with_tolerance( 'POINT(-88.5945861592357 42.9480095987261)', 10, 2, 0))), 306.21843345678644)
def test_buffer(self): r = session.query(Road).filter(Road.road_name=='Graeme Ave').one() assert_almost_equal(session.scalar(functions.area(r.road_geom.buffer(10.0, 8))), 321.93380659099699) ok_(session.query(Spot).filter(functions.within('POINT(-88.5945861592357 42.9480095987261)', Spot.spot_location.buffer(10))).first() is not None) assert_almost_equal(session.scalar(functions.area(functions.buffer('POINT(-88.5945861592357 42.9480095987261)', 10, 2))), 282.84271247461902)