How to use the geojson.utils.map_coords 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_coords.py View on Github external
def test_map_multipolygon(self):
        g = geojson.MultiPolygon([
            ([(3.78, 9.28), (-130.91, 1.52), (35.12, 72.234), (3.78, 9.28)],),
            ([(23.18, -34.29), (-1.31, -4.61),
              (3.41, 77.91), (23.18, -34.29)],)])
        result = map_coords(lambda x: x, g)
        self.assertEqual(result['type'], 'MultiPolygon')
        self.assertEqual(result['coordinates'][0][0][0], (3.78, 9.28))
        self.assertEqual(result['coordinates'][-1][-1][-1], (23.18, -34.29))
github jazzband / geojson / tests / test_coords.py View on Github external
def test_map_linestring(self):
        g = geojson.LineString(
            [(3.78, 9.28), (-130.91, 1.52), (35.12, 72.234), (3.78, 9.28)])
        result = map_coords(lambda x: x, g)
        self.assertEqual(result['type'], 'LineString')
        self.assertEqual(result['coordinates'][0], (3.78, 9.28))
        self.assertEqual(result['coordinates'][-1], (3.78, 9.28))
github jazzband / geojson / tests / test_coords.py View on Github external
def test_map_polygon(self):
        g = geojson.Polygon([
            [(3.78, 9.28), (-130.91, 1.52), (35.12, 72.234), (3.78, 9.28)], ])
        result = map_coords(lambda x: x, g)
        self.assertEqual(result['type'], 'Polygon')
        self.assertEqual(result['coordinates'][0][0], (3.78, 9.28))
        self.assertEqual(result['coordinates'][0][-1], (3.78, 9.28))
github jazzband / geojson / tests / test_coords.py View on Github external
def test_map_feature(self):
        g = geojson.Feature(
            id='123',
            geometry=geojson.Point([-115.81, 37.24])
        )
        result = map_coords(lambda x: x, g)
        self.assertEqual(result['type'], 'Feature')
        self.assertEqual(result['id'], '123')
        self.assertEqual(result['geometry']['coordinates'], (-115.81, 37.24))
github jazzband / geojson / tests / test_coords.py View on Github external
def test_map_invalid(self):
        with self.assertRaises(ValueError):
            map_coords(lambda x: x, {"type": ""})
github bukun / book_python_gis / part010 / ch09_others / sec2_geojson / test_3_geojson_function_x_x.py View on Github external
    @property
    def __geo_interface__(self):
        return {'type': 'Point',
                'coordinates': (self.x, self.y)}

point_instance = MyPoint(52.235, -19.234)
geojson.dumps(point_instance, sort_keys=True)
###############################################################################
import geojson
my_line = geojson.LineString([(-152.62, 51.21),
    (5.21, 10.69)])
my_feature = geojson.Feature(geometry=my_line)
list(geojson.utils.coords(my_feature))
###############################################################################
import geojson
new_point = geojson.utils.map_coords(lambda x: x/2,
    geojson.Point((-115.81, 37.24)))
geojson.dumps(new_point, sort_keys=True)
###############################################################################
import geojson
geojson.utils.generate_random("LineString")
github jazzband / geojson / tests / test_coords.py View on Github external
def test_map_point(self):
        result = map_coords(lambda x: x, geojson.Point((-115.81, 37.24)))
        self.assertEqual(result['type'], 'Point')
        self.assertEqual(result['coordinates'], (-115.81, 37.24))
github jazzband / geojson / geojson / __init__.py View on Github external
from geojson.codec import dump, dumps, load, loads, GeoJSONEncoder
from geojson.utils import coords, map_coords
from geojson.geometry import Point, LineString, Polygon
from geojson.geometry import MultiLineString, MultiPoint, MultiPolygon
from geojson.geometry import GeometryCollection
from geojson.feature import Feature, FeatureCollection
from geojson.base import GeoJSON
from geojson._version import __version__, __version_info__

__all__ = ([dump, dumps, load, loads, GeoJSONEncoder] +
           [coords, map_coords] +
           [Point, LineString, Polygon] +
           [MultiLineString, MultiPoint, MultiPolygon] +
           [GeometryCollection] +
           [Feature, FeatureCollection] +
           [GeoJSON] +
           [__version__, __version_info__])