Beispiel #1
0
    def test_empty(self):
        types = [
            'Point',
            'LineString',
            'Polygon',
            'MultiPoint',
            'MultiLineString',
            'MultiPolygon',
        ]
        coords = [
            [],
            [[]],
            [[[]]],
            [[]],
            [[[]]],
            [[[[]]]],
        ]
        for t, c in zip(types, coords):
            geom = dict(type=t, coordinates=c)
            with self.assertRaises(ValueError):
                wkb.dumps(geom)

        gc = dict(type='GeometryCollection', geometries=[])
        with self.assertRaises(ValueError):
            wkb.dumps(gc)
Beispiel #2
0
def register_danger(request):  # 한 : [미완성] 위험물 등록 폼
    g = geocoder.ip('me')
    danger_loc = g.latlng
    print(
        "0000000000000000000000000000000000000000000000000000000000000000000000000000"
    )

    if request.method == "POST":
        post_danger_type = request.POST['danger_type']
        #post_danger_img = request.POST['danger_img']
        post_danger_img = request.POST.get('danger_img', False)

        print(post_danger_type)
        print(post_danger_img)
        print(danger_loc)  # 한 : 현재 위치
        '''

        '''
        print("111111")

        danger_loc_point = Point(danger_loc[0], danger_loc[1])
        d = {"type": "Point", "coordinates": danger_loc}
        print(wkb.dumps(d))
        model_test_instance = Danger(danger_type=post_danger_type,
                                     danger_img=post_danger_img,
                                     danger_loc=wkb.dumps(d))
        model_test_instance.save()

    else:
        print('\n' + 'else 문 else else else')

    return render(request, 'register_danger.html', {'g': g.latlng})
Beispiel #3
0
    def test_empty(self):
        types = [
            'Point',
            'LineString',
            'Polygon',
            'MultiPoint',
            'MultiLineString',
            'MultiPolygon',
        ]
        coords = [
            [],
            [[]],
            [[[]]],
            [[]],
            [[[]]],
            [[[[]]]],
        ]
        for t, c in zip(types, coords):
            geom = dict(type=t, coordinates=c)
            with self.assertRaises(ValueError):
                wkb.dumps(geom)

        gc = dict(type='GeometryCollection', geometries=[])
        with self.assertRaises(ValueError):
            wkb.dumps(gc)
Beispiel #4
0
def encode_as_wkb(geo_json: dict, big_endian=True) -> bytes:
    """
    Convert the given GeoJSON to WKB.

    :param geo_json: the GeoJSON data to convert.
    :param big_endian: endianness, defaults to big endian.
    :return: the corresponding WKB bytes.
    """
    return wkb.dumps(geo_json, big_endian)
Beispiel #5
0
    def test_2d(self):
        # Tests a typical 2D Point case:
        pt = dict(type='Point', coordinates=[0.0, 1.0])

        expected = (b'\x01'  # little endian
                    b'\x01\x00\x00\x00'  # type
                    b'\x00\x00\x00\x00\x00\x00\x00\x00'
                    b'\x00\x00\x00\x00\x00\x00\xf0?')

        self.assertEqual(expected, wkb.dumps(pt, big_endian=False))
Beispiel #6
0
    def test_serialize_4d_wkb(self):
        from c2corg_api.ext.colander_ext import Geometry
        geom_schema = Geometry()

        wkb = geomet_wkb.dumps(
            {'type': 'Point', 'coordinates': [1.0, 2.0, 3.0, 4.0]},
            big_endian=False)
        self.assertEquals(
            {"type": "Point", "coordinates": [1.0, 2.0, 3.0, 4.0]},
            json.loads(geom_schema.serialize({}, from_wkb(wkb))))
Beispiel #7
0
 def test_2d(self):
     # Tests a typical 2D Point case:
     pt = dict(type='Point', coordinates=[0.0, 1.0])
     expected = EXP_WKB_FMT
     expected %= dict(
         endian='\x01',
         type='\x01\x00\x00\x00',
         data=('\x00\x00\x00\x00\x00\x00\x00\x00'
               '\x00\x00\x00\x00\x00\x00\xf0?'),
     )
     self.assertEqual(expected, wkb.dumps(pt, big_endian=False))
