[Tile-serving] [openstreetmap/osm2pgsql] Add a script for simple updating of a database (#1411)
Sarah Hoffmann
notifications at github.com
Fri Feb 5 10:05:59 UTC 2021
@lonvia commented on this pull request.
> + with conn.cursor() as cur:
+ cur.execute("SELECT max(id) FROM {}_ways".format(prefix))
+ osmid = cur.fetchone()[0] if cur.rowcount == 1 else None
+
+ if osmid is None:
+ LOG.fatal("No data found in the database.")
+ return None
+
+ LOG.info("Using way id %d for timestamp lookup", osmid)
+ # Get the node from the API to find the timestamp when it was created.
+ node_url = 'https://www.openstreetmap.org/api/0.6/way/{}/1'.format(osmid)
+ headers = {"User-Agent" : "osm2pgsql-update"}
+ with urlrequest.urlopen(urlrequest.Request(node_url, headers=headers)) as response:
+ data = response.read().decode('utf-8')
+
+ match = re.search(r'timestamp="((\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}))Z"', data)
Used the json version of the API and parsed that 'properly'.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/pull/1411#discussion_r570856256
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20210205/40e9e1c1/attachment.htm>
More information about the Tile-serving
mailing list