{"id":20705266,"url":"https://github.com/whosonfirst/go-whosonfirst-sqlite-features","last_synced_at":"2025-05-10T20:30:46.924Z","repository":{"id":57499209,"uuid":"120670893","full_name":"whosonfirst/go-whosonfirst-sqlite-features","owner":"whosonfirst","description":"Go package for working with Who's On First features and SQLite databases.","archived":true,"fork":false,"pushed_at":"2024-12-13T18:30:44.000Z","size":15749,"stargazers_count":2,"open_issues_count":3,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-26T12:23:13.475Z","etag":null,"topics":["geojson","golang","sqlite","whosonfirst"],"latest_commit_sha":null,"homepage":null,"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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-07T20:58:50.000Z","updated_at":"2024-12-13T18:30:56.000Z","dependencies_parsed_at":"2024-02-13T18:22:59.257Z","dependency_job_id":null,"html_url":"https://github.com/whosonfirst/go-whosonfirst-sqlite-features","commit_stats":{"total_commits":126,"total_committers":7,"mean_commits":18.0,"dds":0.4841269841269841,"last_synced_commit":"e50a2f8896b39ed598b32c355b9f2855ea3b7e8e"},"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whosonfirst%2Fgo-whosonfirst-sqlite-features","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whosonfirst%2Fgo-whosonfirst-sqlite-features/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whosonfirst%2Fgo-whosonfirst-sqlite-features/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whosonfirst%2Fgo-whosonfirst-sqlite-features/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whosonfirst","download_url":"https://codeload.github.com/whosonfirst/go-whosonfirst-sqlite-features/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253480236,"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":["geojson","golang","sqlite","whosonfirst"],"created_at":"2024-11-17T01:17:02.121Z","updated_at":"2025-05-10T20:30:41.897Z","avatar_url":"https://github.com/whosonfirst.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-whosonfirst-sqlite-features\n\nGo package for implementing the `aaronland/go-sqlite.Table` interface used to index Who's On First Feature records in one or more SQLite database tables.\n\nThis package only defines packages that implement the `aaronland/go-sqlite.Table` interface and does not do any actual database table indexing. That is handled by the `whosonfirst/go-whosonfirst-sqlite-feature-index` package.\n\n## Documentation\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/whosonfirst/go-whosonfirst-sqlite-features.svg)](https://pkg.go.dev/github.com/whosonfirst/go-whosonfirst-sqlite-features)\n\nDocumentation is incomplete at this time.\n\n## Tables\n\n### ancestors\n\n```\nCREATE TABLE ancestors (\n\tid INTEGER NOT NULL,\n\tancestor_id INTEGER NOT NULL,\n\tancestor_placetype TEXT,\n\tlastmodified INTEGER\n);\n\nCREATE INDEX ancestors_by_id ON ancestors (id,ancestor_placetype,lastmodified);\nCREATE INDEX ancestors_by_ancestor ON ancestors (ancestor_id,ancestor_placetype,lastmodified);\nCREATE INDEX ancestors_by_lastmod ON ancestors (lastmodified);\n```\n\n### concordances\n\n```\nCREATE TABLE concordances (\n\tid INTEGER NOT NULL,\n\tconcordance_id INTEGER NOT NULL,\n\tconcordance_souce TEXT,\n\tlastmodified INTEGER\n);\n\nCREATE INDEX concordances_by_id ON concordances (id,lastmodified);\nCREATE INDEX concordances_by_other ON concordances (other_source,other_id);\t\nCREATE INDEX concordances_by_other_lastmod ON concordances (other_source,other_id,lastmodified);\nCREATE INDEX ancestors_by_lastmod ON concordances (lastmodified);`\n```\n\n### geojson\n\n```\nCREATE TABLE geojson (\n\tid INTEGER NOT NULL,\n\tbody TEXT,\n\tsource TEXT,\n\tis_alt BOOLEAN,\n\talt_label TEXT,\n\tlastmodified INTEGER\n);\n\nCREATE UNIQUE INDEX geojson_by_id ON %s (id, source, alt_label);\nCREATE INDEX geojson_by_alt ON %s (id, is_alt, alt_label);\nCREATE INDEX geojson_by_lastmod ON %s (lastmodified);\n```\n\n### geometry\n\n```\nCREATE TABLE geometry (\n\tid INTEGER NOT NULL,\n\tbody TEXT,\n\tis_alt BOOLEAN,\n\talt_label TEXT,\n\tlastmodified INTEGER\n);\n\nCREATE UNIQUE INDEX geojson_by_id ON %s (id, alt_label);\nCREATE INDEX geojson_by_alt ON %s (id, is_alt, alt_label);\nCREATE INDEX geojson_by_lastmod ON %s (lastmodified);\n```\n\nThis table indexes only the `geometry` elements for Who's On First records. This table is principally used in concert with the `rtree` for performance reasons.\n\n### geometries\n\n```\nCREATE TABLE geometries (\n\tid INTEGER NOT NULL,\n\ttype TEXT,\n\tis_alt TINYINT,\n\talt_label TEXT,\n\tlastmodified INTEGER\n);\n\nSELECT InitSpatialMetaData();\nSELECT AddGeometryColumn('geometries', 'geom', 4326, 'GEOMETRY', 'XY');\nSELECT CreateSpatialIndex('geometries', 'geom');\n\nCREATE UNIQUE INDEX by_id ON geometries (id, alt_label);\nCREATE INDEX geometries_by_lastmod ON geometries (lastmodified);`\n```\n\n#### Notes\n\n* In order to index the `geometries` table you will need to have the [Spatialite extension](https://www.gaia-gis.it/fossil/libspatialite/index) installed.\n* As of Decemeber 2020, I am no longer able to make this (indexing the `geometries` table) work under OS X. I am not sure if this is a `spatialite` thing or a `go-sqlite3` thing or something else. Any help resolving this issue would be welcome.\n\n### names\n\n```\nCREATE TABLE names (\n       id INTEGER NOT NULL,\n       placetype TEXT,\n       country TEXT,\n       language TEXT,\n       extlang TEXT,\n       script TEXT,\n       region TEXT,\n       variant TEXT,\n       extension TEXT,\n       privateuse TEXT,\n       name TEXT,\n       lastmodified INTEGER\n);\n\nCREATE INDEX names_by_lastmod ON names (lastmodified);\nCREATE INDEX names_by_country ON names (country,privateuse,placetype);\nCREATE INDEX names_by_language ON names (language,privateuse,placetype);\nCREATE INDEX names_by_placetype ON names (placetype,country,privateuse);\nCREATE INDEX names_by_name ON names (name, placetype, country);\nCREATE INDEX names_by_name_private ON names (name, privateuse, placetype, country);\nCREATE INDEX names_by_wofid ON names (id);\n```\n\n### properties\n\n```\nCREATE TABLE properties (\n\tid INTEGER NOT NULL,\n\tbody TEXT,\n\tis_alt BOOLEAN,\n\talt_label TEXT,\n\tlastmodified INTEGER\n);\n\nCREATE UNIQUE INDEX geojson_by_id ON %s (id, alt_label);\nCREATE INDEX geojson_by_alt ON %s (id, is_alt, alt_label);\nCREATE INDEX geojson_by_lastmod ON %s (lastmodified);\n```\n\nThis table indexes only the `properties` elements for Who's On First records. This table is principally used in concert with the `rtree` for performance reasons.\n\n### rtree\n\n```\nCREATE VIRTUAL TABLE %s USING rtree (\n\tid,\n\tmin_x,\n\tmax_x,\n\tmin_y,\n\tmax_y,\n\t+wof_id INTEGER,\n\t+is_alt TINYINT,\n\t+alt_label TEXT,\n\t+geometry BLOB,\t\n\t+lastmodified INTEGER\n);\n```\n\n#### Notes\n\nSection `3.1.1` of the [SQLite RTree documentation](https://www.sqlite.org/rtree.html) states:\n\n\u003e In the argments to \"rtree\" in the CREATE VIRTUAL TABLE statement, the names of the columns are taken from the first token of each argument. All subsequent tokens within each argument are silently ignored. This means, for example, that if you try to give a column a type affinity or add a constraint such as UNIQUE or NOT NULL or DEFAULT to a column, those extra tokens are accepted as valid, but they do not change the behavior of the rtree. In an RTREE virtual table, the first column always has a type affinity of INTEGER and all other data columns have a type affinity of NUMERIC. Recommended practice is to omit any extra tokens in the rtree specification. Let each argument to \"rtree\" be a single ordinary label that is the name of the corresponding column, and omit all other tokens from the argument list.\n\nSection `4.1` goes on to say:\n\n\u003e Beginning with SQLite version 3.24.0 (2018-06-04), r-tree tables can have auxiliary columns that store arbitrary data. ... Auxiliary columns are marked with a \"+\" symbol before the column name. Auxiliary columns must come after all of the coordinate boundary columns. There is a limit of no more than 100 auxiliary columns.\n\nWith that in mind the `rtree` table relies on SQLite to automatically generate a new primary key value for the `id` column. The Who's On First record's ID is _not_ the primary key for the table and is stored in the `wof_id` column. It may be associated with (1) primary record and (n) alternate geometry records. If an alternate geometry is indexed the `is_alt` column value will be set to \"1\" and the `alt_label` column will be populated with the value in that record's `src:alt_label` property.\n\nThe `+geometry` column contains each polygons rings JSON-encoded as `[][][]float64`.\n\n### search\n\n```\nCREATE VIRTUAL TABLE search USING fts4(\n\tid, placetype,\n\tname, names_all, names_preferred, names_variant, names_colloquial,\t\t\n\tis_current, is_ceased, is_deprecated, is_superseded\n);\n```\n\n### spr\n\n```\nCREATE TABLE spr (\n\tid INTEGER NOT NULL PRIMARY KEY,\n\tparent_id INTEGER,\n\tname TEXT,\n\tplacetype TEXT,\n\tcountry TEXT,\n\trepo TEXT,\n\tlatitude REAL,\n\tlongitude REAL,\n\tmin_latitude REAL,\n\tmin_longitude REAL,\n\tmax_latitude REAL,\n\tmax_longitude REAL,\n\tis_current INTEGER,\n\tis_deprecated INTEGER,\n\tis_ceased INTEGER,\n\tis_superseded INTEGER,\n\tis_superseding INTEGER,\n\tsuperseded_by TEXT,\n\tsupersedes TEXT,\n\tis_alt TINYINT,\n\talt_label TEXT,\t\n\tlastmodified INTEGER\n);\n\nCREATE INDEX spr_by_lastmod ON spr (lastmodified);\nCREATE INDEX spr_by_parent ON spr (parent_id, is_current, lastmodified);\nCREATE INDEX spr_by_placetype ON spr (placetype, is_current, lastmodified);\nCREATE INDEX spr_by_country ON spr (country, placetype, is_current, lastmodified);\nCREATE INDEX spr_by_name ON spr (name, placetype, is_current, lastmodified);\nCREATE INDEX spr_by_centroid ON spr (latitude, longitude, is_current, lastmodified);\nCREATE INDEX spr_by_bbox ON spr (min_latitude, min_longitude, max_latitude, max_longitude, placetype, is_current, lastmodified);\nCREATE INDEX spr_by_repo ON spr (repo, lastmodified);\nCREATE INDEX spr_by_current ON spr (is_current, lastmodified);\nCREATE INDEX spr_by_deprecated ON spr (is_deprecated, lastmodified);\nCREATE INDEX spr_by_ceased ON spr (is_ceased, lastmodified);\nCREATE INDEX spr_by_superseded ON spr (is_superseded, lastmodified);\nCREATE INDEX spr_by_superseding ON spr (is_superseding, lastmodified);\nCREATE INDEX spr_obsolete ON spr (is_deprecated, is_superseded);\n```\n\n### supersedes\n\n```\nCREATE TABLE %s (\n\tid INTEGER NOT NULL,\n\tsuperseded_id INTEGER NOT NULL,\n\tsuperseded_by_id INTEGER NOT NULL,\n\tlastmodified INTEGER\n);\n\nCREATE UNIQUE INDEX supersedes_by ON %s (id,superseded_id, superseded_by_id);\n```\n\n## Custom tables\n\nSure. You just need to write a per-table package that implements the `Table` interface as described in [go-whosonfirst-sqlite](https://github.com/whosonfirst/go-whosonfirst-sqlite#custom-tables).\n\n## Dependencies and relationships\n\nThese are documented in the [Dependencies and relationships section](https://github.com/whosonfirst/go-whosonfirst-sqlite#dependencies-and-relationships) of the `go-whosonfirst-sqlite` package.\n\n## See also\n\n* https://sqlite.org/\n\n# See also\n\n* https://github.com/aaronland/go-sqlite\n* https://github.com/whosonfirst/go-whosonfirst-sqlite-index\n* https://github.com/whosonfirst/go-whosonfirst-sqlite-feature-index","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhosonfirst%2Fgo-whosonfirst-sqlite-features","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhosonfirst%2Fgo-whosonfirst-sqlite-features","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhosonfirst%2Fgo-whosonfirst-sqlite-features/lists"}