Beispiel #8
0
    def test_deserialize_4d(self):
        from c2corg_api.ext.colander_ext import Geometry
        geom_schema = Geometry()

        expected_wkb = from_wkb(geomet_wkb.dumps(
            {'type': 'Point', 'coordinates': [1.0, 2.0, 3.0, 4.0]},
            big_endian=False))

        wkb = geom_schema.deserialize(
            {}, '{"type": "Point", "coordinates": [1.0, 2.0, 3.0, 4.0]}')
        self.assertEquals(expected_wkb.desc, wkb.desc)
Beispiel #9
0
    def test_2d(self):
        # Tests a typical 2D Point case:
        pt = dict(type='Point', coordinates=[0.0, 1.0])

        expected = (
            b'\x01'  # little endian
            b'\x01\x00\x00\x00'  # type
            b'\x00\x00\x00\x00\x00\x00\x00\x00'
            b'\x00\x00\x00\x00\x00\x00\xf0?')

        self.assertEqual(expected, wkb.dumps(pt, big_endian=False))
Beispiel #10
0
    def test_4d(self):
        # Test for an XYZM Point:
        pt = dict(type='Point', coordinates=[0.0, 1.0, 2.0, 4.0])

        expected = (b'\x01'  # little endian
                    b'\x01\x30\x00\x00'  # type
                    b'\x00\x00\x00\x00\x00\x00\x00\x00'
                    b'\x00\x00\x00\x00\x00\x00\xf0?'
                    b'\x00\x00\x00\x00\x00\x00\x00@'
                    b'\x00\x00\x00\x00\x00\x00\x10@')

        self.assertEqual(expected, wkb.dumps(pt, big_endian=False))
Beispiel #11
0
 def _update(self):
     """updates the current row"""
     txts = []
     values = []
     for k, v in self._values.items():
         if k.lower() != "objectid" and \
            k.lower() != 'shape':
             txts.append("%s=?" % k)
             values.append(v)
         elif k.lower() == 'shape':
             if isinstance(v, dict) and "coordinates" not in v:
                 v = self._header + dumps(v, False)
             elif isinstance(v, dict) and "coordinates" in v:
                 v = self._gpheader + geometwkb.dumps(obj=v)
             elif isinstance(v, str):
                 gj = geometwkt.loads(v)
                 v = self._gpheader + geometwkb.dumps(obj=gj)
             elif isinstance(v, (bytes, bytearray)):
                 if isinstance(v, (bytearray)):
                     v = bytes(v)
                 if len(v) > 2 and \
                    v[:2] != b'GB':
                     v = self._gpheader + v
             elif v is None:
                 v = self._gpheader + b'0x000000000000f87f'
             else:
                 raise ValueError(
                     ("Shape column must be Esri JSON dictionary, "
                      "WKT, GeoJSON dictionary, or WKB (bytes)"))
             txts.append("%s=?" % k)
             values.append(v)
     sql = '''UPDATE {table} SET {values} WHERE OBJECTID={oid}'''.format(
         table=self._table_name,
         values=",".join(txts),
         oid=self._values['OBJECTID'])
     cur = self._con.execute(sql, values)
     self._con.commit()
     del sql
     del values, txts
     return True
Beispiel #12
0
    def test_2d(self):
        linestring = dict(type='LineString',
                          coordinates=[[2.2, 4.4], [3.1, 5.1]])
        expected = (
            b'\x00'  # big endian
            b'\x00\x00\x00\x02'  # type
            b'@\x01\x99\x99\x99\x99\x99\x9a'  # 2.2
            b'@\x11\x99\x99\x99\x99\x99\x9a'  # 4.4
            b'@\x08\xcc\xcc\xcc\xcc\xcc\xcd'  # 3.1
            b'@\x14ffffff'  # 5.1
        )

        self.assertEqual(expected, wkb.dumps(linestring))
