def test_transform(self): spot = session.query(Spot).get(1) # compare the coordinates using a tolerance, because they may vary on different systems assert_almost_equal(session.scalar(functions.x(spot.spot_location.transform(2249))), -3890517.6109559298) assert_almost_equal(session.scalar(functions.y(spot.spot_location.transform(2249))), 3627658.6746507999) ok_( session.query(Spot) .filter( Spot.spot_location.transform(2249) == WKTSpatialElement("POINT(-3890517.61095593 3627658.6746508)", 2249) ) .first() is not None ) eq_( session.scalar( functions.wkt( functions.transform( WKTSpatialElement( "POLYGON((743238 2967416,743238 2967450,743265 2967450,743265.625 2967416,743238 2967416))", 2249, ), 4326, ) ) ), u"POLYGON((-71.1776848522251 42.3902896512902,-71.1776843766326 42.3903829478009,-71.1775844305465 42.3903826677917,-71.1775825927231 42.3902893647987,-71.1776848522251 42.3902896512902))", )
def test_y(self): s = session.query(Spot).get(1) assert_almost_equal(float(session.scalar(s.spot_location.y)), 42.9480095987261) s = session.query(Spot).filter(and_(Spot.spot_location.y < 0, Spot.spot_location.y > 42)).all() ok_(s is not None) assert_almost_equal(float(session.scalar(functions.y(WKTSpatialElement('POINT(-88.3655256496815 43.1402866687898)', geometry_type=Point.name)))), 43.1402866687898)
def test_transform(self): spot = session.query(Spot).get(1) # note that we have to cast to 'ST_POINT', because 'functions.x' only works for Points in Oracle assert_almost_equal(float(session.scalar(functions.x(func.ST_POINT(spot.spot_location.transform(2249))))), -3890517.61088792) assert_almost_equal(float(session.scalar(functions.y(func.ST_POINT(spot.spot_location.transform(2249))))), 3627658.6749871401) ok_(session.query(Spot).filter(functions.wkt(Spot.spot_location.transform(2249)) == 'POINT (-3890517.61088792 3627658.67498714)').first() is not None) eq_(session.scalar(functions.wkt(functions.transform(WKTSpatialElement('POLYGON((743238 2967416,743238 2967450,743265 2967450,743265.625 2967416,743238 2967416))', 2249), 4326))), u'POLYGON ((-71.1776848522252 42.3902896503503, -71.1776843766327 42.390382946861, -71.1775844305466 42.3903826668518, -71.1775825927231 42.3902893638588, -71.1776848522252 42.3902896503503))')
def test_transform(self): spot = session.query(Spot).get(1) # compare the coordinates using a tolerance, because they may vary on different systems assert_almost_equal(session.scalar(functions.x(spot.spot_location.transform(2249))), -3890517.6109559298) assert_almost_equal(session.scalar(functions.y(spot.spot_location.transform(2249))), 3627658.6746507999) ok_(session.query(Spot).filter(Spot.spot_location.transform(2249).wkt == 'POINT(-3890517.61095593 3627658.6746508)').first() is not None) eq_(session.scalar(functions.wkt(functions.transform(WKTSpatialElement('POLYGON((743238 2967416,743238 2967450,743265 2967450,743265.625 2967416,743238 2967416))', 2249), 4326))), 'POLYGON((-71.1776848522251 42.3902896512902,-71.1776843766326 42.3903829478009,-71.1775844305465 42.3903826677917,-71.1775825927231 42.3902893647987,-71.1776848522251 42.3902896512902))')
def test_y(self): s = session.query(Spot).filter(Spot.spot_height == 420.40).one() eq_(session.scalar(s.spot_location.y), 42.9480095987261) s = session.query(Spot).filter( and_(Spot.spot_location.y < 0, Spot.spot_location.y > 42)).all() ok_(s is not None) eq_( session.scalar( functions.y('POINT(-88.3655256496815 43.1402866687898)')), 43.1402866687898)
def test_y(self): l = session.query(Lake).get(1) r = session.query(Road).get(1) s = session.query(Spot).get(1) ok_(not session.scalar(l.lake_geom.y)) ok_(not session.scalar(r.road_geom.y)) eq_(session.scalar(s.spot_location.y), 42.948009598726003) s = session.query(Spot).filter(and_(Spot.spot_location.y < 0, Spot.spot_location.y > 42)).all() ok_(s is not None) eq_(session.scalar(functions.y('POINT(-88.3655256496815 43.1402866687898)')), 43.140286668789997)
def test_y(self): import math l = session.query(Lake).get(1) r = session.query(Road).get(1) s = session.query(Spot).get(1) ok_(not session.scalar(l.lake_geom.y)) ok_(not session.scalar(r.road_geom.y)) eq_(math.floor(session.scalar(s.spot_location.y)), 42.0) s = session.query(Spot).filter(and_(Spot.spot_location.y < 0, Spot.spot_location.y > 42)).all() ok_(s is not None) eq_(math.floor(session.scalar(functions.y('POINT(-88.3655256496815 43.1402866687898)'))), 43.0)
def test_y(self): s = session.query(Spot).filter(Spot.spot_height==420.40).one() eq_(session.scalar(s.spot_location.y), 42.9480095987261) s = session.query(Spot).filter(and_(Spot.spot_location.y < 0, Spot.spot_location.y > 42)).all() ok_(s is not None) eq_(session.scalar(functions.y('POINT(-88.3655256496815 43.1402866687898)')), 43.1402866687898)