Exemplo n.º 1
0
 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))",
     )
Exemplo n.º 2
0
 def test_x(self):
     s = session.query(Spot).get(1)
     assert_almost_equal(float(session.scalar(s.spot_location.x)), -88.594586159235689)
     s = session.query(Spot).filter(and_(Spot.spot_location.x < 0, Spot.spot_location.y > 42)).all()
     ok_(s is not None)
     assert_almost_equal(float(session.scalar(functions.x(WKTSpatialElement('POINT(-88.3655256496815 43.1402866687898)', geometry_type=Point.name)))),
                         -88.3655256496815)
Exemplo n.º 3
0
 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))')
Exemplo n.º 4
0
 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))')
Exemplo n.º 5
0
 def test_x(self):
     s = session.query(Spot).filter(Spot.spot_height == 420.40).one()
     eq_(session.scalar(s.spot_location.x), -88.5945861592357)
     s = session.query(Spot).filter(
         and_(Spot.spot_location.x < 0, Spot.spot_location.y > 42)).all()
     ok_(s is not None)
     eq_(
         session.scalar(
             functions.x('POINT(-88.3655256496815 43.1402866687898)')),
         -88.3655256496815)
Exemplo n.º 6
0
 def test_x(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.x))
     ok_( not session.scalar(r.road_geom.x))
     eq_(session.scalar(s.spot_location.x), -88.594586159236002)
     s = session.query(Spot).filter(and_(Spot.spot_location.x < 0, Spot.spot_location.y > 42)).all()
     ok_(s is not None)
     eq_(session.scalar(functions.x('POINT(-88.3655256496815 43.1402866687898)')), -88.365525649681999)
Exemplo n.º 7
0
 def test_x(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.x))
     ok_( not session.scalar(r.road_geom.x))
     print session.scalar(s.spot_location.x)
     eq_(math.ceil(session.scalar(s.spot_location.x)), -88.0)
     s = session.query(Spot).filter(and_(Spot.spot_location.x < 0, Spot.spot_location.y > 42)).all()
     ok_(s is not None)
     eq_(math.ceil(session.scalar(functions.x('POINT(-88.3655256496815 43.1402866687898)'))), -88.0)
Exemplo n.º 8
0
 def test_x(self):
     s = session.query(Spot).filter(Spot.spot_height==420.40).one()
     eq_(session.scalar(s.spot_location.x), -88.5945861592357)
     s = session.query(Spot).filter(and_(Spot.spot_location.x < 0, Spot.spot_location.y > 42)).all()
     ok_(s is not None)
     eq_(session.scalar(functions.x('POINT(-88.3655256496815 43.1402866687898)')), -88.3655256496815)