Beispiel #13
0
    def test_4d(self):
        # Test for an XYZM Point:
        pt = dict(type='Point', coordinates=[0.0, 1.0, 2.0, 4.0])

        expected = (
            b'\x01'  # little endian
            b'\x01\x30\x00\x00'  # type
            b'\x00\x00\x00\x00\x00\x00\x00\x00'
            b'\x00\x00\x00\x00\x00\x00\xf0?'
            b'\x00\x00\x00\x00\x00\x00\x00@'
            b'\x00\x00\x00\x00\x00\x00\x10@')

        self.assertEqual(expected, wkb.dumps(pt, big_endian=False))
Beispiel #14
0
    def test_2d(self):
        linestring = dict(type='LineString', coordinates=[[2.2, 4.4],
                                                          [3.1, 5.1]])
        expected = (
            b'\x00'  # big endian
            b'\x00\x00\x00\x02'  # type
            b'@\x01\x99\x99\x99\x99\x99\x9a'  # 2.2
            b'@\x11\x99\x99\x99\x99\x99\x9a'  # 4.4
            b'@\x08\xcc\xcc\xcc\xcc\xcc\xcd'  # 3.1
            b'@\x14ffffff'                    # 5.1
        )

        self.assertEqual(expected, wkb.dumps(linestring))
Beispiel #15
0
    def test_3d(self):
        # Test for an XYZ Point:
        pt = dict(type='Point', coordinates=[0.0, 1.0, 2.0])
        # Note that a 3d point could either be a XYZ or XYM type.
        # For simplicity, we always assume XYZ.

        expected = (b'\x00'  # big endian
                    b'\x00\x00\x10\x01'  # type
                    b'\x00\x00\x00\x00\x00\x00\x00\x00'
                    b'?\xf0\x00\x00\x00\x00\x00\x00'
                    b'@\x00\x00\x00\x00\x00\x00\x00')

        self.assertEqual(expected, wkb.dumps(pt, big_endian=True))
Beispiel #16
0
    def test_serialize_4d_wkb(self):
        from c2corg_api.ext.colander_ext import Geometry
        geom_schema = Geometry()

        wkb = geomet_wkb.dumps(
            {
                'type': 'Point',
                'coordinates': [1.0, 2.0, 3.0, 4.0]
            },
            big_endian=False)
        self.assertEqual({
            "type": "Point",
            "coordinates": [1.0, 2.0, 3.0, 4.0]
        }, json.loads(geom_schema.serialize({}, from_wkb(wkb))))
Beispiel #17
0
    def test_3d(self):
        # Test for an XYZ Point:
        pt = dict(type='Point', coordinates=[0.0, 1.0, 2.0])
        # Note that a 3d point could either be a XYZ or XYM type.
        # For simplicity, we always assume XYZ.

        expected = (
            b'\x00'  # big endian
            b'\x00\x00\x10\x01'  # type
            b'\x00\x00\x00\x00\x00\x00\x00\x00'
            b'?\xf0\x00\x00\x00\x00\x00\x00'
            b'@\x00\x00\x00\x00\x00\x00\x00')

        self.assertEqual(expected, wkb.dumps(pt, big_endian=True))
Beispiel #18
0
    def test_deserialize_4d(self):
        from c2corg_api.ext.colander_ext import Geometry
        geom_schema = Geometry()

        expected_wkb = from_wkb(
            geomet_wkb.dumps(
                {
                    'type': 'Point',
                    'coordinates': [1.0, 2.0, 3.0, 4.0]
                },
                big_endian=False))

        wkb = geom_schema.deserialize(
            {}, '{"type": "Point", "coordinates": [1.0, 2.0, 3.0, 4.0]}')
        self.assertEqual(expected_wkb.desc, wkb.desc)
