Code:
api = overpy.Overpass()
result = api.query("[out:json];way(user:'{}')({}, {}, {}, {})(changed:'{}T{}Z', '{}T{}Z');out;".format(user, max_coords['south'], max_coords['west'], max_coords['north'], max_coords['east'], start_date, start_time, end_date, end_time))
for way in result.ways:
way_nodes_list = []
nodes = way.get_nodes(resolve_missing = True)
for node in nodes:
way_nodes_list.append((float(node.lon), float(node.lat)))
Suggestion : 2
Created by Murz on 21 October 2021, updated 18 November 2021
Usage example:
$result = \Drupal::service('overpass_api') - > query( << < EOT relation["admin_level" = "2"]
["type" = "boundary"]
["boundary" = "administrative"]
["ISO3166-1:alpha2"~"^..$"] EOT);
It should return array of OSM elements like this:
array: 216[
0 => {
"type": "relation"
"id": 60189 "members": [...]
"tags": {
...
}
}
...
]
Suggestion : 3
OSM XML vector data is loaded dynamically from a the Overpass API using a bbox strategy. Note that panning and zooming will eventually lead to "Too many requests" errors from the Overpass API.
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>OSM XML</title>
<!-- Pointer events polyfill for old browsers, see https://caniuse.com/#feat=pointer -->
<script src="https://unpkg.com/[email protected]/dist/elm-pep.js"></script>
<!-- The lines below are only needed for old environments like Internet Explorer and Android 4.x -->
<script src="https://cdn.polyfill.io/v3/polyfill.min.js?features=fetch,requestAnimationFrame,Element.prototype.classList,TextDecoder"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/core-js/3.18.3/minified.js"></script>
<link rel="stylesheet" href="node_modules/ol/ol.css">
<style>
.map {
width: 100%;
height:400px;
}
</style>
</head>
<body>
<div id="map" class="map"></div>
<script type="module" src="main.js"></script>
</body>
</html>
package.json
{
"name": "vector-osm",
"dependencies": {
"ol": "6.15.1"
},
"devDependencies": {
"parcel": "^2.0.0"
},
"scripts": {
"start": "parcel index.html",
"build": "parcel build --public-url . index.html"
}
}