You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 13, 2024. It is now read-only.
Note that the `-live-hard-die-fast` flag is enabled by default. That is to enable a number of performace-related PRAGMA commands (described [here](https://blog.devart.com/increasing-sqlite-performance.html) and [here](https://www.gaia-gis.it/gaia-sins/spatialite-cookbook/html/system.html)) without which database index can be prohibitive and time-consuming. These is a small but unlikely chance of database corruptions when this flag is enabled.
80
-
81
-
Also note that the `-live-hard-die-fast` flag will cause the `PAGE_SIZE` and `CACHE_SIZE` PRAGMAs to be set to `4096` and `1000000` respectively so the eventual cache size will require 4GB of memory. This is probably fine on most systems where you'll be indexing data but I am open to the idea that we may need to revisit those numbers or at least make them configurable.
82
-
83
-
...creating databases for all the Who's On First repos:
79
+
Or creating databases for all the Who's On First repos:
84
80
85
81
```
86
82
#!/bin/sh
@@ -107,6 +103,77 @@ do
107
103
done
108
104
```
109
105
106
+
#### Inline queries
107
+
108
+
You can also specify inline queries by passing a `-query` parameter which is a string in the format of:
109
+
110
+
```
111
+
{PATH}={REGULAR EXPRESSION}
112
+
```
113
+
114
+
Paths follow the dot notation syntax used by the [tidwall/gjson](https://github.com/tidwall/gjson) package and regular expressions are any valid [Go language regular expression](https://golang.org/pkg/regexp/). Successful path lookups will be treated as a list of candidates and each candidate's string value will be tested against the regular expression's [MatchString](https://golang.org/pkg/regexp/#Regexp.MatchString) method.
115
+
116
+
For example:
117
+
118
+
```
119
+
$> ./bin/wof-sqlite-index-features \
120
+
-all \
121
+
-dsn ca-region.db \
122
+
-query 'properties.wof:placetype=region' \
123
+
-mode repo:// \
124
+
/usr/local/data/whosonfirst-data-admin-ca
125
+
126
+
$> sqlite3 ca-region.db
127
+
128
+
SQLite version 3.28.0 2019-04-15 14:49:49
129
+
Enter ".help" for usage hints.
130
+
sqlite> SELECT id,name,placetype FROM spr;
131
+
85682057|Ontario|region
132
+
85682117|British Columbia|region
133
+
85682065|New Brunswick|region
134
+
85682123|Newfoundland and Labrador|region
135
+
85682067|Northwest Territories|region
136
+
85682075|Nova Scotia|region
137
+
85682081|Prince Edward Island|region
138
+
85682085|Manitoba|region
139
+
85682091|Alberta|region
140
+
85682095|Yukon|region
141
+
85682113|Saskatchewan|region
142
+
136251273|Quebec|region
143
+
85682105|Nunavut|region
144
+
sqlite>
145
+
146
+
```
147
+
148
+
You can pass multiple `-query` parameters. For example:
149
+
150
+
```
151
+
$> ./bin/wof-sqlite-index-features \
152
+
-all \
153
+
-dsn ca-region.db \
154
+
-query 'properties.wof:placetype=region' \
155
+
-query 'properties.wof:name=(?i)new.*'
156
+
-mode repo:// \
157
+
/usr/local/data/whosonfirst-data-admin-ca
158
+
159
+
$> sqlite3 ca-region-new.db
160
+
161
+
SQLite version 3.28.0 2019-04-15 14:49:49
162
+
Enter ".help" for usage hints.
163
+
sqlite> SELECT id,name,placetype FROM spr;
164
+
85682065|New Brunswick|region
165
+
85682123|Newfoundland and Labrador|region
166
+
sqlite>
167
+
```
168
+
169
+
The default query mode is to ensure that all queries match but you can also specify that only one or more queries need to match by passing the `-query-mode ANY` flag:
170
+
171
+
#### SQLite performace-related PRAGMA
172
+
173
+
Note that the `-live-hard-die-fast` flag is enabled by default. That is to enable a number of performace-related PRAGMA commands (described [here](https://blog.devart.com/increasing-sqlite-performance.html) and [here](https://www.gaia-gis.it/gaia-sins/spatialite-cookbook/html/system.html)) without which database index can be prohibitive and time-consuming. These is a small but unlikely chance of database corruptions when this flag is enabled.
174
+
175
+
Also note that the `-live-hard-die-fast` flag will cause the `PAGE_SIZE` and `CACHE_SIZE` PRAGMAs to be set to `4096` and `1000000` respectively so the eventual cache size will require 4GB of memory. This is probably fine on most systems where you'll be indexing data but I am open to the idea that we may need to revisit those numbers or at least make them configurable.
176
+
110
177
### wof-sqlite-query-features
111
178
112
179
Query a search-enabled SQLite database by name(s). Results are output as CSV encoded rows containing `id` and `(wof:)name` properties.
@@ -153,10 +220,35 @@ Full-text search is supported using SQLite's FTS4 indexer. In order to index the
153
220
154
221
## Spatial indexes
155
222
156
-
Yes, if you have the [Spatialite extension](https://www.gaia-gis.it/fossil/libspatialite/index) installed and have indexed the `geometries` table. For example:
223
+
### RTree
224
+
225
+
RTree indexes are available if SQLite has been compiled with the [R*Tree module](https://www.sqlite.org/rtree.html) and you have indexed the [rtree](https://github.com/whosonfirst/go-whosonfirst-sqlite-features#rtree), [spr](https://github.com/whosonfirst/go-whosonfirst-sqlite-features#spr) and [properties](https://github.com/whosonfirst/go-whosonfirst-sqlite-features#properties) tables. For example:
Spatial indexes are also available if you have the [Spatialite extension](https://www.gaia-gis.it/fossil/libspatialite/index) installed and have indexed the `geometries` table. For example:
0 commit comments