Beispiel #19
0
    def test_3d(self):
        linestring = dict(type='LineString',
                          coordinates=[[2.2, 4.4, 10.0], [3.1, 5.1, 20.0]])
        expected = (
            b'\x01'  # little endian
            b'\x02\x10\x00\x00'  # type
            b'\x9a\x99\x99\x99\x99\x99\x01@'  # 2.2
            b'\x9a\x99\x99\x99\x99\x99\x11@'  # 4.4
            b'\x00\x00\x00\x00\x00\x00$@'  # 10.0
            b'\xcd\xcc\xcc\xcc\xcc\xcc\x08@'  # 3.1
            b'ffffff\x14@'  # 5.1
            b'\x00\x00\x00\x00\x00\x004@'  # 20.0
        )

        self.assertEqual(expected, wkb.dumps(linestring, big_endian=False))
Beispiel #20
0
    def test_3d(self):
        linestring = dict(type='LineString', coordinates=[[2.2, 4.4, 10.0],
                                                          [3.1, 5.1, 20.0]])
        expected = (
            b'\x01'  # little endian
            b'\x02\x10\x00\x00'  # type
            b'\x9a\x99\x99\x99\x99\x99\x01@'  # 2.2
            b'\x9a\x99\x99\x99\x99\x99\x11@'  # 4.4
            b'\x00\x00\x00\x00\x00\x00$@'     # 10.0
            b'\xcd\xcc\xcc\xcc\xcc\xcc\x08@'  # 3.1
            b'ffffff\x14@'                    # 5.1
            b'\x00\x00\x00\x00\x00\x004@'     # 20.0
        )

        self.assertEqual(expected, wkb.dumps(linestring, big_endian=False))
Beispiel #21
0
 def test_2d(self):
     linestring = dict(type='LineString', coordinates=[[2.2, 4.4],
                                                       [3.1, 5.1]])
     data = (
         '@\x01\x99\x99\x99\x99\x99\x9a'  # 2.2
         '@\x11\x99\x99\x99\x99\x99\x9a'  # 4.4
         '@\x08\xcc\xcc\xcc\xcc\xcc\xcd'  # 3.1
         '@\x14ffffff'                    # 5.1
     )
     expected = EXP_WKB_FMT
     expected %= dict(
         endian='\x00',
         type='\x00\x00\x00\x02',
         data=data,
     )
     self.assertEqual(expected, wkb.dumps(linestring))
Beispiel #22
0
    def test_4d(self):
        # Test for an XYZM Point:
        pt = dict(type='Point', coordinates=[0.0, 1.0, 2.0, 4.0])

        data = ('\x00\x00\x00\x00\x00\x00\x00\x00'
                '\x00\x00\x00\x00\x00\x00\xf0?'
                '\x00\x00\x00\x00\x00\x00\x00@'
                '\x00\x00\x00\x00\x00\x00\x10@')

        expected = EXP_WKB_FMT
        expected %= dict(
            endian='\x01',
            type='\x01\x30\x00\x00',
            data=data,
        )
        self.assertEqual(expected, wkb.dumps(pt, big_endian=False))
Beispiel #23
0
    def test_3d(self):
        # Test for an XYZ Point:
        pt = dict(type='Point', coordinates=[0.0, 1.0, 2.0])
        # Note that a 3d point could either be a XYZ or XYM type.
        # For simplicity, we always assume XYZ.

        data = ('\x00\x00\x00\x00\x00\x00\x00\x00'
                '?\xf0\x00\x00\x00\x00\x00\x00'
                '@\x00\x00\x00\x00\x00\x00\x00')

        expected = EXP_WKB_FMT
        expected %= dict(
            endian='\x00',
            type='\x00\x00\x10\x01',
            data=data,
        )
        self.assertEqual(expected, wkb.dumps(pt, big_endian=True))
