How to use the geojson.MultiPoint function in geojson

To help you get started, we’ve selected a few geojson examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jazzband / geojson / tests / test_constructor.py View on Github external
def test_nested_constructors(self):
        a = [5, 6]
        b = [9, 10]
        c = [-5, 12]
        mp = geojson.MultiPoint([geojson.Point(a), b])
        self.assertEquals(mp.coordinates, [a, b])

        mls = geojson.MultiLineString([geojson.LineString([a, b]), [a, c]])
        self.assertEquals(mls.coordinates, [[a, b], [a, c]])

        outer = [a, b, c, a]
        poly = geojson.Polygon(geojson.MultiPoint(outer))
        other = [[1, 1], [1, 2], [2, 1], [1, 1]]
        poly2 = geojson.Polygon([outer, other])
        self.assertEquals(geojson.MultiPolygon([poly, poly2]).coordinates,
                          [[outer], [outer, other]])
github jazzband / geojson / tests / test_validation.py View on Github external
def test_valid_multipoint(self):
        mpoint = geojson.MultiPoint([(10, 20), (30, 40)])
        self.assertEqual(mpoint.is_valid, True)
github jazzband / geojson / tests / test_constructor.py View on Github external
def test_nested_constructors(self):
        a = [5, 6]
        b = [9, 10]
        c = [-5, 12]
        mp = geojson.MultiPoint([geojson.Point(a), b])
        self.assertEquals(mp.coordinates, [a, b])

        mls = geojson.MultiLineString([geojson.LineString([a, b]), [a, c]])
        self.assertEquals(mls.coordinates, [[a, b], [a, c]])

        outer = [a, b, c, a]
        poly = geojson.Polygon(geojson.MultiPoint(outer))
        other = [[1, 1], [1, 2], [2, 1], [1, 1]]
        poly2 = geojson.Polygon([outer, other])
        self.assertEquals(geojson.MultiPolygon([poly, poly2]).coordinates,
                          [[outer], [outer, other]])
github SuperMap / iclient-python / iclientpy / iclientpy / data / featuresconverter.py View on Github external
def __to_geojson_point(s_geo: icp_model.Geometry):
    coordinates = []
    for point in s_geo.points:
        coordinates.append([point.x, point.y])
    if len(coordinates) == 1:
        geo = geojson.Point(coordinates=coordinates[0])
    else:
        geo = geojson.MultiPoint(coordinates=coordinates)
    return geo
github jazzband / geojson / geojson / validation.py View on Github external
{valid: 'no', message:'explanation, why this object is not valid'}

        Example:
            >> point = Point((10,20), (30,40))
            >> IsValid(point)
            >> {valid: 'yes', message: ''}
    """

    if not isinstance(obj, geojson.GeoJSON):
        return output('this is not GeoJSON object')

    if isinstance(obj, geojson.Point):
        if len(obj['coordinates']) not in (2, 3):
            return output('the "coordinates" member must be a single position')

    if isinstance(obj, geojson.MultiPoint):
        if checkListOfObjects(obj['coordinates'], lambda x: len(x) in (2, 3)):
            return output(
                'the "coordinates" member must be an array of positions'
            )

    if isinstance(obj, geojson.LineString):
        if len(obj['coordinates']) < 2:
            return output('the "coordinates" member must be an array '
                          'of two or more positions')

    if isinstance(obj, geojson.MultiLineString):
        coord = obj['coordinates']
        if checkListOfObjects(coord, lambda x: len(x) >= 2):
            return output('the "coordinates" member must be an array '
                          'of LineString coordinate arrays')
github csparpa / pyowm / pyowm / utils / geo.py View on Github external
def __init__(self, list_of_tuples):
        if not list_of_tuples:
            raise ValueError("A MultiPoint cannot be empty")
        for t in list_of_tuples:
            assert_is_lon(t[0])
            assert_is_lat(t[1])
        self._geom = geojson.MultiPoint(list_of_tuples)
github geoadmin / mf-chsdi3 / chsdi / esrigeojsonencoder.py View on Github external
ret['x'], ret['y'] = coordinates
                ret['type'] = 'esriGeometryPoint'

                return self._cleanup(ret)

            if isinstance(obj, geojson.geometry.LineString):
                ret = dict(obj)

                path = coordinates
                ret['paths'] = [[xy for xy in path]]
                ret['type'] = 'esriGeometryPolyline'
                ret = self._hasZ(xy, ret)

                return self._cleanup(ret)

            if isinstance(obj, (geojson.MultiPoint)):
                ret = dict(obj)
                points = [xy for xy in coordinates]
                ret['points'] = points
                ret['type'] = 'esriGeometryMultipoint'
                ret = self._hasZ(xy, ret)

                return self._cleanup(ret)

            if isinstance(obj, geojson.MultiLineString):
                ret = dict(obj)

                paths = coordinates
                ret['paths'] = [[xy for xy in p] for p in paths]
                ret['type'] = 'esriGeometryPolyline'
                ret = self._hasZ(xy, ret)