{"id":20705310,"url":"https://github.com/whosonfirst/go-whosonfirst-pgis","last_synced_at":"2025-05-10T20:30:43.510Z","repository":{"id":54423723,"uuid":"74076468","full_name":"whosonfirst/go-whosonfirst-pgis","owner":"whosonfirst","description":"This is not ready to use. It is still being tested. It will probably be renamed.","archived":true,"fork":false,"pushed_at":"2024-12-14T21:28:53.000Z","size":4899,"stargazers_count":3,"open_issues_count":9,"forks_count":2,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-02-26T12:23:16.960Z","etag":null,"topics":["database","golang","postgis","whosonfirst"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/whosonfirst.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-17T23:27:12.000Z","updated_at":"2024-12-14T21:29:20.000Z","dependencies_parsed_at":"2022-08-13T15:10:47.951Z","dependency_job_id":null,"html_url":"https://github.com/whosonfirst/go-whosonfirst-pgis","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whosonfirst%2Fgo-whosonfirst-pgis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whosonfirst%2Fgo-whosonfirst-pgis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whosonfirst%2Fgo-whosonfirst-pgis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whosonfirst%2Fgo-whosonfirst-pgis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whosonfirst","download_url":"https://codeload.github.com/whosonfirst/go-whosonfirst-pgis/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253480238,"owners_count":21915245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","golang","postgis","whosonfirst"],"created_at":"2024-11-17T01:17:15.249Z","updated_at":"2025-05-10T20:30:43.493Z","avatar_url":"https://github.com/whosonfirst.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-whosonfirst-pgis\n\n## Deprecation notice (December 2024)\n\nThis package has been deprecated and superseded by tools in the [whosonfirst/go-whosonfirst-database-postgres](https://github.com/whosonfirst/go-whosonfirst-database-postgres) package.\n\n## Install\n\nTo compile all the binary tools just run the handy `cli-tools` Make target, like this:\n\n```\nmake cli-tools\n```\n\n## Set up\n\nFirst of all this requires Postgresql 9.6 in order that we can take advantage of the recent `UPSERT` syntax.\n\n#### Ubuntu Installation\n\n```bash\nsudo wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -\nsudo apt-get update\nsudo apt-get install postgresql-9.6 postgresql-contrib-9.6 postgis postgresql-9.6-postgis-2.3\n```\n\n```bash\nsudo -u postgres createuser -P whosonfirst\nsudo -u postgres createdb -O whosonfirst whosonfirst\nsudo -u postgres psql -c \"CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology;\" whosonfirst\nsudo -u postgres psql -c \"CREATE TABLE whosonfirst (id BIGINT PRIMARY KEY,parent_id BIGINT,placetype_id BIGINT,is_superseded SMALLINT,is_deprecated SMALLINT,meta JSON, geom_hash CHAR(32), lastmod CHAR(25), geom GEOGRAPHY(MULTIPOLYGON, 4326), centroid GEOGRAPHY(POINT, 4326))\" whosonfirst\nsudo -u postgres psql -c \"GRANT ALL ON TABLE whosonfirst TO whosonfirst\" whosonfirst\nsudo -u postgres psql -c \"CREATE INDEX by_geom ON whosonfirst USING GIST(geom);\" whosonfirst\nsudo -u postgres psql -c \"CREATE INDEX by_centroid ON whosonfirst USING GIST(centroid);\" whosonfirst\nsudo -u postgres psql -c \"CREATE INDEX by_placetype ON whosonfirst (placetype_id);\" whosonfirst\n```\n\n_Note that this still lacks indices on things like `placetype_id` and others._\n\n#### Docker Container\n\nThe `docker-compose.yml` \u0026 `setup.sh` files in this repo can be used to install \u0026 configure a PostGIS server running inside a Docker container.\n\n\u003e the default superuser username is 'postgres' and the default password is 'secretpassword'.\n\u003e these settings can be modified in docker-compose.yml along with the desired port mapping.\n\n```bash\ndocker-compose up -d postgis\n```\n\nYou can now connect to the database with the following command (from your local machine):\n\n```bash\nexport PGPASSWORD='secretpassword'\npsql -h localhost -p 5432 -U postgres\n```\n\nRunning `setup.sh` will set up the `whosonfirst` user, create the database \u0026 the table (as shown above).\n\n```bash\n./setup.sh\n```\n\n\u003e by default the user account is named 'whosonfirst' and the password is 'secretpassword'.\n\u003e note: you will need to correctly specify the `-pgis-password` flag when using docker.\n\nYou can confirm the user, database \u0026 table were created correctly with the following command:\n\n```bash\npsql -h localhost -p 5432 -U whosonfirst -d whosonfirst -c '\\dt+ whosonfirst'\n\n                           List of relations\n Schema |    Name     | Type  |    Owner    |    Size    | Description\n--------+-------------+-------+-------------+------------+-------------\n public | whosonfirst | table | whosonfirst | 8192 bytes |\n(1 row)\n```\n\n## Utilities\n\n### wof-pgis-index\n\nIndex one or more Who's On First documents on disk in to your PGIS database.\n\n```\n./bin/wof-pgis-index -h\nUsage of ./bin/wof-pgis-index:\n  -collection string\n    \tThe name of your PostgreSQL database for indexing data.\n  -debug\n    \tGo through all the motions but don't actually index anything.\n  -geometry string\n    \tWhich geometry to index. Valid options are: centroid, bbox or whatever is in the default GeoJSON geometry (default).\n  -mode string\n    \tThe mode to use importing data. Valid options are: directory, meta, repo, filelist and files. (default \"files\")\n  -nfs-kludge\n    \tEnable the (walk.go) NFS kludge to ignore 'readdirent: errno' 523 errors\n  -pgis-database string\n    \tThe name of your PostgreSQL database. (default \"whosonfirst\")\n  -pgis-host string\n    \tThe host of your PostgreSQL server. (default \"localhost\")\n  -pgis-maxconns int\n    \tThe maximum number of connections to use with your PostgreSQL database. (default 10)\n  -pgis-password string\n    \tThe password of your PostgreSQL user.\n  -pgis-port int\n    \tThe port of your PostgreSQL server. (default 5432)\n  -pgis-user string\n    \tThe name of your PostgreSQL user. (default \"whosonfirst\")\n  -procs int\n    \tThe number of concurrent processes to use importing data. (default 200)\n  -strict\n    \tThrow fatal errors rather than warning when certain conditions fails.\n  -verbose\n    \tBe chatty about what's happening. This is automatically enabled if the -debug flag is set.\n```\n\n### wof-pgis-prune\n\n```\n./bin/wof-pgis-prune -h\nUsage of ./bin/wof-pgis-prune:\n  -data-root string\n    \tThe root folder where Who's On First data repositories are stored. (default \"/usr/local/data\")\n  -debug\n    \tGo through all the motions but don't actually index anything.\n  -delete\n    \tDelete rows from the PostgreSQL database.\n  -pgis-database string\n    \tThe name of your PostgreSQL database. (default \"whosonfirst\")\n  -pgis-host string\n    \tThe host of your PostgreSQL server. (default \"localhost\")\n  -pgis-maxconns int\n    \tThe maximum number of connections to use with your PostgreSQL database. (default 10)\n  -pgis-password string\n    \tThe password of your PostgreSQL user.\n  -pgis-port int\n    \tThe port of your PostgreSQL server. (default 5432)\n  -pgis-user string\n    \tThe name of your PostgreSQL user. (default \"whosonfirst\")\n  -procs int\n    \tThe number of concurrent processes to use importing data. (default 200)\n  -verbose\n    \tBe chatty about what's happening. This is automatically enabled if the -debug flag is set.\n```\n\nThis is a simple utility to ensure that the Who's On First records in your PGIS database have corresponding Who's On First records on disk. If there are missing records (on disk) and this program is invoked with the `-delete` flag then that record will be removed from the PGIS database. For example:\n\n```\n./bin/wof-pgis-prune -debug -verbose\n2017/03/31 19:53:48 SELECT id, meta FROM whosonfirst OFFSET 0 LIMIT 100000 (25171692)\n2017/03/31 19:54:08 SELECT id, meta FROM whosonfirst OFFSET 100000 LIMIT 100000 (25171692)\n2017/03/31 19:54:30 SELECT id, meta FROM whosonfirst OFFSET 200000 LIMIT 100000 (25171692)\n2017/03/31 19:54:44 SELECT id, meta FROM whosonfirst OFFSET 300000 LIMIT 100000 (25171692)\n2017/03/31 19:55:02 SELECT id, meta FROM whosonfirst OFFSET 400000 LIMIT 100000 (25171692)\n2017/03/31 19:55:15 SELECT id, meta FROM whosonfirst OFFSET 500000 LIMIT 100000 (25171692)\n2017/03/31 19:55:29 SELECT id, meta FROM whosonfirst OFFSET 600000 LIMIT 100000 (25171692)\n2017/03/31 19:55:37 /usr/local/data/whosonfirst-data-venue-pr/data/110/870/298/5/1108702985.geojson does not exist\n2017/03/31 19:55:37 /usr/local/data/whosonfirst-data-venue-pr/data/110/870/298/1/1108702981.geojson does not exist\n2017/03/31 19:55:45 SELECT id, meta FROM whosonfirst OFFSET 700000 LIMIT 100000 (25171692)\n2017/03/31 19:56:01 SELECT id, meta FROM whosonfirst OFFSET 800000 LIMIT 100000 (25171692)\n2017/03/31 19:56:17 SELECT id, meta FROM whosonfirst OFFSET 900000 LIMIT 100000 (25171692)\n2017/03/31 19:56:42 SELECT id, meta FROM whosonfirst OFFSET 1000000 LIMIT 100000 (25171692)\n\nand so on\n```\n\nReally, this is a utility for when an update goes pear-shaped and you need to clean up after yourself.\n\n## See also\n\n* http://www.saintsjd.com/2014/08/13/howto-install-postgis-on-ubuntu-trusty.html\n* https://wiki.postgresql.org/wiki/Apt\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhosonfirst%2Fgo-whosonfirst-pgis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhosonfirst%2Fgo-whosonfirst-pgis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhosonfirst%2Fgo-whosonfirst-pgis/lists"}