Beispiel #24
0
 def test_3d(self):
     linestring = dict(type='LineString', coordinates=[[2.2, 4.4, 10.0],
                                                       [3.1, 5.1, 20.0]])
     data = (
         '\x9a\x99\x99\x99\x99\x99\x01@'  # 2.2
         '\x9a\x99\x99\x99\x99\x99\x11@'  # 4.4
         '\x00\x00\x00\x00\x00\x00$@'     # 10.0
         '\xcd\xcc\xcc\xcc\xcc\xcc\x08@'  # 3.1
         'ffffff\x14@'                    # 5.1
         '\x00\x00\x00\x00\x00\x004@'     # 20.0
     )
     expected = EXP_WKB_FMT
     expected %= dict(
         endian='\x01',
         type='\x02\x10\x00\x00',
         data=data
     )
     self.assertEqual(expected, wkb.dumps(linestring, big_endian=False))
Beispiel #25
0
    def test_4d(self):
        linestring = dict(type='LineString',
                          coordinates=[[2.2, -4.4, -10.0, 0.1],
                                       [-3.1, 5.1, 20.0, -0.9]])

        expected = (
            b'\x00'  # big endian
            b'\x00\x00\x30\x02'  # type
            b'@\x01\x99\x99\x99\x99\x99\x9a'     # 2.2
            b'\xc0\x11\x99\x99\x99\x99\x99\x9a'  # -4.4
            b'\xc0$\x00\x00\x00\x00\x00\x00'     # -10.0
            b'?\xb9\x99\x99\x99\x99\x99\x9a'     # 0.1
            b'\xc0\x08\xcc\xcc\xcc\xcc\xcc\xcd'  # -3.1
            b'@\x14ffffff'                       # 5.1
            b'@4\x00\x00\x00\x00\x00\x00'        # 20.0
            b'\xbf\xec\xcc\xcc\xcc\xcc\xcc\xcd'  # -0.9
        )

        self.assertEqual(expected, wkb.dumps(linestring))
Beispiel #26
0
    def test_4d(self):
        linestring = dict(type='LineString',
                          coordinates=[[2.2, -4.4, -10.0, 0.1],
                                       [-3.1, 5.1, 20.0, -0.9]])

        expected = (
            b'\x00'  # big endian
            b'\x00\x00\x30\x02'  # type
            b'@\x01\x99\x99\x99\x99\x99\x9a'  # 2.2
            b'\xc0\x11\x99\x99\x99\x99\x99\x9a'  # -4.4
            b'\xc0$\x00\x00\x00\x00\x00\x00'  # -10.0
            b'?\xb9\x99\x99\x99\x99\x99\x9a'  # 0.1
            b'\xc0\x08\xcc\xcc\xcc\xcc\xcc\xcd'  # -3.1
            b'@\x14ffffff'  # 5.1
            b'@4\x00\x00\x00\x00\x00\x00'  # 20.0
            b'\xbf\xec\xcc\xcc\xcc\xcc\xcc\xcd'  # -0.9
        )

        self.assertEqual(expected, wkb.dumps(linestring))
Beispiel #27
0
def translate(text, output_format='json', indent=None, precision=-1):
    if text.startswith('{'):
        geom = json.loads(text)
    elif text.startswith(('G', 'L', 'M', 'P')):
        geom = wkt.loads(text)
    else:
        geom = wkb.loads(a2b_hex(text))
    if output_format == 'wkb':
        output = b2a_hex(wkb.dumps(geom))
    elif output_format == 'wkt':
        kwds = {}
        if precision >= 0:
            kwds['decimals'] = precision
        output = wkt.dumps(geom, **kwds)
    else:
        if precision >= 0:
            geom = util.round_geom(geom, precision)
        output = json.dumps(geom, indent=indent, sort_keys=True)
    return output
