curtilage 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +75 -0
- data/README.md +76 -22
- data/SECURITY.md +18 -3
- data/docs/reference.md +221 -27
- data/docs/schema/site-v1.json +362 -0
- data/docs/security.md +69 -0
- data/exe/curtilage +375 -82
- data/lib/curtilage/audit.rb +5 -5
- data/lib/curtilage/auto_data.rb +61 -11
- data/lib/curtilage/batch.rb +116 -0
- data/lib/curtilage/build.rb +117 -63
- data/lib/curtilage/candidates.rb +67 -0
- data/lib/curtilage/catalogue.rb +44 -16
- data/lib/curtilage/confidence.rb +55 -0
- data/lib/curtilage/config.rb +24 -2
- data/lib/curtilage/corrections.rb +57 -0
- data/lib/curtilage/diff.rb +90 -0
- data/lib/curtilage/doctor.rb +92 -0
- data/lib/curtilage/download.rb +42 -16
- data/lib/curtilage/duckdb.rb +170 -6
- data/lib/curtilage/error.rb +3 -0
- data/lib/curtilage/features.rb +54 -5
- data/lib/curtilage/formats.rb +271 -36
- data/lib/curtilage/generator.rb +145 -166
- data/lib/curtilage/generator_details.rb +22 -14
- data/lib/curtilage/generator_lot.rb +56 -32
- data/lib/curtilage/generator_pin.rb +74 -0
- data/lib/curtilage/generator_roads.rb +109 -0
- data/lib/curtilage/generator_steps.rb +54 -0
- data/lib/curtilage/generator_store.rb +18 -4
- data/lib/curtilage/generator_zones.rb +93 -0
- data/lib/curtilage/geometry.rb +48 -52
- data/lib/curtilage/lookup.rb +41 -21
- data/lib/curtilage/overture.rb +137 -17
- data/lib/curtilage/preview.rb +55 -16
- data/lib/curtilage/profiles.rb +62 -0
- data/lib/curtilage/regions.rb +4 -8
- data/lib/curtilage/result.rb +72 -7
- data/lib/curtilage/validation.rb +73 -9
- data/lib/curtilage/version.rb +1 -1
- data/lib/curtilage/zip_range.rb +81 -16
- data/lib/curtilage.rb +155 -17
- data/sql/build_from_shapefiles.sql +1 -1
- metadata +15 -2
data/docs/reference.md
CHANGED
|
@@ -14,21 +14,34 @@ Just the building at a pin (the one its premises would be made from): `{ id:, na
|
|
|
14
14
|
|
|
15
15
|
### `Curtilage.generate_many(pins, **options) → [Result]`
|
|
16
16
|
|
|
17
|
-
Premises for many pins, in pin order. Pins that share map data share the work.
|
|
17
|
+
Premises for many pins, in pin order. Pins that share map data share the work. Every pin is checked before any data is fetched (a bad one raises `ArgumentError` naming it), and so are the generation options; a call takes at most 100,000 pins (`max_pins:` raises the cap; bigger batches are better split). If generating one site raises, that site gets a result with the `error` flag and the error in its explanation, and the rest of the batch goes on; problems fetching map data still raise for the whole call.
|
|
18
18
|
|
|
19
19
|
| Option | Default | What |
|
|
20
20
|
|---|---|---|
|
|
21
|
-
| `source:` | `Curtilage.config.source` (`:auto`) | `:auto`: build a Geofabrik region when enough pins share it (`data: { auto_build_min_pins: 10 }`) or it's already cached, and read scattered pins from Overture Maps. `:geofabrik`: always build the pins' regions (the host learns only the region). `:overture`: always read Overture Maps in place. |
|
|
22
|
-
| `cache_dir:` | `Curtilage.config.cache_dir` (none) | Keep on-demand builds here and reuse them for a month. Without it, builds go to a temporary folder deleted afterwards. |
|
|
21
|
+
| `source:` | `Curtilage.config.source` (`:auto`) | `:auto`: build a Geofabrik region when enough pins share it (`data: { auto_build_min_pins: 10 }`) or it's already cached, and read scattered pins from Overture Maps. `:geofabrik`: always build the pins' regions (the host learns only the region; use this for sensitive location lists). `:overture`: always read Overture Maps in place (its storage host learns roughly where each pin is). See the README's [Privacy](../README.md#privacy) section. |
|
|
22
|
+
| `cache_dir:` | `Curtilage.config.cache_dir` (none) | Keep on-demand builds here and reuse them for a month. Without it, builds go to a temporary folder deleted afterwards. A new folder is created readable only by you; one another user owns, or that everyone can write to, is refused. A cached file that's missing or the wrong size is rebuilt. |
|
|
23
23
|
| `catalogue:` | none | A `Curtilage::Catalogue` of regions built ahead of time (overrides `source:`). |
|
|
24
24
|
| `parquet:` | none | One built file, or a list, local or `s3://`, `gs://`, `https://` (overrides `source:`). |
|
|
25
|
-
| `lookup:` | `{}` | `duckdb:`, `extension_directory:` (default: the configuration), `setup_sql:` (e.g. `CREATE SECRET` for a private bucket), `radius_deg:` (how far around each pin to read, default 0.004). |
|
|
26
|
-
| `data:` | `{}` | For builds: `max_age_days:` (31), `ml_footprints:` (`"microsoft"`), `parallel_builds:` (1; each build peaks near 600 MB, so raise it to 2-3 only on machines with the memory). For `:auto`: `auto_build_min_pins:` (10). For Overture: `release:` (default: the latest). `log:` where build progress goes (anything with `puts`; default standard error). |
|
|
25
|
+
| `lookup:` | `{}` | `duckdb:`, `extension_directory:` (default: the configuration), `setup_sql:` (e.g. `CREATE SECRET` for a private bucket), `radius_deg:` (how far around each pin to read, default 0.004), `memory_limit:` (DuckDB's memory cap for lookups and Overture reads, default `"1GB"`), `timeout:` (seconds before a DuckDB query is stopped, default `Curtilage.config.duckdb_timeout`, 600). |
|
|
26
|
+
| `data:` | `{}` | For builds: `max_age_days:` (31), `ml_footprints:` (`"microsoft"`), `parallel_builds:` (1, at most 8; each build peaks near 600 MB, so raise it to 2-3 only on machines with the memory). An unknown `data:` option raises `ArgumentError`. For `:auto`: `auto_build_min_pins:` (10). For Overture: `release:` (default: the latest; a release name such as `"2026-11-18.0"`). `log:` where build progress goes (anything with `puts`; default standard error). |
|
|
27
27
|
| `preset:` | none | `:whole_lot`, `:tight` or `:centre` (below). |
|
|
28
28
|
| `method:` | none | `:grow_trim` or `:building` to force one method, no fallback. |
|
|
29
|
+
| `corrections:` | `{}` | `{ pin index => ring }` (or `{ ring:, store_ring: }`), 0-based: use these polygons instead of generating ([Corrections](#corrections-and-comparing-runs)). Their pins fetch no data. |
|
|
30
|
+
| `candidates:` | none | 1 to 5: also return other premises for ambiguous sites ([Candidates](#candidates)). |
|
|
29
31
|
| `keep_features:` | `false` | Keep each result's map data in `Result#features` (needed by `Preview` to draw the surroundings). Off by default to save memory on big batches. |
|
|
30
32
|
| any generation option | | See the table below. |
|
|
31
33
|
|
|
34
|
+
### `Curtilage.places(region: or bbox:, category: or brand: or ids:, **options) → [Hash]`
|
|
35
|
+
|
|
36
|
+
Pins from [Overture Maps places](https://docs.overturemaps.org/guides/places/), for when you have no pin list. One filter: `category:` matches any level of Overture's taxonomy (`"pharmacy"`, or `"health_care"` for everything under it) or its basic category; `brand:` the brand's primary name, any case; `ids:` a list of Overture place ids. Where: `region:` (a US state such as `"virginia"`, or a Geofabrik path, matched to its outline from Geofabrik's region index) or `bbox:` `[west, south, east, north]` (at most 400 square degrees). `min_confidence:` (0 to 1) drops places Overture is less sure of; `release:` picks an Overture release; DuckDB options as elsewhere. Places that are permanently or temporarily closed are left out.
|
|
37
|
+
|
|
38
|
+
Each place is `{ id:, name:, brand:, category:, confidence:, sources:, licences:, pin: [lng, lat] }`, sorted by id, at most 100,000. Places carry their own licences by source (most CDLA Permissive 2.0, AllThePlaces CC0, Foursquare Apache 2.0, which asks for its licence and notice to be kept); they're inputs, and premises made from them are ODbL like any other. Reading them tells Overture's storage host which box was read, and a `region:` downloads Geofabrik's region index.
|
|
39
|
+
|
|
40
|
+
```ruby
|
|
41
|
+
places = Curtilage.places(region: "delaware", category: "pharmacy", min_confidence: 0.9)
|
|
42
|
+
results = Curtilage.generate_many(places.map { |p| p[:pin] })
|
|
43
|
+
```
|
|
44
|
+
|
|
32
45
|
### `Curtilage.generate(pin, features, **options) → Result`
|
|
33
46
|
|
|
34
47
|
Premises from features you already have (from `Curtilage::Lookup.features` or `Curtilage::Overture.features_many`), with the same `preset:`, `method:` and generation options.
|
|
@@ -41,18 +54,39 @@ Premises from features you already have (from `Curtilage::Lookup.features` or `C
|
|
|
41
54
|
| `problem` | Why they aren't usable, in words (e.g. `"no premises: no building within 30 m of the pin (it may be missing from OpenStreetMap: try buildings: :osm_filled)"`), or `nil` when `ok?`. |
|
|
42
55
|
| `ring` | The premises: `[[lng, lat], ...]`, closed, convex, at most `max_vertices` corners. `nil` if nothing could be made. |
|
|
43
56
|
| `store_ring` | The store zone: the building's own outline, always inside `ring`. `nil` with `store_zone: false`. |
|
|
57
|
+
| `candidates` | With `candidates: N`, up to N other premises the site could have, most confident first, each a full `Result` ([Candidates](#candidates)); `nil` otherwise. |
|
|
58
|
+
| `approach_ring`, `pickup_ring` | The [zones](#zones), when asked for (`approach_m:`, `pickup_m:`); `nil` otherwise. |
|
|
59
|
+
| `staging_point` | `[lng, lat]` where a driver might wait, estimated, with a pickup zone ([Zones](#zones)); `nil` otherwise. |
|
|
60
|
+
| `entrances` | Where vehicles enter from the street, with the street's name and class (`details[:entrances]`, below); `[]` when none. |
|
|
44
61
|
| `flags` | Reasons a person should look first (below). |
|
|
62
|
+
| `pin_quality` | `{ quality:, building_m:, moved_from: }`: where the pin was given (`on_building`; `on_road`, within half a public road's width of its centreline; `near_building`, a building within `building_max_distance_m`; or `far`), the distance to the nearest building's edge (0 on one, absent with none), and with `snap_m:` the pin as given when it was moved (`pin` is then the moved pin). `nil` for results that raised an error. |
|
|
45
63
|
| `explanation` | Each step, in plain words. |
|
|
64
|
+
| `steps` | The same steps as records, one per line of `explanation` and in the same order, for tools to show or audit (below). |
|
|
46
65
|
| `validation` | `errors`, `warnings` and `metrics` (area, rectangularity, pin inside, distances). |
|
|
47
|
-
| `method_name` | `:grow_trim`, or `:building` after a fallback. |
|
|
66
|
+
| `method_name` | `:grow_trim`, or `:building` after a fallback; `:manual` for a [correction](#corrections-and-comparing-runs). |
|
|
48
67
|
| `building` | The id of the building used. |
|
|
68
|
+
| `attribution` | What to credit wherever the result is shown: OpenStreetMap, plus Overture, Overture's non-OSM building sources or Microsoft's footprints when the result could use them. `nil` means OpenStreetMap only (`Result::OSM_ATTRIBUTION`). |
|
|
49
69
|
| `pin` | The pin it was made for. |
|
|
50
70
|
| `details` | Facts about the site, rough by nature (open map data); `nil` when no premises were made. See below. |
|
|
71
|
+
| `confidence` | How far to trust the result, 0 to 1 (below). `0.0` when not `ok?`. |
|
|
72
|
+
| `confidence_factors` | The factors behind it: `[{ name:, met:, weight: }, ...]`, every factor listed. |
|
|
73
|
+
| `provenance` | What the result was made from, to reproduce or audit it (below). |
|
|
51
74
|
| `features` | The map data it was made from (`Curtilage::Features`, in metres around the pin), or `nil` unless `keep_features: true`. |
|
|
52
75
|
| `to_geojson(include_store: false, properties: {})` | A GeoJSON Feature (premises) with everything above in its properties, including the attribution to show; with `include_store: true`, a FeatureCollection of premises and store zone (`properties.role`). `properties:` are merged into each feature's properties (your own id, say). |
|
|
53
|
-
| `to_wkt`, `store_wkt` | The premises and store zone as well-known text (`POLYGON ((lng lat, ...))`), for databases and spreadsheets. |
|
|
76
|
+
| `to_wkt`, `store_wkt`, `approach_wkt`, `pickup_wkt`, `staging_wkt` | The premises and store zone as well-known text (`POLYGON ((lng lat, ...))`), for databases and spreadsheets. |
|
|
54
77
|
| `buffered(metres)` | The premises grown (positive) or shrunk (negative) evenly, as a closed ring: a geofence with a margin. Corners are rounded when growing. `nil` if there are no premises or they shrink away. |
|
|
55
78
|
|
|
79
|
+
`provenance`:
|
|
80
|
+
|
|
81
|
+
| Key | What |
|
|
82
|
+
|---|---|
|
|
83
|
+
| `gem_version` | The curtilage version that made it. |
|
|
84
|
+
| `data` | `{ source: "overture", release: "2026-11-18.0" }`; `{ source: "geofabrik", regions: [{ region:, extract_dates: [...], ml_footprints: { source:, fetched: } }] }` for builds and catalogues (`ml_footprints` only when the build added them; their source publishes no dates, so `fetched` is the build's date); `{ source: "parquet" }` for a lone `parquet:` file; `nil` when no data covered the pin or features were passed to `generate` directly. |
|
|
85
|
+
| `features_sha256` | A SHA256 of the map data the result was made from, the same whatever order the features came in. Two results with the same hash, version and options used the same inputs. |
|
|
86
|
+
| `options` | Every generation option after defaults and presets. |
|
|
87
|
+
|
|
88
|
+
It holds no timestamps: the same pins, options and data give the same output, byte for byte, whatever order the map data arrives in. Results that failed with an error carry only `gem_version`.
|
|
89
|
+
|
|
56
90
|
`details`:
|
|
57
91
|
|
|
58
92
|
| Key | What |
|
|
@@ -62,10 +96,11 @@ Premises from features you already have (from `Curtilage::Lookup.features` or `C
|
|
|
62
96
|
| `parking_spaces_estimate` | That area over 25 m2 a space (aisles included). Unmapped parking counts as none. |
|
|
63
97
|
| `frontage_m` | Length of premises edges running along a public road. |
|
|
64
98
|
| `access_points` | `[[lng, lat], ...]`: where driveways taken into the premises meet the street (entrances within 10 m are counted once). |
|
|
99
|
+
| `entrances` | The same entrances with what they open onto: `[{ point: [lng, lat], street:, street_class:, street_id:, driveway: }, ...]` (`street` is the street's name, `nil` when unnamed; `driveway` the driveway's id). Also `Result#entrances`. |
|
|
65
100
|
|
|
66
101
|
### Errors
|
|
67
102
|
|
|
68
|
-
Every error the gem raises on purpose is a `Curtilage::Error` (or a subclass: `Lookup::Error`, `Overture::Error`, `Build::Error`, `Download::Error`, `Footprints::Error`, `ZipRange::Unsupported`, `ZipRange::Corrupt`), so `rescue Curtilage::Error` catches them all. Mistakes in what you pass (a bad pin, option or file) raise `ArgumentError`. A missing DuckDB binary is a `Curtilage::Error` saying what to install.
|
|
103
|
+
Every error the gem raises on purpose is a `Curtilage::Error` (or a subclass: `Lookup::Error`, `Overture::Error`, `Build::Error`, `Download::Error`, `Footprints::Error`, `ZipRange::Unsupported`, `ZipRange::Corrupt`), so `rescue Curtilage::Error` catches them all. Mistakes in what you pass (a bad pin, option or file) raise `ArgumentError`. A missing DuckDB binary, or extensions that won't load, is a `Curtilage::DependencyError` (a `Curtilage::Error`) saying what to install.
|
|
69
104
|
|
|
70
105
|
### Presets
|
|
71
106
|
|
|
@@ -77,9 +112,25 @@ Every error the gem raises on purpose is a `Curtilage::Error` (or a subclass: `L
|
|
|
77
112
|
|
|
78
113
|
Any option passed with a preset overrides it.
|
|
79
114
|
|
|
115
|
+
**Your own profiles.** `Curtilage::Profiles.load(path)` reads named sets of generation options from a JSON (`.json`) or YAML (`.yml`, `.yaml`) file and returns `{ name => options }` to pass to `generate` or `generate_many`. A profile may start from a built-in `preset:`; names (`method`, `scope`, `buildings`, `preset`) are written as text. Every profile is checked like options passed directly, so a mistake fails at load, naming the profile. Files are capped at 1 MB and 100 profiles; YAML is read safely (no aliases or objects).
|
|
116
|
+
|
|
117
|
+
```yaml
|
|
118
|
+
big_box:
|
|
119
|
+
preset: whole_lot
|
|
120
|
+
parking_max_extent_m: 150
|
|
121
|
+
validation: { max_area_error_m2: 300000 }
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
```ruby
|
|
125
|
+
options = Curtilage::Profiles.load("profiles.yml")[:big_box]
|
|
126
|
+
Curtilage.generate_many(pins, **options)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
On the command line: `--profiles FILE --preset big_box`; other flags given with it override the profile.
|
|
130
|
+
|
|
80
131
|
### Generation options
|
|
81
132
|
|
|
82
|
-
All distances in metres, areas in square metres. These are `Curtilage::Generator::DEFAULTS`. An unknown or misspelt option raises `ArgumentError
|
|
133
|
+
All distances in metres, areas in square metres. These are `Curtilage::Generator::DEFAULTS`. An unknown or misspelt option raises `ArgumentError`, and so does a value out of range: distances must be 0 to 1,000 m, areas 0 to 10,000,000 m2, `max_vertices` a whole number from 4 to 50, `max_store_vertices` from 3 to 200, `shared_lot_buildings` from 1 to 1,000, `precision` a whole number from 5 to 15 (`Generator::RANGES`).
|
|
83
134
|
|
|
84
135
|
| Option | Default | What |
|
|
85
136
|
|---|---|---|
|
|
@@ -105,6 +156,111 @@ All distances in metres, areas in square metres. These are `Curtilage::Generator
|
|
|
105
156
|
| `building_margin_m` | `20` | The fallback's margin around the building rectangle. |
|
|
106
157
|
| `max_vertices` | `10` | The premises are simplified to at most this many corners (never cutting the building). |
|
|
107
158
|
| `max_store_vertices` | `20` | The store outline is simplified to at most this many corners. |
|
|
159
|
+
| `validation` | `{}` | Limits for the validation every polygon goes through (below), e.g. `{ max_area_error_m2: 300_000 }` for a big-box store's lot. |
|
|
160
|
+
| `snap_m` | `nil` | Move a pin that isn't on any building 1 m inside the nearest one within this distance (real buildings before kiosks), then generate from there. Flags `pin_moved`; `pin_quality` keeps where it was given. Useful for geocoded pins that land on the street, which otherwise pull the premises toward the road (they always hold the pin). |
|
|
161
|
+
| `approach_m` | `nil` | Also make an approach zone: the premises grown by this much, for "customer is near" (see [Zones](#zones)). `Generator::DEFAULT_APPROACH_M` is 150. |
|
|
162
|
+
| `pickup_m` | `nil` | Also make an estimated pickup zone: mapped parking within this much of the building ([Zones](#zones)). `Generator::DEFAULT_PICKUP_M` is 25. |
|
|
163
|
+
| `precision` | `7` | Decimal places in output coordinates (7 is about 1 cm). Validation checks the rounded polygon. |
|
|
164
|
+
|
|
165
|
+
#### Validation limits
|
|
166
|
+
|
|
167
|
+
`Curtilage::Validation::DEFAULTS`, changed with the `validation:` option (or passed to `Validation.check`). Values must be positive numbers; an unknown limit raises `ArgumentError`.
|
|
168
|
+
|
|
169
|
+
| Limit | Default | What |
|
|
170
|
+
|---|---|---|
|
|
171
|
+
| `min_area_m2` | `1000` | Warn (`small`) below this area. |
|
|
172
|
+
| `max_area_m2` | `40000` | Warn (`large`) above this area. |
|
|
173
|
+
| `max_area_error_m2` | `100000` | Error (`too_large`) above this area: a block, not one site's lot. |
|
|
174
|
+
| `max_vertex_distance_m` | `1000` | Error (`too_far_from_pin`) if any corner is further than this from the pin. |
|
|
175
|
+
| `max_vertices` | `50` | Error (`too_many_vertices`) above this many corners. |
|
|
176
|
+
| `off_centre_m` | `200` | Warn (`off_centre`) if the polygon's centre is further than this from the pin. |
|
|
177
|
+
| `swap_far_m`, `swap_near_m` | `10000`, `1000` | Error (`swapped`) when the polygon is further than `swap_far_m` from the pin but within `swap_near_m` of it with longitude and latitude swapped. |
|
|
178
|
+
|
|
179
|
+
### Corrections and comparing runs
|
|
180
|
+
|
|
181
|
+
To fix the few bad sites once and trust the rest:
|
|
182
|
+
|
|
183
|
+
- **Corrections.** `generate_many(pins, corrections: { 3 => ring })`, or `Curtilage::Corrections.result(pin, ring, store_ring: nil)` for one site, returns the polygon you give instead of generating it: `method_name` `:manual`, `provenance` `{ gem_version:, data: { source: "manual" } }`, a `manual` step, validated like any polygon (with the `validation:` limits passed), so an invalid one is returned not `ok?`, saying why. A store zone that isn't a valid ring inside the premises is dropped, with a step. A valid correction has confidence 1.0 (the factors are just `valid`). On the command line, `--corrections FILE` (GeoJSON or NDJSON) matches polygons to sites by id; this gem's own output, edited in a GIS, works as is.
|
|
184
|
+
- **Comparing runs.** `curtilage diff OLD NEW` (or `Curtilage::Diff.compare(old, new, threshold: 0.9)` on two `Formats.read_results`) compares two result files site by site: `status` (`same`, `changed`, `added`, `removed`), IoU of the premises, both areas and the change in percent, `ok` before and after, flags gained and lost, and confidence before and after. A site needs `review` when it was added or removed, gained or lost premises, changed `ok`, gained a flag, or its premises overlap the old ones less than the threshold. It prints CSV (or `--format ndjson`, or `--out FILE`), says how many need review on standard error, and exits 1 when any do.
|
|
185
|
+
- **Keeping results stable.** The same pins, options and data give byte-identical results (see `provenance`), so a rerun only changes sites whose map data changed; re-applying your corrections keeps your fixes, and `diff` against the last run lists the sites worth a look.
|
|
186
|
+
|
|
187
|
+
`Formats.read_results(path)` reads a GeoJSON or NDJSON result file back as `{ id => { ring:, store_ring:, properties: } }` (premises and store zone; other zones skipped; rings of up to 1,000 vertices; files up to 50 MB).
|
|
188
|
+
|
|
189
|
+
### Candidates
|
|
190
|
+
|
|
191
|
+
When a site is ambiguous, `candidates: N` (1 to 5, on `generate`, `generate_many` or `premises`; `--candidates N` on the command line) also returns up to N other premises in `Result#candidates`, for a reviewer or a downstream system to choose from. The main result is unchanged. Alternatives come from:
|
|
192
|
+
|
|
193
|
+
- **another building** within `building_max_distance_m` of the pin (not a kiosk), in case the pin is on the wrong one: generated as if the pin were on it, flagged `pin_moved`, with `pin_quality.moved_from` the pin as given;
|
|
194
|
+
- **the whole shopping centre** (`scope: :centre`) when the site's lot is shared;
|
|
195
|
+
- **the building rectangle** (`method: :building`) when confidence is below 0.7 (`Candidates::LOW_CONFIDENCE`).
|
|
196
|
+
|
|
197
|
+
Only valid ones that differ from the main result and from each other are kept, most confident first. Each starts with a `candidate` step saying what it is. Each candidate is a full generation, so a call takes a few times longer. In GeoJSON each is a feature with `role` `candidate` and `rank`; in NDJSON, `properties.candidates` (rank, geometry, confidence, flags, building, method, explanation); in CSV, the `candidates` column counts them; in KML, placemarks; the preview draws them dashed.
|
|
198
|
+
|
|
199
|
+
### Zones
|
|
200
|
+
|
|
201
|
+
For arrival detection, two optional zones nest with the premises and store zone: approach ⊇ premises ⊇ store zone and pickup zone. Every zone is checked as a shape (closed, valid coordinates, not crossing itself) and dropped with a step if it fails; only the premises get the size limits.
|
|
202
|
+
|
|
203
|
+
- **Approach** (`approach_m:`): the premises grown by that many metres with rounded corners, then simplified to at most 16 corners by dropping only corners that keep every premises corner inside. "The customer is near." It may cross roads; the premises never do.
|
|
204
|
+
- **Pickup** (`pickup_m:`): the largest piece of mapped parking within that many metres of the building's rectangle, kept inside the premises. Neither OpenStreetMap extracts (Geofabrik's free shapefiles) nor Overture carry pickup or curbside spots or entrances, so it's always estimated (`estimated: true` on its GeoJSON feature): the parking right by the store, not marked bays. `nil` (with a step saying so) when no mapped parking is that close.
|
|
205
|
+
- **Staging point** (with a pickup zone): the pickup zone's point nearest the building, where a driver might wait. Estimated like the zone.
|
|
206
|
+
|
|
207
|
+
Building entrances (`entrance=*`) and drive-through lanes (`service=drive-through`) aren't in either data source today (Geofabrik's free shapefiles drop those tags; Overture has no entrances and no drive-through subclass), so they aren't output. Driveway entrances from the street are (`details[:entrances]`).
|
|
208
|
+
|
|
209
|
+
In GeoJSON they're extra features with `properties.role` `approach`, `pickup` and `staging` (a Point); in NDJSON, geometries in `properties.approach`, `properties.pickup` and `properties.staging`; in CSV, `approach_wkt`, `pickup_wkt` and `staging_wkt`; in KML, placemarks; the preview draws them.
|
|
210
|
+
|
|
211
|
+
### Steps
|
|
212
|
+
|
|
213
|
+
`Result#steps` (GeoJSON and NDJSON `steps`) is the explanation as records: `{ step:, text:, rule:, features:, distance_m:, area_before_m2:, area_after_m2:, flag: }`. `step` and `text` (the line of `explanation`) are always there; the rest only when they apply. `rule` names the option (from [Generation options](#generation-options)) or rule that set the distance, `features` are the map-data ids involved, and the areas are the premises in whole square metres before and after the step changed them.
|
|
214
|
+
|
|
215
|
+
| `step` | What happened | `rule` |
|
|
216
|
+
|---|---|---|
|
|
217
|
+
| `data` | Where the map data came from, or that it's missing or partial (`flag`). | |
|
|
218
|
+
| `fallback` | A method failed validation; the next was tried. | the method that failed |
|
|
219
|
+
| `error` | Generation raised an error (flag `error`). | |
|
|
220
|
+
| `drop_features` | Unusable map features were dropped. | |
|
|
221
|
+
| `find_building` | The building under the pin, the nearest one in reach, or none. | `building_max_distance_m` when not under the pin |
|
|
222
|
+
| `check_building`, `check_store` | The building's size or source raised a flag or a note. | `small_building_m2`, `large_building_m2`, `large_building_note_m2` |
|
|
223
|
+
| `grow` | The building's rectangle grown toward its lot. | `grow_m`, or `building_margin_m` (fallback) |
|
|
224
|
+
| `trim_road` | Trimmed at a public road or railway (one step per road). | `road_class_half_width`, `road_offset_m`, or `clearance` when the building or pin clearance kept the cut closer to the centreline |
|
|
225
|
+
| `keep_road_side` | A road wasn't trimmed at because the cut would cross the building. | |
|
|
226
|
+
| `claim_lot` | Parking, a garage or a canopy is the site's lot. | `parking_reach_m`, or `shared_lot_buildings` for a shared lot |
|
|
227
|
+
| `share_lot` | A claimed lot also touches other buildings. | |
|
|
228
|
+
| `split_neighbour` | Cut short of, or halfway to, a neighbouring building. | `neighbour_gap_m` or `halfway` |
|
|
229
|
+
| `keep_neighbour` | A neighbour touching the building couldn't be split off. | |
|
|
230
|
+
| `take_driveway` | A driveway to the street was taken in. | `ENTRANCE_REACH_M` |
|
|
231
|
+
| `add_lot` | The claimed lot was added to the premises. | `parking_max_extent_m` |
|
|
232
|
+
| `keep_off_neighbour` | Kept 1 m off a neighbour the lot reached. | |
|
|
233
|
+
| `whole_centre` | The whole shopping centre (`scope: :centre`). | |
|
|
234
|
+
| `widen`, `simplify` | The premises widened to hold the building, or simplified. | `max_vertices` for `simplify` |
|
|
235
|
+
| `trim_store` | The store outline trimmed to fit inside the premises. | |
|
|
236
|
+
| `approach_zone` | The approach zone made (or dropped). | `approach_m` |
|
|
237
|
+
| `pickup_zone` | The pickup zone estimated from a parking lot, or none found. | `pickup_m` |
|
|
238
|
+
| `staging_point` | The staging point placed. | |
|
|
239
|
+
| `candidate` | What a candidate is (first step of each `Result#candidates`). | `scope` or `method` for those alternatives |
|
|
240
|
+
| `manual` | The polygon is a correction, not generated. | |
|
|
241
|
+
| `snap_pin` | The pin moved onto the nearest building (flag `pin_moved`). | `snap_m` |
|
|
242
|
+
|
|
243
|
+
New step names may be added in minor versions; treat an unknown one as a plain note.
|
|
244
|
+
|
|
245
|
+
### Confidence
|
|
246
|
+
|
|
247
|
+
`Result#confidence` orders results for review: flags say what to look at, confidence says where to look first. It's rule-based (no learning): each factor that isn't met takes its weight off 1, never below 0, rounded to 2 places. The factors are `Curtilage::Confidence::FACTORS`:
|
|
248
|
+
|
|
249
|
+
| Factor | Weight | Met when |
|
|
250
|
+
|---|---|---|
|
|
251
|
+
| `valid` | 1.0 | The premises passed validation. |
|
|
252
|
+
| `main_method` | 0.30 | Made by the main method (no `fallback`). |
|
|
253
|
+
| `building_under_pin` | 0.20 | The pin was given on the building used (no `building_not_under_pin` or `pin_moved`). |
|
|
254
|
+
| `full_data` | 0.20 | Map data covers the whole area around the pin (no `partial_data`). |
|
|
255
|
+
| `plausible_building` | 0.15 | The building is big enough to be a store (no `small_building`). |
|
|
256
|
+
| `mapped_parking` | 0.15 | Mapped parking is inside the premises. |
|
|
257
|
+
| `road_frontage` | 0.15 | At least one side of the premises runs along a public road. |
|
|
258
|
+
| `osm_building` | 0.10 | The building is from OpenStreetMap (no `ml_footprint`). |
|
|
259
|
+
| `single_building_store` | 0.10 | The building is small enough to be one store (no `large_building` or `store_may_be_unit`). |
|
|
260
|
+
| `no_homes_next_door` | 0.10 | No home borders the lot (no `near_houses`). |
|
|
261
|
+
| `no_warnings` | 0.05 | Validation raised no warnings. |
|
|
262
|
+
|
|
263
|
+
The weights are judgement for now, to be calibrated on the public benchmark once its reference polygons are drawn; treat the score as an order, not a probability. Data age isn't a factor, so the same inputs always score the same.
|
|
108
264
|
|
|
109
265
|
### Flags
|
|
110
266
|
|
|
@@ -116,29 +272,36 @@ The same list is `Curtilage::FLAGS` (flag => what it asks a person to check).
|
|
|
116
272
|
| `large_building` | Building over 5,000 m2: may be shared by several tenants. |
|
|
117
273
|
| `small_building` | Building under 50 m2: may be a kiosk or canopy rather than the store. |
|
|
118
274
|
| `building_not_under_pin` | No building under the pin; the nearest one within 30 m was used. |
|
|
275
|
+
| `pin_moved` | The pin wasn't on a building and was moved onto the nearest one (`snap_m:`): check it's the right one. |
|
|
119
276
|
| `store_may_be_unit` | The store zone is a building over 1,500 m2: the store may be one unit of it. |
|
|
120
277
|
| `shopping_centre` | `scope: :centre` mapped the whole centre. |
|
|
121
278
|
| `fallback` | The main method failed validation; the building rectangle was used. |
|
|
122
279
|
| `ml_footprint` | Built on a machine-learned footprint, not an OSM building. |
|
|
123
280
|
| `no_data` | No map data covers the pin. |
|
|
281
|
+
| `error` | Generating this site raised an error (see its explanation); the rest of the batch went on. |
|
|
124
282
|
| `partial_data` | Part of the area around the pin is in a region that isn't built (a hand-built catalogue near a border): buildings or roads there are missing. |
|
|
125
283
|
|
|
126
284
|
### Files: `Curtilage::Formats`
|
|
127
285
|
|
|
128
286
|
Reading pins:
|
|
129
287
|
|
|
130
|
-
- `Formats.read_pins(path)`: pins from a `.csv` or `.
|
|
288
|
+
- `Formats.read_pins(path, format: nil)`: pins from a `.csv`, `.geojson`/`.json` or `.ndjson`/`.jsonl` file, as `[{ id:, pin: [lng, lat] }, ...]`. `Formats.parse_pins(text, :csv | :geojson | :ndjson)` does the same from a string.
|
|
131
289
|
- CSV: a header row, then one pin per row. Longitude is the column named `lng`, `lon`, `long` or `longitude`; latitude is `lat` or `latitude`; the id, if any, is `id`, `site_id` or `name` (names are case-insensitive). Quoted fields, a byte-order mark and blank lines are fine.
|
|
132
290
|
- GeoJSON: a FeatureCollection of Point features (or one Point feature). The id is the feature's `id`, or its `id` or `name` property.
|
|
133
|
-
-
|
|
291
|
+
- NDJSON (`.ndjson`/`.jsonl`, or `:ndjson`): one site per line, as `{"id": "a", "lng": -80.1, "lat": 35.2}` (any of the CSV column names), `{"id": "a", "pin": [-80.1, 35.2]}` or a GeoJSON Point Feature. Blank lines are skipped; a bad line is named by number.
|
|
292
|
+
- Pins without an id are numbered from 1. Files are capped at 50 MB and 100,000 pins; CSV fields (and ids) at 10,000 characters and rows at 1,000 columns; GeoJSON nesting at 20 levels. Files must be UTF-8 (a byte-order mark is fine) without NUL bytes.
|
|
293
|
+
- Coordinates must be plain decimal numbers (`-80.25`, `35`, `1e-3`), longitude first, longitude within 180 and latitude within 90. Hexadecimal, underscores (`1_0`), `NaN` and infinite values are refused with the line or feature named. Every entry point (Ruby calls, `--pin`, files) checks pins the same way.
|
|
134
294
|
|
|
135
295
|
Writing results: `Formats.write(results, format, ids: nil, store: true)` returns text.
|
|
136
296
|
|
|
137
297
|
| Format | What |
|
|
138
298
|
|---|---|
|
|
139
|
-
| `:geojson` | One FeatureCollection: for each pin, its premises
|
|
140
|
-
| `:
|
|
141
|
-
| `:
|
|
299
|
+
| `:geojson` | One FeatureCollection: for each pin, its premises, (unless `store: false`) its store zone, and any [zones](#zones) asked for, with `properties.id`, `properties.role` and everything `to_geojson` carries. |
|
|
300
|
+
| `:ndjson` | One line per pin: a GeoJSON Feature of its premises (`geometry` is `null` when none could be made) with everything `to_geojson` carries in its properties, the store zone's geometry in `properties.store` (absent with `store: false`), and any [zones](#zones) in `properties.approach` and `properties.pickup`. The schema is [`docs/schema/site-v1.json`](schema/site-v1.json) (it ships in the gem); version 1 only gains optional properties, and anything that would break a reader gets a new schema version. |
|
|
301
|
+
| `:csv` | One row per pin. Columns: `id`, `lng`, `lat`, `ok`, `problem`, `method`, `flags` and `errors` (`;`-separated), `building`, `building_area_m2`, `parking_area_m2`, `parking_spaces_estimate`, `frontage_m`, `premises_area_m2`, `premises_wkt`, `store_wkt`, `attribution` (`; `-separated), then `gem_version`, `data_source`, `data_release` (the Overture release or the Geofabrik extract dates, `;`-separated) and `features_sha256` from `provenance` (the options are only in GeoJSON), then `confidence`, `approach_wkt`, `pickup_wkt` and `staging_wkt` (empty unless asked for), then `pin_quality` and `candidates` (how many). Cells a spreadsheet would run as a formula (starting with `=`, `+`, `-`, `@`, `|` or `%`, or their full-width forms, even after spaces) get a leading `'`; plain numbers don't. |
|
|
302
|
+
| `:kml` | A placemark per polygon (premises, store zone and any zones) and per point (driveway entrances, named by their street, and the staging point), with the confidence, flags, attribution, gem version and data release in its description, and every source credited in the document's description, for Google Earth. |
|
|
303
|
+
|
|
304
|
+
`Formats.write_places(places, :csv | :ndjson | :geojson)` writes places as pins: `id`, `lng`, `lat` (which `read_pins` reads back), `name`, `brand`, `category`, `place_confidence`, `place_sources`, `place_licences`.
|
|
142
305
|
|
|
143
306
|
`Formats.format_of(path)` names the format a file extension stands for.
|
|
144
307
|
|
|
@@ -148,18 +311,23 @@ Writing results: `Formats.write(results, format, ids: nil, store: true)` returns
|
|
|
148
311
|
|
|
149
312
|
- A map 240 m across, north up, with a 50 m scale bar: the premises, store zone and pin; the site's building (darker) and other buildings, mapped parking, public roads (hover for the name), service roads and driveways, railways; driveway entrances (blue dots); with `buffer_m:`, the premises grown by that much (dashed).
|
|
150
313
|
- Under it: the flags (hover for their meaning), the building and premises areas, parking area and estimated spaces, street frontage, the number of entrances, and the step-by-step explanation. Invalid results say why.
|
|
151
|
-
- At the top, a count of sites that are ok, flagged or without usable premises, and two controls: **Show** (all sites; those that need a look, meaning flagged or not valid; not valid; ok with no flags; or those with a given flag, with counts) and **Sort by** (input order, needs a look first, id, largest or smallest premises). The choice is remembered in the browser. The controls are a short inline script; without it every card shows, in input order.
|
|
314
|
+
- At the top, a count of sites that are ok, flagged or without usable premises, and two controls: **Show** (all sites; those that need a look, meaning flagged or not valid; not valid; ok with no flags; or those with a given flag, with counts) and **Sort by** (input order, needs a look first, lowest confidence first, id, largest or smallest premises). Each card shows its confidence. The choice is remembered in the browser. The controls are a short inline script; without it every card shows, in input order.
|
|
152
315
|
|
|
153
|
-
The surroundings come from `Result#features`, so pass results from `generate_many(pins, keep_features: true)`; without them only the premises, store zone and entrances are drawn. The page loads nothing from the internet (no tiles, scripts or fonts), so opening it reveals no locations; it does contain the coordinates, so share it only as you would them.
|
|
316
|
+
The surroundings come from `Result#features`, so pass results from `generate_many(pins, keep_features: true)`; without them only the premises, store zone and entrances are drawn. The page loads nothing from the internet (no tiles, scripts or fonts), so opening it reveals no locations; it does contain the coordinates, so share it only as you would them. Its Content-Security-Policy allows only its own inline style and script, and text from map data is escaped.
|
|
154
317
|
|
|
155
318
|
### Other entry points
|
|
156
319
|
|
|
157
320
|
- `Curtilage::Audit.check(pin, ring, features, thresholds: {}, **options)`: checks an existing polygon. Returns a report with `verdict` (`:ok`, `:review`, `:invalid`), `reasons` (`crosses_road`, `covers_neighbour`, `differs_from_generated`, validation warnings), `overlap`, `road_m`, `neighbour_m2` and the `generated` result.
|
|
158
321
|
- `Curtilage::Validation.check(pin, ring, **thresholds)`: the checks every polygon goes through.
|
|
159
|
-
- `Curtilage::Build.run(region, out_dir:, work_dir:, **options)`: build a region's files ahead of time (`date:`, `ml_footprints:`, `memory_limit:` `"400MB"
|
|
322
|
+
- `Curtilage::Build.run(region, out_dir:, work_dir:, **options)`: build a region's files ahead of time (`date:`, `ml_footprints:`, `memory_limit:` `"400MB"` (a size such as `"2GB"`), `threads:` `1` (1 to 64), `timeout:` `3600` seconds for the build query, `keep_downloads:`). Downloads retry network hiccups (3 tries) and use `curl` when available. Each build records its region's outline from Geofabrik's index, and the size and SHA256 of every file it downloaded (`sources`, `ml_sources` in the region's `.json`); rebuilding the same dated extract warns if any of them changed.
|
|
160
323
|
- `Curtilage::Catalogue.from_dir(dir, base_url: nil)`: the regions built into a folder; `base_url:` when the Parquet files live in a bucket. It uses each region's recorded outline to decide which files cover a pin, and `coverage(pin)` says whether that's `:full`, `:partial` or `:none`.
|
|
161
324
|
- `Curtilage::Lookup.features(parquet:, pin:)` / `features_many(parquet:, pins:)`: the map features around pins, from built files.
|
|
162
325
|
- `Curtilage::Overture.features_many(pins)`: the map features around pins, from Overture Maps.
|
|
326
|
+
- `Curtilage::Overture.places(bbox:, ...)`: what `Curtilage.places` reads, for a box only.
|
|
327
|
+
|
|
328
|
+
## Data licence
|
|
329
|
+
|
|
330
|
+
Results are derived from OpenStreetMap data under the [ODbL 1.0](https://opendatacommons.org/licenses/odbl/1-0/), so they keep its terms, not the code's MIT licence. Credit OpenStreetMap wherever results are shown ([OSMF attribution guidelines](https://osmfoundation.org/wiki/Licence/Attribution_Guidelines)); every output carries what to credit (`Result#attribution`, the GeoJSON `attribution` property, the CSV `attribution` column, the KML description, the preview page). Storing or publishing many results can make a derivative database with ODbL share-alike obligations (section 4.4); a map image or other produced work needs a notice (section 4.3). Overture data also credits the Overture Maps Foundation and, when used, Overture's non-OSM building sources; Microsoft's footprints are under [CDLA Permissive 2.0](https://cdla.dev/permissive-2-0/). See the README's [Data licence](../README.md#data-licence) section and the OSMF [community guidelines](https://osmfoundation.org/wiki/Licence/Community_Guidelines). Not legal advice.
|
|
163
331
|
|
|
164
332
|
## Configuration
|
|
165
333
|
|
|
@@ -171,7 +339,10 @@ Set once instead of passing on every call. Defaults come from the environment.
|
|
|
171
339
|
| `extension_directory` | `CURTILAGE_EXTENSIONS` | DuckDB's own |
|
|
172
340
|
| `cache_dir` | `CURTILAGE_CACHE_DIR` | none (temporary folders) |
|
|
173
341
|
| `source` | `CURTILAGE_SOURCE` | `auto` |
|
|
174
|
-
| | `
|
|
342
|
+
| `offline` | `CURTILAGE_OFFLINE` | off. `1`: never use the network: extensions are loaded but not installed (populate the folder first, e.g. with `curtilage doctor`), every download is refused, and so are Overture and bucket reads; prebuilt catalogues and cached builds still work |
|
|
343
|
+
| `duckdb_timeout` | `CURTILAGE_DUCKDB_TIMEOUT` | `600` seconds per lookup or Overture query; DuckDB is then stopped, with anything it started |
|
|
344
|
+
| | `CURTILAGE_CURL` | Downloads use the `curl` command when it's installed (optional, much faster); `0` forces Ruby's own HTTP client |
|
|
345
|
+
| | `HTTPS_PROXY`, `NO_PROXY` | Downloads go through this proxy (both with and without `curl`), except to hosts `NO_PROXY` covers. DuckDB's own reads (Overture, buckets) use DuckDB's `http_proxy` setting, which `lookup: { setup_sql: }` can set. |
|
|
175
346
|
|
|
176
347
|
```ruby
|
|
177
348
|
Curtilage.configure do |c|
|
|
@@ -185,32 +356,55 @@ DuckDB's `spatial` and `httpfs` extensions install themselves on first use.
|
|
|
185
356
|
## Command line
|
|
186
357
|
|
|
187
358
|
```
|
|
188
|
-
curtilage generate (--pin LNG,LAT ... | --in FILE) [--out FILE] [options]
|
|
359
|
+
curtilage generate (--pin LNG,LAT ... | --in FILE|-) [--out FILE] [options]
|
|
189
360
|
curtilage preview (--pin LNG,LAT ... | --in FILE) [--out FILE] [options]
|
|
361
|
+
curtilage places (--region NAME | --bbox W,S,E,N) (--category NAME | --brand NAME | --place-id ID ...)
|
|
362
|
+
curtilage diff OLD NEW [--threshold IOU] [--out FILE]
|
|
190
363
|
curtilage build REGION [options]
|
|
191
364
|
curtilage doctor
|
|
192
365
|
```
|
|
193
366
|
|
|
194
367
|
- `generate`: premises and store zones for one or more pins.
|
|
195
|
-
- Pins: `--pin LNG,LAT` (repeat for several; ids 1, 2, ...) and/or `--in FILE` (CSV or
|
|
196
|
-
- Output: printed as GeoJSON, or `--out FILE` in the format its extension names (`.geojson`/`.json`, `.csv`, `.kml`). `--format geojson|csv|kml` overrides.
|
|
368
|
+
- Pins: `--pin LNG,LAT` (repeat for several; ids 1, 2, ...) and/or `--in FILE` (CSV, GeoJSON or NDJSON; see [Files](#files-curtilageformats)). `--in -` reads standard input, as NDJSON unless `--in-format csv|geojson|ndjson` says otherwise; `--in-format` also overrides a file's extension.
|
|
369
|
+
- Output: printed as GeoJSON, or `--out FILE` in the format its extension names (`.geojson`/`.json`, `.ndjson`/`.jsonl`, `.csv`, `.kml`). `--format geojson|ndjson|csv|kml` overrides. The file is written whole (to a temporary name, then renamed) and replaces any file there; a symbolic link at that path is refused.
|
|
197
370
|
- Data: `--source auto|geofabrik|overture` (default auto), `--cache-dir DIR`, `--catalogue DIR`, `--parquet FILE`.
|
|
198
|
-
- Style: `--preset whole_lot|tight|centre`, `--buildings osm|osm_filled|ml`, `--[no-]store`.
|
|
371
|
+
- Style: `--preset whole_lot|tight|centre` or a profile name with `--profiles FILE`, `--buildings osm|osm_filled|ml`, `--[no-]store`.
|
|
372
|
+
- Corrections: `--corrections FILE` uses your polygons for sites with the same id ([Corrections](#corrections-and-comparing-runs)).
|
|
373
|
+
- Ambiguous sites: `--candidates N` (1 to 5) adds up to N other premises ([Candidates](#candidates)).
|
|
374
|
+
- Pins: `--snap [METRES]` (default 30) moves pins that aren't on a building onto the nearest one (`snap_m:`).
|
|
375
|
+
- Zones: `--approach [METRES]` (default 150) and `--pickup [METRES]` (default 25) add the [zones](#zones).
|
|
199
376
|
- DuckDB: `--duckdb PATH`, `--extension-directory DIR`.
|
|
200
|
-
-
|
|
377
|
+
- Big batches: sites are generated in chunks of 500 (`Curtilage::Batch`). NDJSON and CSV are written as each chunk finishes, so memory stays flat: to standard output directly, or with `--out FILE` into `.FILE.part` next to it, renamed to `FILE` when the run finishes (so `FILE` never holds half a run). `--resume` carries on an interrupted run from that `.part` file, skipping sites already in it and redoing a line cut short by a crash; it needs `--out` with `.ndjson` or `.csv` and unique site ids. GeoJSON and KML are written whole at the end. Progress (sites done, rate, time left) goes to standard error when it's a terminal, or always with `--progress`. Without `--cache-dir`, a Geofabrik region the run builds is kept in a temporary cache for the whole run, so chunks don't rebuild it.
|
|
378
|
+
- `--min-confidence N` (0 to 1) leaves out results whose confidence is below N, and says how many on standard error; the exit code is then 1, as some sites weren't written.
|
|
379
|
+
- Logs: `--quiet` keeps only warnings and errors; `--log-format json` writes each log line as `{"level": "info"|"warning"|"error", "message": "..."}`.
|
|
201
380
|
- `preview`: generates the same way (same options, except `--format`), then writes the page described under [Preview](#preview-curtilagepreview). `--out FILE` (default `curtilage-preview.html`); `--buffer METRES` also draws the premises grown by that much.
|
|
202
|
-
- `
|
|
203
|
-
- `
|
|
381
|
+
- `diff OLD NEW`: compares two result files ([Comparing runs](#corrections-and-comparing-runs)). `--threshold IOU` (default 0.9), `--out FILE`, `--format csv|ndjson`. Exits 1 when any site needs review.
|
|
382
|
+
- `places (--region NAME | --bbox W,S,E,N) (--category NAME | --brand NAME | --place-id ID ...)`: pins from Overture Maps places (`Curtilage.places`), as CSV (default), NDJSON or GeoJSON, printed or `--out FILE`. Also `--min-confidence N`, `--release NAME`, the DuckDB and log flags. Its output feeds `generate --in` directly: `curtilage places --region delaware --category pharmacy | curtilage generate --in - --in-format csv`.
|
|
383
|
+
- `build REGION` writes `REGION.parquet` and `REGION.json`. REGION is a US state (`tennessee`, `new-york`) or a Geofabrik path (`europe/germany/bayern`). Options: `--out DIR` (default `.`), `--work DIR` (default: a private temporary folder, removed afterwards), `--date YYMMDD`, `--keep-downloads`, `--ml-footprints microsoft`, `--duckdb`, `--extension-directory`.
|
|
384
|
+
- `doctor` checks everything the gem needs outside Ruby, with a fix for each problem: the DuckDB binary (its path and version; a warning, not a failure, outside the tested 1.4 LTS and 2.0), its `spatial` and `httpfs` extensions (with versions), and the cache folder's permissions when one is configured. `--verify DIR` also checks every built file in a catalogue or cache folder against the SHA256 its build recorded; `--network` checks that Geofabrik and Overture's catalogue answer (no locations are sent); `--json` prints the report for scripts. It exits 0 when ready, 1 if not. It prints the DuckDB version and the path of the binary that runs: `CURTILAGE_DUCKDB` runs whatever it names, so it's trusted configuration.
|
|
204
385
|
|
|
205
386
|
Run `curtilage COMMAND --help` for the same list.
|
|
206
387
|
|
|
388
|
+
Standard output carries only results (`generate` without `--out`, and the file path `build` wrote); progress, summaries, warnings and errors go to standard error, so output can be piped. Exit codes, for `generate`, `preview`, `places`, `diff` and `build` (`diff` uses 1 for "some sites need review"):
|
|
389
|
+
|
|
390
|
+
| Code | Meaning |
|
|
391
|
+
|---|---|
|
|
392
|
+
| 0 | Done; every site has usable premises. |
|
|
393
|
+
| 1 | Done, but some sites have no usable premises (`ok` is false); the output was still written. |
|
|
394
|
+
| 2 | Bad input or usage: an unknown option or command, a bad pin, an unreadable input file, an output path that can't be written. Nothing was generated. |
|
|
395
|
+
| 3 | A dependency is missing: DuckDB isn't found, or its extensions won't load. `curtilage doctor` says what to fix. |
|
|
396
|
+
| 4 | Map data unavailable: a download, Overture read or build failed, offline mode forbids what's needed, or a built file can't be read. |
|
|
397
|
+
| 70 | An unexpected error (a bug: please report it with the message). |
|
|
398
|
+
|
|
399
|
+
`doctor` keeps its own codes: 0 ready, 1 not.
|
|
400
|
+
|
|
207
401
|
### Docker
|
|
208
402
|
|
|
209
|
-
The repository's `Dockerfile` packages the gem with the DuckDB CLI (1.4.4, `--build-arg DUCKDB_VERSION=`
|
|
403
|
+
The repository's `Dockerfile` packages the gem with the DuckDB CLI (1.4.4, checked against its SHA256; to change the version pass `--build-arg DUCKDB_VERSION=` with `DUCKDB_SHA256_AMD64=` and `DUCKDB_SHA256_ARM64=` for that release) and its extensions, fetched while building, on a base image pinned by digest. The image runs `curtilage`:
|
|
210
404
|
|
|
211
405
|
```sh
|
|
212
406
|
docker build -t curtilage .
|
|
213
407
|
docker run --rm -v "$PWD:/work" -v curtilage-cache:/cache curtilage generate --in pins.csv --out premises.csv
|
|
214
408
|
```
|
|
215
409
|
|
|
216
|
-
The container's working folder is `/work`: mount yours there and give file names relative to it. On-demand builds go to `/cache` (`CURTILAGE_CACHE_DIR`); mount a volume there to reuse them for a month. It runs as a non-root user.
|
|
410
|
+
The container's working folder is `/work`: mount yours there and give file names relative to it. On-demand builds go to `/cache` (`CURTILAGE_CACHE_DIR`); mount a volume there to reuse them for a month. It runs as a non-root user, has no build tools (curl, unzip) in it, works offline (`-e CURTILAGE_OFFLINE=1`, with prebuilt files or a cache) and with a read-only root filesystem (`--read-only --tmpfs /tmp -v curtilage-cache:/cache`).
|