Exemple #1
0
 def loadFromJsonEntity(cls, json_entity):
     return GeometryCollection(*map(lambda x: GeoJSON.loadFromJsonEntity(x),
                                    json_entity["geometries"]))
Exemple #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)
 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)
 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)
 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)
Exemple #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))
 def test_it_returns_point_instance(self):
     text = """{"type": "Point", "coordinates": [102.0, 0.5]}"""
     point = GeoJSON.loadFromString(text)
     self.assertEqual("Point", point.getType())
Exemple #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)
Exemple #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())
Exemple #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)
Exemple #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))
Exemple #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)