def insert_buildings(geojsonObj):  # reference: predict.py
    if not geojsonObj:
        return False

    # geojson to buildings array
    buildings = []
    for feature in geojsonObj["features"]:
        geometry = feature['geometry']
        newBuild = PredictBuildings()
        newBuild.task_id = feature["properties"]['task_id']
        newBuild.extent = feature["properties"]['extent']
        newBuild.user_id = feature["properties"]['user_id']
        newBuild.area_code = feature["properties"]['area_code']
        # newBuild.handler = feature["properties"]['handler']
        newBuild.geom = wkb.dumps(geometry).hex()
        buildings.append(newBuild)

    # insert into
    with DB.auto_commit():
        DB.session.bulk_save_objects(buildings)
        return True
Beispiel #29
0
    def test_4d(self):
        linestring = dict(type='LineString',
                          coordinates=[[2.2, -4.4, -10.0, 0.1],
                                       [-3.1, 5.1, 20.0, -0.9]])

        data = (
            '@\x01\x99\x99\x99\x99\x99\x9a'     # 2.2
            '\xc0\x11\x99\x99\x99\x99\x99\x9a'  # -4.4
            '\xc0$\x00\x00\x00\x00\x00\x00'     # -10.0
            '?\xb9\x99\x99\x99\x99\x99\x9a'     # 0.1
            '\xc0\x08\xcc\xcc\xcc\xcc\xcc\xcd'  # -3.1
            '@\x14ffffff'                       # 5.1
            '@4\x00\x00\x00\x00\x00\x00'        # 20.0
            '\xbf\xec\xcc\xcc\xcc\xcc\xcc\xcd'  # -0.9
        )
        expected = EXP_WKB_FMT
        expected %= dict(
            endian='\x00',
            type='\x00\x00\x30\x02',
            data=data,
        )
        self.assertEqual(expected, wkb.dumps(linestring))
Beispiel #30
0
def wkbelement_from_geojson(geojson, srid):
    geometry = wkb.dumps(geojson, big_endian=False)
    return from_wkb(geometry, srid)
Beispiel #31
0
 def test_dumps_3d(self):
     self.assertEqual(self.multipoint3d_wkb,
                      wkb.dumps(self.multipoint3d, big_endian=False))
Beispiel #32
0
 def test_dumps_4d(self):
     self.assertEqual(self.poly4d_wkb, wkb.dumps(self.poly4d))
Beispiel #33
0
 def test_dumps_4d(self):
     self.assertEqual(self.poly4d_wkb, wkb.dumps(self.poly4d))
Beispiel #34
0
 def test_dumps_2d(self):
     self.assertEqual(
         self.multipoint2d_wkb,
         wkb.dumps(self.multipoint2d, big_endian=False)
     )
Beispiel #35
0
 def test_dumps_3d(self):
     self.assertEqual(self.pt3d_wkb, wkb.dumps(self.pt3d))
Beispiel #36
0
 def test_unsupported_geom_type(self):
     geom = dict(type='Tetrahedron', coordinates=[])
     with self.assertRaises(ValueError) as ar:
         wkb.dumps(geom)
     self.assertEqual("Unsupported geometry type 'Tetrahedron'",
                      str(ar.exception))
