diff --git a/Pipfile b/Pipfile index b08b60a93c..47f9dc1fab 100644 --- a/Pipfile +++ b/Pipfile @@ -1,14 +1,15 @@ [[source]] -url = "https://pypi.python.org/simple" +url = "https://pypi.org/simple" verify_ssl = true name = "pypi" [packages] -geojson = ">=3.0.1" -pytest = "7.4.0" +osm2geojson = ">=0.1.30" requests = ">=2.31.0" -shapely = ">=2.0.1" [dev-packages] +geojson = ">=1.3.1" +pytest = "6.0.0" +requests-mock = "*" [requires] diff --git a/overpass/api.py b/overpass/api.py index 24a79253ae..a5fe645bb3 100644 --- a/overpass/api.py +++ b/overpass/api.py @@ -12,9 +12,8 @@ from math import ceil from typing import Optional -import geojson import requests -from shapely.geometry import Point, Polygon +from osm2geojson import json2geojson from .errors import ( MultipleRequestsError, @@ -131,7 +130,7 @@ def get(self, query, responseformat="geojson", verbosity="body", build=True, dat return response # construct geojson - return self._as_geojson(response["elements"]) + return json2geojson(response) @staticmethod def _api_status() -> dict: @@ -275,94 +274,16 @@ def _get_from_overpass(self, query): self._status = r.status_code - if self._status == 200: - r.encoding = "utf-8" - return r - elif self._status == 400: - raise OverpassSyntaxError(query) - elif self._status == 429: - raise MultipleRequestsError() - elif self._status == 504: - raise ServerLoadError(self._timeout) - else: + if self._status != 200: + if self._status == 400: + raise OverpassSyntaxError(query) + elif self._status == 429: + raise MultipleRequestsError() + elif self._status == 504: + raise ServerLoadError(self._timeout) raise UnknownOverpassError( - f"The request returned status code {self._status}" + "The request returned status code {code}".format(code=self._status) ) - - def _as_geojson(self, elements): - ids_already_seen = set() - features = [] - geometry = None - for elem in elements: - try: - if elem["id"] in ids_already_seen: - continue - ids_already_seen.add(elem["id"]) - except KeyError: - raise UnknownOverpassError("Received corrupt data from Overpass (no id).") - elem_type = elem.get("type") - elem_tags = elem.get("tags", {}) - elem_nodes = elem.get("nodes", None) - elem_timestamp = elem.get("timestamp", None) - elem_user = elem.get("user", None) - elem_uid = elem.get("uid", None) - elem_version = elem.get("version", None) - if elem_nodes: - elem_tags["nodes"] = elem_nodes - if elem_user: - elem_tags["user"] = elem_user - if elem_uid: - elem_tags["uid"] = elem_uid - if elem_version: - elem_tags["version"] = elem_version - elem_geom = elem.get("geometry", []) - if elem_type == "node": - # Create Point geometry - geometry = geojson.Point((elem.get("lon"), elem.get("lat"))) - elif elem_type == "way": - # Create LineString geometry - geometry = geojson.LineString([(coords["lon"], coords["lat"]) for coords in elem_geom]) - elif elem_type == "relation": - # Initialize polygon list - polygons = [] - # First obtain the outer polygons - for member in elem.get("members", []): - if member["role"] == "outer": - points = [(coords["lon"], coords["lat"]) for coords in member.get("geometry", [])] - # Check that the outer polygon is complete - if points and points[-1] == points[0]: - polygons.append([points]) - else: - raise UnknownOverpassError("Received corrupt data from Overpass (incomplete polygon).") - # Then get the inner polygons - for member in elem.get("members", []): - if member["role"] == "inner": - points = [(coords["lon"], coords["lat"]) for coords in member.get("geometry", [])] - # Check that the inner polygon is complete - if not points or points[-1] != points[0]: - raise UnknownOverpassError("Received corrupt data from Overpass (incomplete polygon).") - # We need to check to which outer polygon the inner polygon belongs - point = Point(points[0]) - for poly in polygons: - polygon = Polygon(poly[0]) - if polygon.contains(point): - poly.append(points) - break - else: - raise UnknownOverpassError("Received corrupt data from Overpass (inner polygon cannot " - "be matched to outer polygon).") - # Finally create MultiPolygon geometry - if polygons: - geometry = geojson.MultiPolygon(polygons) - else: - raise UnknownOverpassError("Received corrupt data from Overpass (invalid element).") - - if geometry: - feature = geojson.Feature( - id=elem["id"], - geometry=geometry, - properties=elem_tags - ) - features.append(feature) - - return geojson.FeatureCollection(features) + else: + r.encoding = "utf-8" + return r diff --git a/requirements-dev.txt b/requirements-dev.txt index 107faeb50b..52a31908a6 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,3 +1,4 @@ pytest>=7.4.0 requests-mock[fixture] tox>=4.6.3 +geojson>=1.3.1 diff --git a/requirements.txt b/requirements.txt index 1148fd78ed..6a05501a0c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,2 @@ -geojson>=3.0.1 -pytest +osm2geojson>=0.1.30 requests>=2.31.0 -shapely>=2.0.1 \ No newline at end of file diff --git a/setup.py b/setup.py index d60d30896b..c0496fc9d0 100644 --- a/setup.py +++ b/setup.py @@ -20,6 +20,6 @@ "Topic :: Scientific/Engineering :: GIS", "Topic :: Utilities", ], - install_requires=["requests>=2.3.0", "geojson>=1.0.9", "shapely>=1.6.4"], - extras_require={"test": ["pytest", "requests-mock[fixture]"]}, + install_requires=["requests>=2.3.0", "osm2geojson"], + extras_require={"test": ["pytest", "requests-mock[fixture]", "geojson>=1.0.9"]}, ) diff --git a/tests/example_body.geojson b/tests/example_body.geojson index 7c0ac7a4c9..c5c960d08c 100644 --- a/tests/example_body.geojson +++ b/tests/example_body.geojson @@ -1,318 +1,11 @@ { "type": "FeatureCollection", - "features": [ - { - "type": "Feature", + "features": [{ + "type": "Feature", + "properties": { + "type": "relation", "id": 6518385, - "geometry": { - "type": "MultiPolygon", - "coordinates": [ - [ - [ - [-122.197877, 37.85778], - [-122.194092, 37.857792], - [-122.194969, 37.856665], - [-122.194573, 37.856456], - [-122.19383, 37.856063], - [-122.192671, 37.855601], - [-122.191239, 37.854941], - [-122.190287, 37.854202], - [-122.18951, 37.853395], - [-122.189155, 37.85316], - [-122.188619, 37.852042], - [-122.188587, 37.850433], - [-122.188458, 37.8468], - [-122.193004, 37.84685], - [-122.193102, 37.844092], - [-122.196167, 37.843758], - [-122.196416, 37.843891], - [-122.196527, 37.84398], - [-122.196596, 37.844063], - [-122.196625, 37.844159], - [-122.196626, 37.844275], - [-122.196591, 37.8446], - [-122.196555, 37.844785], - [-122.19655, 37.844859], - [-122.196562, 37.845099], - [-122.196595, 37.845336], - [-122.196707, 37.845596], - [-122.19685, 37.845815], - [-122.197436, 37.846209], - [-122.197763, 37.846534], - [-122.1982, 37.846859], - [-122.198509, 37.847245], - [-122.198686, 37.847378], - [-122.198832, 37.847411], - [-122.199029, 37.847391], - [-122.199673, 37.847378], - [-122.200188, 37.847506], - [-122.200603, 37.847587], - [-122.200899, 37.847626], - [-122.201293, 37.847766], - [-122.201452, 37.847847], - [-122.201547, 37.847906], - [-122.201615, 37.847969], - [-122.201662, 37.84805], - [-122.201686, 37.848126], - [-122.201714, 37.848254], - [-122.201749, 37.848329], - [-122.201797, 37.848392], - [-122.201848, 37.848454], - [-122.201904, 37.848511], - [-122.201952, 37.848548], - [-122.202784, 37.849109], - [-122.202848, 37.849167], - [-122.202922, 37.849257], - [-122.203008, 37.849391], - [-122.20307, 37.849528], - [-122.203293, 37.849857], - [-122.203312, 37.849699], - [-122.203361, 37.849483], - [-122.203425, 37.84928], - [-122.203476, 37.84912], - [-122.203566, 37.848937], - [-122.203649, 37.848788], - [-122.203775, 37.848634], - [-122.203864, 37.848741], - [-122.203814, 37.848821], - [-122.203839, 37.848899], - [-122.203951, 37.84896], - [-122.204071, 37.848987], - [-122.204475, 37.848981], - [-122.204632, 37.849013], - [-122.204699, 37.849004], - [-122.204719, 37.848972], - [-122.204722, 37.848938], - [-122.204701, 37.848915], - [-122.204612, 37.848879], - [-122.204503, 37.848825], - [-122.204432, 37.848755], - [-122.204427, 37.848645], - [-122.204533, 37.84831], - [-122.20456, 37.848005], - [-122.204584, 37.847916], - [-122.204615, 37.847869], - [-122.204655, 37.847849], - [-122.204778, 37.847778], - [-122.204807, 37.847701], - [-122.204831, 37.847448], - [-122.204949, 37.847111], - [-122.205346, 37.846512], - [-122.205394, 37.846387], - [-122.20541, 37.846273], - [-122.205352, 37.845942], - [-122.205358, 37.845857], - [-122.205495, 37.845739], - [-122.205632, 37.84565], - [-122.205692, 37.845581], - [-122.205716, 37.845454], - [-122.205755, 37.845186], - [-122.205853, 37.844948], - [-122.205926, 37.844826], - [-122.206013, 37.844757], - [-122.206318, 37.844628], - [-122.206408, 37.844569], - [-122.206432, 37.844509], - [-122.206444, 37.844375], - [-122.206447, 37.844294], - [-122.206449, 37.844236], - [-122.206428, 37.844158], - [-122.206375, 37.844106], - [-122.206287, 37.844071], - [-122.206153, 37.844079], - [-122.206148, 37.843571], - [-122.206622, 37.843483], - [-122.208596, 37.850482], - [-122.208577, 37.850955], - [-122.208566, 37.851015], - [-122.208541, 37.851063], - [-122.208502, 37.851109], - [-122.208438, 37.851157], - [-122.208486, 37.85169], - [-122.20877, 37.851925], - [-122.209269, 37.852516], - [-122.210885, 37.854196], - [-122.210623, 37.855061], - [-122.210977, 37.855542], - [-122.211163, 37.856313], - [-122.210923, 37.856645], - [-122.211096, 37.856762], - [-122.21085, 37.856934], - [-122.211025, 37.857108], - [-122.211307, 37.856894], - [-122.211506, 37.85714], - [-122.212047, 37.857809], - [-122.212137, 37.858256], - [-122.211748, 37.85828], - [-122.212917, 37.859008], - [-122.213903, 37.858986], - [-122.214168, 37.859233], - [-122.214833, 37.859851], - [-122.215417, 37.860394], - [-122.215701, 37.860658], - [-122.216433, 37.860582], - [-122.216481, 37.860648], - [-122.216546, 37.860723], - [-122.21661, 37.860783], - [-122.216911, 37.86104], - [-122.217074, 37.861197], - [-122.217137, 37.861274], - [-122.217197, 37.861362], - [-122.217243, 37.861458], - [-122.217274, 37.861549], - [-122.217316, 37.861709], - [-122.217372, 37.861838], - [-122.217921, 37.862287], - [-122.21805, 37.862382], - [-122.218553, 37.862994], - [-122.218267, 37.863282], - [-122.217, 37.862143], - [-122.21633, 37.862981], - [-122.215336, 37.86253], - [-122.214499, 37.862013], - [-122.213738, 37.861522], - [-122.212933, 37.8612], - [-122.21206, 37.86088], - [-122.2115, 37.860812], - [-122.211345, 37.860794], - [-122.210262, 37.860607], - [-122.209757, 37.860235], - [-122.209453, 37.859626], - [-122.208785, 37.859769], - [-122.20885, 37.859909], - [-122.208941, 37.860063], - [-122.208188, 37.859981], - [-122.207766, 37.859935], - [-122.207408, 37.859896], - [-122.207248, 37.860891], - [-122.207189, 37.861261], - [-122.208394, 37.861405], - [-122.208703, 37.861442], - [-122.208942, 37.861471], - [-122.209142, 37.861497], - [-122.209117, 37.861616], - [-122.208902, 37.862686], - [-122.206636, 37.862631], - [-122.206689, 37.861446], - [-122.198009, 37.861454], - [-122.197877, 37.85778] - ], - [ - [-122.195626, 37.850528], - [-122.195622, 37.850664], - [-122.194665, 37.85065], - [-122.194668, 37.850514], - [-122.195626, 37.850528] - ], - [ - [-122.193631, 37.850507], - [-122.193653, 37.849682], - [-122.192015, 37.849655], - [-122.191993, 37.85048], - [-122.191979, 37.851031], - [-122.192966, 37.851048], - [-122.192981, 37.850497], - [-122.193631, 37.850507] - ], - [ - [-122.209682, 37.858775], - [-122.210318, 37.858454], - [-122.210106, 37.858073], - [-122.209792, 37.858168], - [-122.209445, 37.858474], - [-122.209682, 37.858775] - ] - ], - [ - [ - [-122.214506, 37.865654], - [-122.214739, 37.865305], - [-122.215062, 37.864823], - [-122.215317, 37.864443], - [-122.215441, 37.864258], - [-122.215644, 37.863955], - [-122.215787, 37.863741], - [-122.213781, 37.862786], - [-122.21353, 37.862666], - [-122.213115, 37.862469], - [-122.211992, 37.862088], - [-122.211749, 37.862006], - [-122.211032, 37.861823], - [-122.210984, 37.861854], - [-122.210932, 37.861888], - [-122.210789, 37.861994], - [-122.210657, 37.862098], - [-122.210519, 37.862215], - [-122.210369, 37.862355], - [-122.210221, 37.862516], - [-122.210096, 37.862657], - [-122.209982, 37.862824], - [-122.209884, 37.862961], - [-122.209774, 37.863164], - [-122.209702, 37.863344], - [-122.209633, 37.863545], - [-122.209581, 37.863762], - [-122.209559, 37.863965], - [-122.209557, 37.864192], - [-122.209553, 37.864413], - [-122.20983, 37.86445], - [-122.210077, 37.864798], - [-122.212723, 37.864933], - [-122.212632, 37.865082], - [-122.214506, 37.865654] - ] - ], - [ - [ - [-122.183933, 37.846772], - [-122.179485, 37.846769], - [-122.179472, 37.84959], - [-122.179469, 37.850483], - [-122.174886, 37.850508], - [-122.174897, 37.846908], - [-122.174381, 37.846909], - [-122.174374, 37.846768], - [-122.174278, 37.845781], - [-122.174244, 37.845431], - [-122.17421, 37.84505], - [-122.174198, 37.844938], - [-122.174197, 37.84491], - [-122.174198, 37.844895], - [-122.174239, 37.844001], - [-122.174148, 37.843785], - [-122.173667, 37.84333], - [-122.173359, 37.842656], - [-122.173059, 37.842199], - [-122.173039, 37.842167], - [-122.172363, 37.841828], - [-122.17167, 37.841556], - [-122.170393, 37.841024], - [-122.170366, 37.839856], - [-122.173416, 37.839848], - [-122.175136, 37.839844], - [-122.176957, 37.837722], - [-122.178038, 37.838142], - [-122.178218, 37.837895], - [-122.178398, 37.837974], - [-122.179015, 37.838187], - [-122.179246, 37.838281], - [-122.179458, 37.838394], - [-122.179526, 37.839474], - [-122.18098, 37.839502], - [-122.180953, 37.839917], - [-122.181039, 37.839916], - [-122.182271, 37.839908], - [-122.182634, 37.839717], - [-122.182912, 37.83957], - [-122.183949, 37.839595], - [-122.183929, 37.840341], - [-122.183935, 37.841137], - [-122.183933, 37.846772] - ] - ] - ] - }, - "properties": { + "tags": { "boundary": "protected_area", "contact:website": "http://www.ebparks.org/parks/sibley", "name": "Sibley Volcanic Regional Preserve", @@ -326,61 +19,357 @@ "wikipedia": "en:Robert Sibley Volcanic Regional Preserve" } }, - { - "type": "Feature", - "id": 10322303, - "geometry": { - "type": "LineString", - "coordinates": [ - [-122.318477, 37.869901], - [-122.318412, 37.869652], - [-122.318357, 37.869442], - [-122.318313, 37.869271], - [-122.318271, 37.86911], - [-122.318218, 37.868906], - [-122.318134, 37.868831], - [-122.317998, 37.868763], - [-122.317754, 37.86875], - [-122.317622, 37.868773], - [-122.317266, 37.86893], - [-122.317185, 37.869015], - [-122.317255, 37.869279], - [-122.317297, 37.869439], - [-122.317345, 37.869618], - [-122.317421, 37.869906], - [-122.317464, 37.87007] + "geometry": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [-122.1794718, 37.84959], + [-122.1794688, 37.8504828], + [-122.1748862, 37.8505078], + [-122.1748969, 37.846908], + [-122.1743812, 37.8469091], + [-122.1743737, 37.8467679], + [-122.174278, 37.8457811], + [-122.1742444, 37.8454312], + [-122.1742095, 37.8450505], + [-122.1741976, 37.844938], + [-122.1741972, 37.8449101], + [-122.1741978, 37.8448946], + [-122.1742394, 37.8440012], + [-122.1741477, 37.8437848], + [-122.1736671, 37.8433304], + [-122.1733589, 37.8426564], + [-122.1730593, 37.8421994], + [-122.1730392, 37.8421669], + [-122.1723633, 37.8418279], + [-122.1716704, 37.8415556], + [-122.170393, 37.841024], + [-122.1703659, 37.8398564], + [-122.1734159, 37.8398484], + [-122.1751359, 37.8398439], + [-122.1769565, 37.8377218], + [-122.1780377, 37.8381424], + [-122.1782177, 37.8378947], + [-122.1783984, 37.8379737], + [-122.1790152, 37.8381872], + [-122.1792459, 37.8382812], + [-122.1794585, 37.8383942], + [-122.179526, 37.839474], + [-122.18098, 37.839502], + [-122.180953, 37.839917], + [-122.1810388, 37.8399164], + [-122.182271, 37.839908], + [-122.1826336, 37.8397165], + [-122.182912, 37.83957], + [-122.1839488, 37.839595], + [-122.1839291, 37.8403406], + [-122.1839345, 37.841137], + [-122.1839334, 37.846772], + [-122.1794846, 37.8467686], + [-122.1794718, 37.84959] + ] + ], + [ + [ + [-122.1945727, 37.8564558], + [-122.1938301, 37.8560627], + [-122.1926709, 37.8556011], + [-122.191239, 37.854941], + [-122.1902871, 37.8542022], + [-122.1895098, 37.853395], + [-122.1891555, 37.8531602], + [-122.1886194, 37.8520422], + [-122.1885866, 37.8504331], + [-122.188458, 37.8468], + [-122.193004, 37.84685], + [-122.193102, 37.844092], + [-122.1961671, 37.8437576], + [-122.1964164, 37.843891], + [-122.1965272, 37.8439802], + [-122.1965956, 37.8440628], + [-122.1966251, 37.8441586], + [-122.1966258, 37.8442751], + [-122.1965913, 37.8445996], + [-122.1965552, 37.8447847], + [-122.1965504, 37.8448595], + [-122.1965625, 37.8450989], + [-122.1965948, 37.8453362], + [-122.1967066, 37.8455965], + [-122.1968499, 37.845815], + [-122.1974365, 37.8462085], + [-122.1977626, 37.8465338], + [-122.1982004, 37.8468591], + [-122.1985094, 37.8472454], + [-122.1986861, 37.8473775], + [-122.198832, 37.8474114], + [-122.1990294, 37.847391], + [-122.1996732, 37.8473775], + [-122.2001882, 37.8475063], + [-122.2006034, 37.847587], + [-122.2008992, 37.8476259], + [-122.2012933, 37.8477655], + [-122.2014519, 37.8478469], + [-122.2015471, 37.8479064], + [-122.2016145, 37.847969], + [-122.2016621, 37.8480504], + [-122.2016859, 37.8481256], + [-122.2017136, 37.848254], + [-122.2017493, 37.8483291], + [-122.2017969, 37.8483917], + [-122.2018485, 37.8484544], + [-122.201904, 37.8485107], + [-122.2019516, 37.8485483], + [-122.2027841, 37.8491095], + [-122.2028479, 37.8491672], + [-122.2029216, 37.8492567], + [-122.2030081, 37.8493907], + [-122.2030698, 37.8495283], + [-122.2032926, 37.8498573], + [-122.2033125, 37.8496988], + [-122.2033608, 37.8494828], + [-122.2034252, 37.8492805], + [-122.2034761, 37.8491196], + [-122.203566, 37.8489374], + [-122.203649, 37.8487876], + [-122.2037751, 37.8486341], + [-122.2038636, 37.848741], + [-122.203814, 37.8488215], + [-122.2038394, 37.8488992], + [-122.203951, 37.8489602], + [-122.2040712, 37.8489873], + [-122.2044746, 37.8489805], + [-122.2046315, 37.8490126], + [-122.2046985, 37.8490036], + [-122.2047186, 37.8489724], + [-122.204722, 37.848938], + [-122.2047005, 37.8489147], + [-122.2046119, 37.8488788], + [-122.2045027, 37.8488252], + [-122.2044317, 37.8487548], + [-122.204427, 37.8486446], + [-122.2045329, 37.8483105], + [-122.2045604, 37.8480045], + [-122.2045839, 37.847916], + [-122.2046154, 37.8478694], + [-122.2046548, 37.8478486], + [-122.2047783, 37.8477778], + [-122.2048072, 37.8477005], + [-122.2048306, 37.8474485], + [-122.2049493, 37.8471107], + [-122.2053463, 37.8465123], + [-122.2053939, 37.8463874], + [-122.20541, 37.846273], + [-122.2053523, 37.8459415], + [-122.2053577, 37.8458573], + [-122.2054945, 37.8457393], + [-122.2056319, 37.8456498], + [-122.2056923, 37.8455809], + [-122.2057158, 37.8454544], + [-122.2057547, 37.8451859], + [-122.2058526, 37.8449476], + [-122.2059263, 37.8448258], + [-122.2060135, 37.844757], + [-122.2063179, 37.8446278], + [-122.2064078, 37.8445685], + [-122.2064319, 37.8445092], + [-122.206444, 37.8443747], + [-122.2064467, 37.8442939], + [-122.2064487, 37.8442361], + [-122.2064279, 37.844158], + [-122.2063753, 37.8441062], + [-122.2062871, 37.8440712], + [-122.206153, 37.8440786], + [-122.2061479, 37.8435708], + [-122.2066221, 37.8434835], + [-122.2085964, 37.850482], + [-122.208577, 37.8509554], + [-122.2085659, 37.8510147], + [-122.2085409, 37.851063], + [-122.208502, 37.8511091], + [-122.208438, 37.8511574], + [-122.208486, 37.85169], + [-122.2087702, 37.8519251], + [-122.2092691, 37.8525155], + [-122.2108847, 37.8541961], + [-122.2106232, 37.8550607], + [-122.2109766, 37.8555423], + [-122.2111627, 37.8563126], + [-122.2109229, 37.8566447], + [-122.2110964, 37.8567616], + [-122.2108496, 37.8569342], + [-122.2110246, 37.857108], + [-122.2113068, 37.856894], + [-122.2115058, 37.8571398], + [-122.2120475, 37.8578091], + [-122.2121374, 37.8582562], + [-122.2117485, 37.8582802], + [-122.2129171, 37.8590083], + [-122.2139028, 37.8589861], + [-122.2141683, 37.859233], + [-122.2148326, 37.8598506], + [-122.2154172, 37.8603942], + [-122.215701, 37.8606581], + [-122.2164333, 37.8605821], + [-122.2164811, 37.8606483], + [-122.2165464, 37.860723], + [-122.2166097, 37.8607835], + [-122.2169109, 37.8610403], + [-122.217074, 37.8611974], + [-122.2171367, 37.8612736], + [-122.2171975, 37.8613625], + [-122.2172431, 37.8614579], + [-122.2172742, 37.8615492], + [-122.2173159, 37.8617086], + [-122.2173716, 37.8618385], + [-122.2179208, 37.8622867], + [-122.2180495, 37.8623816], + [-122.2185527, 37.8629942], + [-122.2182672, 37.8632819], + [-122.2170003, 37.862143], + [-122.2163302, 37.8629807], + [-122.2153362, 37.8625301], + [-122.2144994, 37.8620134], + [-122.2137376, 37.8615221], + [-122.2129329, 37.8612002], + [-122.2120602, 37.86088], + [-122.2114995, 37.8608123], + [-122.2113451, 37.8607936], + [-122.2102615, 37.8606073], + [-122.2097572, 37.8602346], + [-122.2094531, 37.8596264], + [-122.2087851, 37.8597685], + [-122.2088504, 37.8599088], + [-122.2089406, 37.860063], + [-122.2081879, 37.8599809], + [-122.2077658, 37.8599349], + [-122.2074076, 37.8598958], + [-122.207248, 37.8608912], + [-122.2071887, 37.8612612], + [-122.2083939, 37.8614053], + [-122.2087028, 37.8614422], + [-122.2089418, 37.8614708], + [-122.2091415, 37.8614975], + [-122.2091172, 37.861616], + [-122.2089019, 37.8626858], + [-122.2066359, 37.8626311], + [-122.2066888, 37.8614459], + [-122.1980086, 37.8614543], + [-122.1978766, 37.85778], + [-122.1940921, 37.8577917], + [-122.1949688, 37.8566651], + [-122.1945727, 37.8564558] + ], + [ + [-122.1936314, 37.8505074], + [-122.1936532, 37.8496821], + [-122.1920152, 37.8496551], + [-122.1919934, 37.8504796], + [-122.1919789, 37.8510314], + [-122.1929665, 37.8510476], + [-122.192981, 37.8504967], + [-122.1936314, 37.8505074] + ], + [ + [-122.1956223, 37.8506642], + [-122.1956256, 37.8505283], + [-122.1946679, 37.8505136], + [-122.1946645, 37.8506495], + [-122.1956223, 37.8506642] + ], + [ + [-122.2094446, 37.8584741], + [-122.2096819, 37.8587752], + [-122.2103175, 37.858454], + [-122.2101056, 37.8580727], + [-122.209792, 37.8581685], + [-122.2094446, 37.8584741] + ] + ], + [ + [ + [-122.2100769, 37.8647984], + [-122.2098302, 37.8644502], + [-122.2095533, 37.864413], + [-122.2095565, 37.8641922], + [-122.209559, 37.8639646], + [-122.2095814, 37.8637617], + [-122.2096334, 37.8635452], + [-122.2097017, 37.863344], + [-122.2097741, 37.8631636], + [-122.2098842, 37.8629608], + [-122.2099821, 37.8628239], + [-122.2100963, 37.8626573], + [-122.2102208, 37.8625164], + [-122.2103687, 37.8623554], + [-122.2105186, 37.8622155], + [-122.2106566, 37.862098], + [-122.2107887, 37.861994], + [-122.2109324, 37.8618885], + [-122.210984, 37.8618545], + [-122.2110324, 37.8618225], + [-122.2117493, 37.8620058], + [-122.2119916, 37.8620879], + [-122.2131154, 37.8624686], + [-122.2135296, 37.8626659], + [-122.2137807, 37.8627856], + [-122.2157868, 37.8637413], + [-122.2156436, 37.8639551], + [-122.2154408, 37.8642579], + [-122.2153169, 37.8644428], + [-122.215062, 37.8648233], + [-122.2147394, 37.865305], + [-122.2145058, 37.8656538], + [-122.2126318, 37.8650823], + [-122.2127232, 37.864933], + [-122.2100769, 37.8647984] + ] ] - }, - "properties": { + ] + } + }, { + "type": "Feature", + "properties": { + "type": "way", + "id": 10322303, + "tags": { "addr:city": "Berkeley", "foot": "yes", - "highway": "service", - "nodes": [ - 87340060, - 4927326183, - 4927326179, - 4927326177, - 4927326175, - 87362432, - 4927326184, - 87362434, - 813905690, - 87362436, - 87362437, - 87362444, - 4927326174, - 4927326176, - 4927326178, - 4927326180, - 87362452 - ] - } + "highway": "service" + }, + "nodes": [87340060, 4927326183, 4927326179, 4927326177, 4927326175, 87362432, 4927326184, 87362434, 813905690, 87362436, 87362437, 87362444, 4927326174, 4927326176, 4927326178, 4927326180, 87362452] + }, + "geometry": { + "type": "LineString", + "coordinates": [ + [-122.3184769, 37.8699011], + [-122.3184121, 37.8696521], + [-122.3183574, 37.8694416], + [-122.3183131, 37.8692714], + [-122.318271, 37.8691095], + [-122.3182181, 37.8689059], + [-122.3181336, 37.8688307], + [-122.3179977, 37.8687626], + [-122.3177537, 37.8687499], + [-122.3176222, 37.8687732], + [-122.3172655, 37.8689299], + [-122.317185, 37.8690146], + [-122.3172551, 37.8692792], + [-122.3172973, 37.8694387], + [-122.3173448, 37.8696182], + [-122.3174212, 37.8699064], + [-122.3174645, 37.8700701] + ] + } + }, { + "type": "Feature", + "properties": { + "type": "node", + "id": 4927326183 }, - { - "type": "Feature", - "id": 4927326183, - "geometry": {"type": "Point", "coordinates": [-122.318412, 37.869652]}, - "properties": {} + "geometry": { + "type": "Point", + "coordinates": [-122.3184121, 37.8696521] } - ] -} + }] +} \ No newline at end of file diff --git a/tests/example_meta.geojson b/tests/example_meta.geojson index 5293c46239..629b0e56b1 100644 --- a/tests/example_meta.geojson +++ b/tests/example_meta.geojson @@ -1,318 +1,11 @@ { "type": "FeatureCollection", - "features": [ - { - "type": "Feature", + "features": [{ + "type": "Feature", + "properties": { + "type": "relation", "id": 6518385, - "geometry": { - "type": "MultiPolygon", - "coordinates": [ - [ - [ - [-122.197877, 37.85778], - [-122.194092, 37.857792], - [-122.194969, 37.856665], - [-122.194573, 37.856456], - [-122.19383, 37.856063], - [-122.192671, 37.855601], - [-122.191239, 37.854941], - [-122.190287, 37.854202], - [-122.18951, 37.853395], - [-122.189155, 37.85316], - [-122.188619, 37.852042], - [-122.188587, 37.850433], - [-122.188458, 37.8468], - [-122.193004, 37.84685], - [-122.193102, 37.844092], - [-122.196167, 37.843758], - [-122.196416, 37.843891], - [-122.196527, 37.84398], - [-122.196596, 37.844063], - [-122.196625, 37.844159], - [-122.196626, 37.844275], - [-122.196591, 37.8446], - [-122.196555, 37.844785], - [-122.19655, 37.844859], - [-122.196562, 37.845099], - [-122.196595, 37.845336], - [-122.196707, 37.845596], - [-122.19685, 37.845815], - [-122.197436, 37.846209], - [-122.197763, 37.846534], - [-122.1982, 37.846859], - [-122.198509, 37.847245], - [-122.198686, 37.847378], - [-122.198832, 37.847411], - [-122.199029, 37.847391], - [-122.199673, 37.847378], - [-122.200188, 37.847506], - [-122.200603, 37.847587], - [-122.200899, 37.847626], - [-122.201293, 37.847766], - [-122.201452, 37.847847], - [-122.201547, 37.847906], - [-122.201615, 37.847969], - [-122.201662, 37.84805], - [-122.201686, 37.848126], - [-122.201714, 37.848254], - [-122.201749, 37.848329], - [-122.201797, 37.848392], - [-122.201848, 37.848454], - [-122.201904, 37.848511], - [-122.201952, 37.848548], - [-122.202784, 37.849109], - [-122.202848, 37.849167], - [-122.202922, 37.849257], - [-122.203008, 37.849391], - [-122.20307, 37.849528], - [-122.203293, 37.849857], - [-122.203312, 37.849699], - [-122.203361, 37.849483], - [-122.203425, 37.84928], - [-122.203476, 37.84912], - [-122.203566, 37.848937], - [-122.203649, 37.848788], - [-122.203775, 37.848634], - [-122.203864, 37.848741], - [-122.203814, 37.848821], - [-122.203839, 37.848899], - [-122.203951, 37.84896], - [-122.204071, 37.848987], - [-122.204475, 37.848981], - [-122.204632, 37.849013], - [-122.204699, 37.849004], - [-122.204719, 37.848972], - [-122.204722, 37.848938], - [-122.204701, 37.848915], - [-122.204612, 37.848879], - [-122.204503, 37.848825], - [-122.204432, 37.848755], - [-122.204427, 37.848645], - [-122.204533, 37.84831], - [-122.20456, 37.848005], - [-122.204584, 37.847916], - [-122.204615, 37.847869], - [-122.204655, 37.847849], - [-122.204778, 37.847778], - [-122.204807, 37.847701], - [-122.204831, 37.847448], - [-122.204949, 37.847111], - [-122.205346, 37.846512], - [-122.205394, 37.846387], - [-122.20541, 37.846273], - [-122.205352, 37.845942], - [-122.205358, 37.845857], - [-122.205495, 37.845739], - [-122.205632, 37.84565], - [-122.205692, 37.845581], - [-122.205716, 37.845454], - [-122.205755, 37.845186], - [-122.205853, 37.844948], - [-122.205926, 37.844826], - [-122.206013, 37.844757], - [-122.206318, 37.844628], - [-122.206408, 37.844569], - [-122.206432, 37.844509], - [-122.206444, 37.844375], - [-122.206447, 37.844294], - [-122.206449, 37.844236], - [-122.206428, 37.844158], - [-122.206375, 37.844106], - [-122.206287, 37.844071], - [-122.206153, 37.844079], - [-122.206148, 37.843571], - [-122.206622, 37.843483], - [-122.208596, 37.850482], - [-122.208577, 37.850955], - [-122.208566, 37.851015], - [-122.208541, 37.851063], - [-122.208502, 37.851109], - [-122.208438, 37.851157], - [-122.208486, 37.85169], - [-122.20877, 37.851925], - [-122.209269, 37.852516], - [-122.210885, 37.854196], - [-122.210623, 37.855061], - [-122.210977, 37.855542], - [-122.211163, 37.856313], - [-122.210923, 37.856645], - [-122.211096, 37.856762], - [-122.21085, 37.856934], - [-122.211025, 37.857108], - [-122.211307, 37.856894], - [-122.211506, 37.85714], - [-122.212047, 37.857809], - [-122.212137, 37.858256], - [-122.211748, 37.85828], - [-122.212917, 37.859008], - [-122.213903, 37.858986], - [-122.214168, 37.859233], - [-122.214833, 37.859851], - [-122.215417, 37.860394], - [-122.215701, 37.860658], - [-122.216433, 37.860582], - [-122.216481, 37.860648], - [-122.216546, 37.860723], - [-122.21661, 37.860783], - [-122.216911, 37.86104], - [-122.217074, 37.861197], - [-122.217137, 37.861274], - [-122.217197, 37.861362], - [-122.217243, 37.861458], - [-122.217274, 37.861549], - [-122.217316, 37.861709], - [-122.217372, 37.861838], - [-122.217921, 37.862287], - [-122.21805, 37.862382], - [-122.218553, 37.862994], - [-122.218267, 37.863282], - [-122.217, 37.862143], - [-122.21633, 37.862981], - [-122.215336, 37.86253], - [-122.214499, 37.862013], - [-122.213738, 37.861522], - [-122.212933, 37.8612], - [-122.21206, 37.86088], - [-122.2115, 37.860812], - [-122.211345, 37.860794], - [-122.210262, 37.860607], - [-122.209757, 37.860235], - [-122.209453, 37.859626], - [-122.208785, 37.859769], - [-122.20885, 37.859909], - [-122.208941, 37.860063], - [-122.208188, 37.859981], - [-122.207766, 37.859935], - [-122.207408, 37.859896], - [-122.207248, 37.860891], - [-122.207189, 37.861261], - [-122.208394, 37.861405], - [-122.208703, 37.861442], - [-122.208942, 37.861471], - [-122.209142, 37.861497], - [-122.209117, 37.861616], - [-122.208902, 37.862686], - [-122.206636, 37.862631], - [-122.206689, 37.861446], - [-122.198009, 37.861454], - [-122.197877, 37.85778] - ], - [ - [-122.195626, 37.850528], - [-122.195622, 37.850664], - [-122.194665, 37.85065], - [-122.194668, 37.850514], - [-122.195626, 37.850528] - ], - [ - [-122.193631, 37.850507], - [-122.193653, 37.849682], - [-122.192015, 37.849655], - [-122.191993, 37.85048], - [-122.191979, 37.851031], - [-122.192966, 37.851048], - [-122.192981, 37.850497], - [-122.193631, 37.850507] - ], - [ - [-122.209682, 37.858775], - [-122.210318, 37.858454], - [-122.210106, 37.858073], - [-122.209792, 37.858168], - [-122.209445, 37.858474], - [-122.209682, 37.858775] - ] - ], - [ - [ - [-122.214506, 37.865654], - [-122.214739, 37.865305], - [-122.215062, 37.864823], - [-122.215317, 37.864443], - [-122.215441, 37.864258], - [-122.215644, 37.863955], - [-122.215787, 37.863741], - [-122.213781, 37.862786], - [-122.21353, 37.862666], - [-122.213115, 37.862469], - [-122.211992, 37.862088], - [-122.211749, 37.862006], - [-122.211032, 37.861823], - [-122.210984, 37.861854], - [-122.210932, 37.861888], - [-122.210789, 37.861994], - [-122.210657, 37.862098], - [-122.210519, 37.862215], - [-122.210369, 37.862355], - [-122.210221, 37.862516], - [-122.210096, 37.862657], - [-122.209982, 37.862824], - [-122.209884, 37.862961], - [-122.209774, 37.863164], - [-122.209702, 37.863344], - [-122.209633, 37.863545], - [-122.209581, 37.863762], - [-122.209559, 37.863965], - [-122.209557, 37.864192], - [-122.209553, 37.864413], - [-122.20983, 37.86445], - [-122.210077, 37.864798], - [-122.212723, 37.864933], - [-122.212632, 37.865082], - [-122.214506, 37.865654] - ] - ], - [ - [ - [-122.183933, 37.846772], - [-122.179485, 37.846769], - [-122.179472, 37.84959], - [-122.179469, 37.850483], - [-122.174886, 37.850508], - [-122.174897, 37.846908], - [-122.174381, 37.846909], - [-122.174374, 37.846768], - [-122.174278, 37.845781], - [-122.174244, 37.845431], - [-122.17421, 37.84505], - [-122.174198, 37.844938], - [-122.174197, 37.84491], - [-122.174198, 37.844895], - [-122.174239, 37.844001], - [-122.174148, 37.843785], - [-122.173667, 37.84333], - [-122.173359, 37.842656], - [-122.173059, 37.842199], - [-122.173039, 37.842167], - [-122.172363, 37.841828], - [-122.17167, 37.841556], - [-122.170393, 37.841024], - [-122.170366, 37.839856], - [-122.173416, 37.839848], - [-122.175136, 37.839844], - [-122.176957, 37.837722], - [-122.178038, 37.838142], - [-122.178218, 37.837895], - [-122.178398, 37.837974], - [-122.179015, 37.838187], - [-122.179246, 37.838281], - [-122.179458, 37.838394], - [-122.179526, 37.839474], - [-122.18098, 37.839502], - [-122.180953, 37.839917], - [-122.181039, 37.839916], - [-122.182271, 37.839908], - [-122.182634, 37.839717], - [-122.182912, 37.83957], - [-122.183949, 37.839595], - [-122.183929, 37.840341], - [-122.183935, 37.841137], - [-122.183933, 37.846772] - ] - ] - ] - }, - "properties": { + "tags": { "boundary": "protected_area", "contact:website": "http://www.ebparks.org/parks/sibley", "name": "Sibley Volcanic Regional Preserve", @@ -323,70 +16,372 @@ "type": "multipolygon", "website": "https://www.ebparks.org/parks/sibley/", "wikidata": "Q7349780", - "wikipedia": "en:Robert Sibley Volcanic Regional Preserve", - "user": "Mstew354", - "uid": 11988139, - "version": 14 - } + "wikipedia": "en:Robert Sibley Volcanic Regional Preserve" + }, + "timestamp": "2021-02-17T03:29:31Z", + "user": "Mstew354", + "uid": 11988139, + "version": 14 }, - { - "type": "Feature", - "id": 10322303, - "geometry": { - "type": "LineString", - "coordinates": [ - [-122.318477, 37.869901], - [-122.318412, 37.869652], - [-122.318357, 37.869442], - [-122.318313, 37.869271], - [-122.318271, 37.86911], - [-122.318218, 37.868906], - [-122.318134, 37.868831], - [-122.317998, 37.868763], - [-122.317754, 37.86875], - [-122.317622, 37.868773], - [-122.317266, 37.86893], - [-122.317185, 37.869015], - [-122.317255, 37.869279], - [-122.317297, 37.869439], - [-122.317345, 37.869618], - [-122.317421, 37.869906], - [-122.317464, 37.87007] + "geometry": { + "type": "MultiPolygon", + "coordinates": [ + [ + [ + [-122.1794718, 37.84959], + [-122.1794688, 37.8504828], + [-122.1748862, 37.8505078], + [-122.1748969, 37.846908], + [-122.1743812, 37.8469091], + [-122.1743737, 37.8467679], + [-122.174278, 37.8457811], + [-122.1742444, 37.8454312], + [-122.1742095, 37.8450505], + [-122.1741976, 37.844938], + [-122.1741972, 37.8449101], + [-122.1741978, 37.8448946], + [-122.1742394, 37.8440012], + [-122.1741477, 37.8437848], + [-122.1736671, 37.8433304], + [-122.1733589, 37.8426564], + [-122.1730593, 37.8421994], + [-122.1730392, 37.8421669], + [-122.1723633, 37.8418279], + [-122.1716704, 37.8415556], + [-122.170393, 37.841024], + [-122.1703659, 37.8398564], + [-122.1734159, 37.8398484], + [-122.1751359, 37.8398439], + [-122.1769565, 37.8377218], + [-122.1780377, 37.8381424], + [-122.1782177, 37.8378947], + [-122.1783984, 37.8379737], + [-122.1790152, 37.8381872], + [-122.1792459, 37.8382812], + [-122.1794585, 37.8383942], + [-122.179526, 37.839474], + [-122.18098, 37.839502], + [-122.180953, 37.839917], + [-122.1810388, 37.8399164], + [-122.182271, 37.839908], + [-122.1826336, 37.8397165], + [-122.182912, 37.83957], + [-122.1839488, 37.839595], + [-122.1839291, 37.8403406], + [-122.1839345, 37.841137], + [-122.1839334, 37.846772], + [-122.1794846, 37.8467686], + [-122.1794718, 37.84959] + ] + ], + [ + [ + [-122.1945727, 37.8564558], + [-122.1938301, 37.8560627], + [-122.1926709, 37.8556011], + [-122.191239, 37.854941], + [-122.1902871, 37.8542022], + [-122.1895098, 37.853395], + [-122.1891555, 37.8531602], + [-122.1886194, 37.8520422], + [-122.1885866, 37.8504331], + [-122.188458, 37.8468], + [-122.193004, 37.84685], + [-122.193102, 37.844092], + [-122.1961671, 37.8437576], + [-122.1964164, 37.843891], + [-122.1965272, 37.8439802], + [-122.1965956, 37.8440628], + [-122.1966251, 37.8441586], + [-122.1966258, 37.8442751], + [-122.1965913, 37.8445996], + [-122.1965552, 37.8447847], + [-122.1965504, 37.8448595], + [-122.1965625, 37.8450989], + [-122.1965948, 37.8453362], + [-122.1967066, 37.8455965], + [-122.1968499, 37.845815], + [-122.1974365, 37.8462085], + [-122.1977626, 37.8465338], + [-122.1982004, 37.8468591], + [-122.1985094, 37.8472454], + [-122.1986861, 37.8473775], + [-122.198832, 37.8474114], + [-122.1990294, 37.847391], + [-122.1996732, 37.8473775], + [-122.2001882, 37.8475063], + [-122.2006034, 37.847587], + [-122.2008992, 37.8476259], + [-122.2012933, 37.8477655], + [-122.2014519, 37.8478469], + [-122.2015471, 37.8479064], + [-122.2016145, 37.847969], + [-122.2016621, 37.8480504], + [-122.2016859, 37.8481256], + [-122.2017136, 37.848254], + [-122.2017493, 37.8483291], + [-122.2017969, 37.8483917], + [-122.2018485, 37.8484544], + [-122.201904, 37.8485107], + [-122.2019516, 37.8485483], + [-122.2027841, 37.8491095], + [-122.2028479, 37.8491672], + [-122.2029216, 37.8492567], + [-122.2030081, 37.8493907], + [-122.2030698, 37.8495283], + [-122.2032926, 37.8498573], + [-122.2033125, 37.8496988], + [-122.2033608, 37.8494828], + [-122.2034252, 37.8492805], + [-122.2034761, 37.8491196], + [-122.203566, 37.8489374], + [-122.203649, 37.8487876], + [-122.2037751, 37.8486341], + [-122.2038636, 37.848741], + [-122.203814, 37.8488215], + [-122.2038394, 37.8488992], + [-122.203951, 37.8489602], + [-122.2040712, 37.8489873], + [-122.2044746, 37.8489805], + [-122.2046315, 37.8490126], + [-122.2046985, 37.8490036], + [-122.2047186, 37.8489724], + [-122.204722, 37.848938], + [-122.2047005, 37.8489147], + [-122.2046119, 37.8488788], + [-122.2045027, 37.8488252], + [-122.2044317, 37.8487548], + [-122.204427, 37.8486446], + [-122.2045329, 37.8483105], + [-122.2045604, 37.8480045], + [-122.2045839, 37.847916], + [-122.2046154, 37.8478694], + [-122.2046548, 37.8478486], + [-122.2047783, 37.8477778], + [-122.2048072, 37.8477005], + [-122.2048306, 37.8474485], + [-122.2049493, 37.8471107], + [-122.2053463, 37.8465123], + [-122.2053939, 37.8463874], + [-122.20541, 37.846273], + [-122.2053523, 37.8459415], + [-122.2053577, 37.8458573], + [-122.2054945, 37.8457393], + [-122.2056319, 37.8456498], + [-122.2056923, 37.8455809], + [-122.2057158, 37.8454544], + [-122.2057547, 37.8451859], + [-122.2058526, 37.8449476], + [-122.2059263, 37.8448258], + [-122.2060135, 37.844757], + [-122.2063179, 37.8446278], + [-122.2064078, 37.8445685], + [-122.2064319, 37.8445092], + [-122.206444, 37.8443747], + [-122.2064467, 37.8442939], + [-122.2064487, 37.8442361], + [-122.2064279, 37.844158], + [-122.2063753, 37.8441062], + [-122.2062871, 37.8440712], + [-122.206153, 37.8440786], + [-122.2061479, 37.8435708], + [-122.2066221, 37.8434835], + [-122.2085964, 37.850482], + [-122.208577, 37.8509554], + [-122.2085659, 37.8510147], + [-122.2085409, 37.851063], + [-122.208502, 37.8511091], + [-122.208438, 37.8511574], + [-122.208486, 37.85169], + [-122.2087702, 37.8519251], + [-122.2092691, 37.8525155], + [-122.2108847, 37.8541961], + [-122.2106232, 37.8550607], + [-122.2109766, 37.8555423], + [-122.2111627, 37.8563126], + [-122.2109229, 37.8566447], + [-122.2110964, 37.8567616], + [-122.2108496, 37.8569342], + [-122.2110246, 37.857108], + [-122.2113068, 37.856894], + [-122.2115058, 37.8571398], + [-122.2120475, 37.8578091], + [-122.2121374, 37.8582562], + [-122.2117485, 37.8582802], + [-122.2129171, 37.8590083], + [-122.2139028, 37.8589861], + [-122.2141683, 37.859233], + [-122.2148326, 37.8598506], + [-122.2154172, 37.8603942], + [-122.215701, 37.8606581], + [-122.2164333, 37.8605821], + [-122.2164811, 37.8606483], + [-122.2165464, 37.860723], + [-122.2166097, 37.8607835], + [-122.2169109, 37.8610403], + [-122.217074, 37.8611974], + [-122.2171367, 37.8612736], + [-122.2171975, 37.8613625], + [-122.2172431, 37.8614579], + [-122.2172742, 37.8615492], + [-122.2173159, 37.8617086], + [-122.2173716, 37.8618385], + [-122.2179208, 37.8622867], + [-122.2180495, 37.8623816], + [-122.2185527, 37.8629942], + [-122.2182672, 37.8632819], + [-122.2170003, 37.862143], + [-122.2163302, 37.8629807], + [-122.2153362, 37.8625301], + [-122.2144994, 37.8620134], + [-122.2137376, 37.8615221], + [-122.2129329, 37.8612002], + [-122.2120602, 37.86088], + [-122.2114995, 37.8608123], + [-122.2113451, 37.8607936], + [-122.2102615, 37.8606073], + [-122.2097572, 37.8602346], + [-122.2094531, 37.8596264], + [-122.2087851, 37.8597685], + [-122.2088504, 37.8599088], + [-122.2089406, 37.860063], + [-122.2081879, 37.8599809], + [-122.2077658, 37.8599349], + [-122.2074076, 37.8598958], + [-122.207248, 37.8608912], + [-122.2071887, 37.8612612], + [-122.2083939, 37.8614053], + [-122.2087028, 37.8614422], + [-122.2089418, 37.8614708], + [-122.2091415, 37.8614975], + [-122.2091172, 37.861616], + [-122.2089019, 37.8626858], + [-122.2066359, 37.8626311], + [-122.2066888, 37.8614459], + [-122.1980086, 37.8614543], + [-122.1978766, 37.85778], + [-122.1940921, 37.8577917], + [-122.1949688, 37.8566651], + [-122.1945727, 37.8564558] + ], + [ + [-122.1936314, 37.8505074], + [-122.1936532, 37.8496821], + [-122.1920152, 37.8496551], + [-122.1919934, 37.8504796], + [-122.1919789, 37.8510314], + [-122.1929665, 37.8510476], + [-122.192981, 37.8504967], + [-122.1936314, 37.8505074] + ], + [ + [-122.1956223, 37.8506642], + [-122.1956256, 37.8505283], + [-122.1946679, 37.8505136], + [-122.1946645, 37.8506495], + [-122.1956223, 37.8506642] + ], + [ + [-122.2094446, 37.8584741], + [-122.2096819, 37.8587752], + [-122.2103175, 37.858454], + [-122.2101056, 37.8580727], + [-122.209792, 37.8581685], + [-122.2094446, 37.8584741] + ] + ], + [ + [ + [-122.2100769, 37.8647984], + [-122.2098302, 37.8644502], + [-122.2095533, 37.864413], + [-122.2095565, 37.8641922], + [-122.209559, 37.8639646], + [-122.2095814, 37.8637617], + [-122.2096334, 37.8635452], + [-122.2097017, 37.863344], + [-122.2097741, 37.8631636], + [-122.2098842, 37.8629608], + [-122.2099821, 37.8628239], + [-122.2100963, 37.8626573], + [-122.2102208, 37.8625164], + [-122.2103687, 37.8623554], + [-122.2105186, 37.8622155], + [-122.2106566, 37.862098], + [-122.2107887, 37.861994], + [-122.2109324, 37.8618885], + [-122.210984, 37.8618545], + [-122.2110324, 37.8618225], + [-122.2117493, 37.8620058], + [-122.2119916, 37.8620879], + [-122.2131154, 37.8624686], + [-122.2135296, 37.8626659], + [-122.2137807, 37.8627856], + [-122.2157868, 37.8637413], + [-122.2156436, 37.8639551], + [-122.2154408, 37.8642579], + [-122.2153169, 37.8644428], + [-122.215062, 37.8648233], + [-122.2147394, 37.865305], + [-122.2145058, 37.8656538], + [-122.2126318, 37.8650823], + [-122.2127232, 37.864933], + [-122.2100769, 37.8647984] + ] ] - }, - "properties": { + ] + } + }, { + "type": "Feature", + "properties": { + "type": "way", + "id": 10322303, + "tags": { "addr:city": "Berkeley", "foot": "yes", - "highway": "service", - "nodes": [ - 87340060, - 4927326183, - 4927326179, - 4927326177, - 4927326175, - 87362432, - 4927326184, - 87362434, - 813905690, - 87362436, - 87362437, - 87362444, - 4927326174, - 4927326176, - 4927326178, - 4927326180, - 87362452 - ], - "user": "karitotp", - "uid": 2748195, - "version": 5 - } + "highway": "service" + }, + "nodes": [87340060, 4927326183, 4927326179, 4927326177, 4927326175, 87362432, 4927326184, 87362434, 813905690, 87362436, 87362437, 87362444, 4927326174, 4927326176, 4927326178, 4927326180, 87362452], + "timestamp": "2017-06-20T19:07:01Z", + "user": "karitotp", + "uid": 2748195, + "version": 5 }, - { - "type": "Feature", + "geometry": { + "type": "LineString", + "coordinates": [ + [-122.3184769, 37.8699011], + [-122.3184121, 37.8696521], + [-122.3183574, 37.8694416], + [-122.3183131, 37.8692714], + [-122.318271, 37.8691095], + [-122.3182181, 37.8689059], + [-122.3181336, 37.8688307], + [-122.3179977, 37.8687626], + [-122.3177537, 37.8687499], + [-122.3176222, 37.8687732], + [-122.3172655, 37.8689299], + [-122.317185, 37.8690146], + [-122.3172551, 37.8692792], + [-122.3172973, 37.8694387], + [-122.3173448, 37.8696182], + [-122.3174212, 37.8699064], + [-122.3174645, 37.8700701] + ] + } + }, { + "type": "Feature", + "properties": { + "type": "node", "id": 4927326183, - "geometry": {"type": "Point", "coordinates": [-122.318412, 37.869652]}, - "properties": {"user": "karitotp", "uid": 2748195, "version": 1} + "timestamp": "2017-06-20T19:06:58Z", + "user": "karitotp", + "uid": 2748195, + "version": 1 + }, + "geometry": { + "type": "Point", + "coordinates": [-122.3184121, 37.8696521] } - ] -} + }] +} \ No newline at end of file diff --git a/tests/test_api.py b/tests/test_api.py index bd9b9d3fad..9481941b34 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -56,6 +56,14 @@ def test_geojson( assert len(osm_geo["features"]) > length +def test_multipolygon(): + """ + Test that multipolygons are processed without error + """ + api = overpass.API() + api.get("rel(11038555)", verbosity="body geom") + + @pytest.mark.parametrize("verbosity,response,output", [ ("body geom", "tests/example_body.json", "tests/example_body.geojson"), # ("tags geom", "tests/example.json", "tests/example.geojson"), @@ -71,12 +79,15 @@ def test_geojson_extended(verbosity, response, output, requests_mock.post( "//overpass-api.de/api/interpreter", json=mock_response) - osm_geo = api.get( - f"rel(6518385);out {verbosity};way(10322303);out {verbosity};node(4927326183);", - verbosity=verbosity) + osm_geo = sorted( + api.get( + f"rel(6518385);out {verbosity};way(10322303);out {verbosity};node(4927326183);", + verbosity=verbosity + ) + ) with Path(output).open() as fp: - ref_geo = geojson.load(fp) + ref_geo = sorted(geojson.load(fp)) assert osm_geo == ref_geo