Exemplo n.º 1
0
 def loadFromJsonEntity(cls, json_entity):
     return GeometryCollection(*map(lambda x: GeoJSON.loadFromJsonEntity(x),
                                    json_entity["geometries"]))
Exemplo n.º 2
0
 def loadFromJsonEntity(cls, json_entity):
     return Feature(GeoJSON.loadFromJsonEntity(json_entity["geometry"]),
                    json_entity["properties"],
                    json_entity["id"] if "id" in json_entity else None)
 def test_it_saves_to_string(self):
     text = """{"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Point", "coordinates": [102.0, 0.5]}, "properties": {"foo": 42}}]}"""
     featurecollection = GeoJSON.loadFromString(text)
     savedtext = featurecollection.saveToString()
     self.assertEqual(text, savedtext)
Exemplo n.º 4
0
 def test_it_saves_to_string(self):
     text = """{"type": "LineString", "coordinates": [[101, 0.6], [102.0, 0.5]]}"""
     linestring = GeoJSON.loadFromString(text)
     savedtext = linestring.saveToString()
     self.assertEqual(text, savedtext)
 def test_it_saves_to_string(self):
     text = """{"type": "MultiPolygon", "coordinates": [[[[1, 2], [3, 4], [5, 6], [1, 2]]]]}"""
     multipolygon = GeoJSON.loadFromString(text)
     savedtext = multipolygon.saveToString()
     self.assertEqual(text, savedtext)
Exemplo n.º 6
0
 def test_it_saves_to_string(self):
     text = """{"type": "Point", "coordinates": [102.0, 0.5]}"""
     point = GeoJSON.loadFromString(text)
     savedtext = point.saveToString()
     self.assertEqual(text, savedtext)
Exemplo n.º 7
0
 def test_it_loads_geojson_object_from_string(self):
     text = """{"type": "Point", "coordinates": [102.0, 0.5]}"""
     point = GeoJSON.loadFromString(text)
     self.assertEqual(102.0, point.lat)
     self.assertEqual(0.5, point.lon)
Exemplo n.º 8
0
 def test_it_loads_geojson_object_from_string(self):
     text = """{"type": "MultiPoint", "coordinates": [[101, 0.6], [102.0, 0.5]]}"""
     multipoint = GeoJSON.loadFromString(text)
     self.assertEqual(102.0, multipoint.lat(1))
     self.assertEqual(0.6, multipoint.lon(0))
     self.assertEqual(2, len(multipoint))
Exemplo n.º 9
0
 def test_it_returns_point_instance(self):
     text = """{"type": "Point", "coordinates": [102.0, 0.5]}"""
     point = GeoJSON.loadFromString(text)
     self.assertEqual("Point", point.getType())
Exemplo n.º 10
0
 def test_it_saves_to_string(self):
     text = """{"type": "MultiPoint", "coordinates": [[101, 0.6], [102.0, 0.5]]}"""
     multipoint = GeoJSON.loadFromString(text)
     savedtext = multipoint.saveToString()
     self.assertEqual(text, savedtext)
Exemplo n.º 11
0
 def test_it_returns_point_instance(self):
     text = """{"type": "MultiPoint", "coordinates": [[101, 0.6], [102.0, 0.5]]}"""
     multipoint = GeoJSON.loadFromString(text)
     self.assertEqual("MultiPoint", multipoint.getType())
Exemplo n.º 12
0
 def test_it_saves_id(self):
     text = """{"type": "Feature", "geometry": null, "properties": {"foo": 42}, "id": 999}"""
     feature = GeoJSON.loadFromString(text)
     savedtext = feature.saveToString()
     self.assertEqual(text, savedtext)
Exemplo n.º 13
0
"""Program zahodí body moc vzdálené od středu"""

import json
from geojson_lib.GeoJSON import GeoJSON
from geojson_lib.MultiPoint import MultiPoint

MAX_DISTANCE = 1.0  # max vzdálenost od středu
FILE_NAME = "example.geojson"

collection = GeoJSON.loadFromFile(FILE_NAME)
center_point = collection.items[0]
point_cloud = collection.items[1]

filtered_points = []
for i in range(len(point_cloud)):
    if ((center_point.lat - point_cloud.lat(i))**2 \
            + (center_point.lon - point_cloud.lon(i))**2) ** 0.5 <= MAX_DISTANCE:
        filtered_points.append([point_cloud.lat(i), point_cloud.lon(i)])

filtered_point_cloud = MultiPoint(*filtered_points)
collection.items[1] = filtered_point_cloud

print(json.dumps(collection.saveToJsonEntity(), indent=2))
Exemplo n.º 14
0
 def test_it_saves_to_string(self):
     text = """{"type": "GeometryCollection", "geometries": [{"type": "Point", "coordinates": [102.0, 0.5]}]}"""
     geometrycollection = GeoJSON.loadFromString(text)
     savedtext = geometrycollection.saveToString()
     self.assertEqual(text, savedtext)