[Tile-serving] [openstreetmap/osm2pgsql] Add a script for simple updating of a database (#1411)
mmd
notifications at github.com
Thu Feb 4 21:57:25 UTC 2021
@mmd-osm 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)
Since you're requesting this from the API 0.6: CGImap doesn't set a last-modified header at this time.
--
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_r570571420
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20210204/9e6ecb4b/attachment.htm>
More information about the Tile-serving
mailing list