Пример #1
0
    def test_render_reproject(self):
        session = FakeSession()
        spot_fieldset = FieldSet(Spot, session=session)
        spot_fieldset.the_geom.set(options=[('map_srid', 900913)])

        spot = Spot()
        spot.id = 1
        spot.the_geom = PersistentSpatialElement(PersistentSpatialElement(WKBSpatialElement('010')));

        spot_fieldset = spot_fieldset.bind(spot)

        spot_fieldset.render()
        ok_(isinstance(session.scalar_args[0], functions.wkt), 'The geometry was not queried as WKT');
        ok_(isinstance(session.scalar_args[0].arguments[0], functions.transform), 'The geometry was not reprojected');
Пример #2
0
    def test_render(self):
        session = FakeSession()
        spot_fieldset = FieldSet(Spot, session=session)

        spot = Spot()
        spot.id = 1
        spot.the_geom = PersistentSpatialElement(PersistentSpatialElement(WKBSpatialElement('010')));

        spot_fieldset = spot_fieldset.bind(spot)

        form = spot_fieldset.render()

        ok_("geoformalchemy.init_map(" in form, 'Template was not rendered')
        ok_("'Point'," in form, 'OpenLayers geometry was not mapped correctly ')
        ok_("false," in form, 'Geometry should not be a collection')
        ok_(isinstance(session.scalar_args[0], functions.wkt), 'The geometry was not queried as WKT');
Пример #3
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))
Пример #4
0
 def __getattr__(self, name):
     try:
         return PersistentSpatialElement.__getattr__(self, name)
     except AttributeError:
         return getattr(ms_functions, name)(self)
Пример #5
0
 def __getattr__(self, name):
     try:
         return PersistentSpatialElement.__getattr__(self, name)
     except AttributeError:
         return getattr(oracle_functions, name)(self)