Skip to content

Commit fde764d

Browse files
author
mgoddard
committed
Using geohash as the PK for the tourist_locations; adding a note on geohash precision
1 parent caee338 commit fde764d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -298,3 +298,8 @@ $ ./docker_tag_publish.sh
298298
299299
```
300300

301+
## References
302+
303+
1. [Geohash precision as a function of length](https://gis.stackexchange.com/questions/115280/what-is-the-precision-of-a-geohash)
304+
305+

load_osm_stdin.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,12 @@ def setup_db():
104104
DROP TABLE IF EXISTS tourist_locations;
105105
CREATE TABLE tourist_locations
106106
(
107-
name TEXT PRIMARY KEY
107+
name TEXT
108108
, lat FLOAT8
109109
, lon FLOAT8
110110
, enabled BOOLEAN DEFAULT TRUE
111+
, geohash CHAR(9) AS (ST_GEOHASH(ST_SETSRID(ST_MAKEPOINT(lon, lat), 4326), 9)) STORED
112+
, CONSTRAINT "primary" PRIMARY KEY (geohash ASC)
111113
);
112114
"""
113115
print("Creating tourist_locations table")

0 commit comments

Comments
 (0)