Пример #1
0
    def test_deserialize_valid_geojson(self):
        from c2cgeoform.ext.colander_ext import Geometry
        geom_schema = Geometry()

        from shapely.geometry.point import Point
        expected_wkb = WKBElement(Point(1.0, 2.0).wkb)

        wkb = geom_schema.deserialize(
            {}, '{"type": "Point", "coordinates": [1.0, 2.0]}')
        self.assertEquals(expected_wkb.desc, wkb.desc)
Пример #2
0
    def test_deserialize_valid_geojson(self):
        from c2cgeoform.ext.colander_ext import Geometry
        geom_schema = Geometry()

        from shapely.geometry.point import Point
        expected_wkb = WKBElement(Point(1.0, 2.0).wkb)

        wkb = geom_schema.deserialize(
            {}, '{"type": "Point", "coordinates": [1.0, 2.0]}')
        self.assertEquals(expected_wkb.desc, wkb.desc)
Пример #3
0
    def test_deserialize_reproject(self):
        from c2cgeoform.ext.colander_ext import Geometry
        geom_schema = Geometry(srid=4326, map_srid=3857)

        wkb = geom_schema.deserialize(
            {}, '{"type": "Point", '
            '"coordinates": [111319.49079327231, 222684.20850554455]}')
        self.assertEquals(4326, wkb.srid)

        shape = to_shape(wkb)
        self.assertAlmostEqual(1.0, shape.x)
        self.assertAlmostEqual(2.0, shape.y)
Пример #4
0
    def test_deserialize_reproject(self):
        from c2cgeoform.ext.colander_ext import Geometry
        geom_schema = Geometry(srid=4326, map_srid=3857)

        wkb = geom_schema.deserialize(
            {},
            '{"type": "Point", '
            '"coordinates": [111319.49079327231, 222684.20850554455]}')
        self.assertEquals(4326, wkb.srid)

        shape = to_shape(wkb)
        self.assertAlmostEqual(1.0, shape.x)
        self.assertAlmostEqual(2.0, shape.y)
Пример #5
0
    def test_deserialize_null(self):
        from c2cgeoform.ext.colander_ext import Geometry
        geom_schema = Geometry()

        self.assertEquals(null, geom_schema.deserialize({}, null))
        self.assertEquals(null, geom_schema.deserialize({}, ''))
Пример #6
0
    def test_deserialize_null(self):
        from c2cgeoform.ext.colander_ext import Geometry
        geom_schema = Geometry()

        self.assertEquals(null, geom_schema.deserialize({}, null))
        self.assertEquals(null, geom_schema.deserialize({}, ''))