Beispiel #37
0
    def insert(self, row, geom_format='EsriJSON'):
        """
        Inserts a new row via dictionary

        ===============     ===============================================
        **Arguements**      **Description**
        ---------------     -----------------------------------------------
        row                 Required Dictionary.  Insert a new row via a
                            dictionary. The key/value pair must match up to
                            the field names in the table.
        ---------------     -----------------------------------------------
        geom_format         Optional String. When providing geometries
                            during insertion of new records, the method
                            needs to know the format of the geometry. The
                            formats supported values are: EsriJSON,
                            GeoJSON, WKT, and WKB.

                            The default geometry format is`EsriJSON`.

                            **Note**

                            GeoJSON and WKT require the package `geomet` to
                            be installed.

        ==============      ===============================================

        :returns: Boolean

        """
        if _HASGEOMET == False and geom_format.lower() in ['wkt', 'geojson']:
            raise ValueError(
                ("The package `geomet` is required to work with "
                 "WKT and GeoJSON. Run `pip install geomet` to install."))
        if isinstance(row, _Row):
            row = row._values
        values = None
        flds = {fld.lower(): fld for fld in row.keys()}
        if 'shape' in flds:
            if isinstance(row[flds['shape']],
                          dict) and geom_format.lower() == "esrijson":
                row[flds['shape']] = self._gpheader + dumps(
                    row[flds['shape']], False)
            elif isinstance(row[flds['shape']],
                            dict) and geom_format.lower() == "geojson":
                row[flds['shape']] = self._gpheader + geometwkb.dumps(
                    obj=row[flds['shape']])
            elif isinstance(row[flds['shape']],
                            str) and geom_format.lower() == "wkt":
                gj = geometwkt.loads(row[flds['shape']])
                row[flds['shape']] = self._gpheader + geometwkb.dumps(obj=gj)
            elif isinstance(row[flds['shape']], (bytes, bytearray)):
                if isinstance(row[flds['shape']], (bytearray)):
                    row[flds['shape']] = bytes(row[flds['shape']])
                if len(row[flds['shape']]) > 2 and \
                   row[flds['shape']][:2] != b'GB':
                    row[flds['shape']] = self._gpheader + row[flds['shape']]
            elif row[flds['shape']] is None:
                row[flds['shape']] = self._gpheader + b'0x000000000000f87f'
            else:
                raise ValueError(("Shape column must be Esri JSON dictionary, "
                                  "WKT, GeoJSON dictionary, or WKB (bytes)"))
        if isinstance(row, dict):
            keys = row.keys()
            values = [list(row.values())]
        elif isinstance(row, (list, tuple)):
            keys = row[0].keys()
            values = [list(r.values()) for r in row]
        q = ["?"] * len(keys)
        q = ",".join(q)
        sql = '''INSERT INTO {table} ({fields})
                     VALUES({q})'''.format(table=self._table_name,
                                           fields=",".join(keys),
                                           q=q)
        inserts = []
        cur = self._con.cursor()
        cur.execute(sql, list(values[0]))
        self._con.commit()
        return True
Beispiel #38
0
 def test_dumps_3d(self):
     self.assertEqual(self.mpoly3d_wkb,
                      wkb.dumps(self.mpoly3d, big_endian=False))
Beispiel #39
0
 def bin_encode(self, value):
     return wkb.dumps(self.json_encode(value))
Beispiel #40
0
 def test_dumps_2d(self):
     self.assertEqual(self.pt2d_wkb, wkb.dumps(self.pt2d, big_endian=False))
Beispiel #41
0
 def wkb(self):
     return wkb.dumps(self["geometry"])
Beispiel #42
0
 def test_dumps_4d(self):
     self.assertEqual(self.pt4d_wkb, wkb.dumps(self.pt4d, big_endian=False))
Beispiel #43
0
 def test_dumps_4d(self):
     self.assertEqual(self.mpoly4d_wkb,
                      wkb.dumps(self.mpoly4d, big_endian=False))
Beispiel #44
0
 def test_dumps_3d(self):
     self.assertEqual(self.pt3d_wkb, wkb.dumps(self.pt3d))
Beispiel #45
0
def wkbelement_from_geojson(geojson, srid):
    geometry = wkb.dumps(json.loads(geojson), big_endian=False)
    return from_wkb(geometry, srid)
Beispiel #46
0
 def ewkb(self):
     return wkb.dumps(ChainMap(cached_crs(self.__srid), self["geometry"]))
Beispiel #47
0
 def test_dumps_2d(self):
     self.assertEqual(self.mls2d_wkb, wkb.dumps(self.mls2d))
Beispiel #48
0
 def test_unsupported_geom_type(self):
     geom = dict(type='Tetrahedron', coordinates=[])
     with self.assertRaises(ValueError) as ar:
         wkb.dumps(geom)
     self.assertEqual("Unsupported geometry type 'Tetrahedron'",
                      ar.exception.message)
Beispiel #49
0
 def test_dumps_2d(self):
     self.assertEqual(self.mls2d_wkb, wkb.dumps(self.mls2d))