def test_wkb(self): print session.scalar(functions.wkt(self.r.road_geom.wkb)) eq_(session.scalar(functions.wkt(func.GeomFromWKB(self.r.road_geom.wkb, 4326))), u'LINESTRING(-88.6748409363057 43.1035032292994,-88.6464173694267 42.9981688343949,-88.607961955414 42.9680732929936,-88.5160033566879 42.9363057770701,-88.4390925286624 43.0031847579618)') eq_(session.scalar(self.r.road_geom.wkb), self.r.road_geom.geom_wkb) ok_(not session.query(Spot).filter(Spot.spot_location.wkb == '101').first()) centroid_geom = DBSpatialElement(session.scalar(self.r.road_geom.centroid)) eq_(session.scalar(functions.wkt(func.GeomFromWKB(centroid_geom.wkb, 4326))), u'POINT(-88.5769371859941 42.9915634871979)')
def test_wkb(self): eq_( session.scalar( functions.wkt(func.GeomFromWKB(self.r.road_geom.wkb, 4326))), 'LINESTRING(-88.674841 43.103503, -88.646417 42.998169, -88.607962 42.968073, -88.516003 42.936306, -88.439093 43.003185)' ) eq_(session.scalar(self.r.road_geom.wkb), self.r.road_geom.geom_wkb) centroid_geom = DBSpatialElement( session.scalar(self.r.road_geom.centroid)) eq_( session.scalar( functions.wkt(func.GeomFromWKB(centroid_geom.wkb, 4326))), 'POINT(-88.576937 42.991563)')
def test_persistent(self): eq_(session.scalar(functions.wkt(func.GeomFromWKB(self.r.road_geom.wkb, 4326))), u'LINESTRING(-88.6748409363057 43.1035032292994,-88.6464173694267 42.9981688343949,-88.607961955414 42.9680732929936,-88.5160033566879 42.9363057770701,-88.4390925286624 43.0031847579618)') geom = WKTSpatialElement('POINT(30250865.9714116 -610981.481754275)', 2249) spot = Spot(spot_height=102.34, spot_location=geom) session.add(spot) session.commit(); assert_almost_equal(session.scalar(spot.spot_location.x), 0) assert_almost_equal(session.scalar(spot.spot_location.y), 0)
def test_persistent(self): eq_( session.scalar( functions.wkt(func.GeomFromWKB(self.r.road_geom.wkb, 4326))), 'LINESTRING(-88.674841 43.103503, -88.646417 42.998169, -88.607962 42.968073, -88.516003 42.936306, -88.439093 43.003185)' ) geom = WKTSpatialElement('POINT(30250865.9714116 -610981.481754275)', 2249) spot = Spot(spot_height=102.34, spot_location=geom) session.add(spot) session.commit() assert_almost_equal(session.scalar(spot.spot_location.x), 0) assert_almost_equal(session.scalar(spot.spot_location.y), 0) spot.spot_location = PersistentSpatialElement(None) ok_(isinstance(spot.spot_location, PersistentSpatialElement))