diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a1380d0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/data/ +*.osm +*.osm.pbf diff --git a/README.md b/README.md index 5606de3..c9c9aaa 100644 --- a/README.md +++ b/README.md @@ -29,3 +29,40 @@ Checks: ```sh go test -race ./client/... ./server/... ./datapoint/... ``` + +## Free local address lookup: Jackson to the Mississippi coast + +Address lookup runs on the VPS using a local index of OpenStreetMap addresses. There are no API keys, subscriptions, or per-request fees, and GPS coordinates are not sent to an address service. The full Mississippi extract covers the operating area from Jackson south to the coast without guessing a route boundary. + +Install `curl`, Go, and Osmium Tool on the machine preparing the data (`osmium-tool` on Debian/Ubuntu; `osmium` on Arch). From the repository root: + +```sh +./scripts/prepare-addresses.sh + +go build -o /tmp/macker-server ./server +/tmp/macker-server -addresses data/mississippi-addresses.json -ingest :2948 -http :8080 +``` + +The preparation script downloads the [free Mississippi OSM extract from Geofabrik](https://download.geofabrik.de/north-america/us/mississippi.html), retains address nodes and ways together with their referenced nodes using [Osmium tags-filter](https://docs.osmcode.org/osmium/latest/osmium-tags-filter.html), and builds `data/mississippi-addresses.json`. Temporary source files are removed. Allow disk space for the roughly 90 MB PBF download and its filtered XML, plus memory for importing the referenced coordinates. Actual resource usage depends on the current extract. + +Preparation can run on a different machine: copy the resulting JSON file to the VPS. The running server needs only its binary and this index; it does not need Osmium, a Nominatim server, or a database service. By default it looks for `data/mississippi-addresses.json` relative to its working directory; use an absolute `-addresses` path in a systemd service. If the file is missing, GPS and mapping still work, with address lookup shown as unconfigured. + +The page displays the nearest **mapped address within 5 km** and its approximate straight-line distance. Address nodes use their recorded coordinates. Addressed building ways use the mean of their vertices, so distance is to an approximate building location, not an entrance, boundary, or driving route. Ways missing referenced coordinates are skipped. Only objects with a house number and street/place are indexed; relation-only addresses, address interpolation, and unmapped houses are not synthesized. OSM address coverage varies, especially in rural areas. If no mapped address is within range, the page says no nearby mapped address is available. + +The in-memory spatial index searches locally on every location API request, without the hosted geocoder's 30-second throttle or its 25-metre reuse window. Stale GPS fixes label the distance as belonging to the last known fix. Local data takes precedence over any previously configured geocoder endpoint. The map tiles still load from OpenStreetMap as before. + +To refresh, rerun the preparation script and restart the server. Imports replace the JSON file atomically after successful parsing, preserving an existing file if import fails. The generated data is derived from OpenStreetMap and is covered by [ODbL](https://www.openstreetmap.org/copyright); attribution is displayed in the address card. Keep that attribution and license when sharing the dataset. + +If you already have filtered OSM XML, import it directly with no download: + +```sh +go run ./server -import-osm addresses.osm -addresses data/mississippi-addresses.json +``` + +## Free aerial imagery + +Use the **Street / Aerial** layer control on the map. Street uses OpenStreetMap; Aerial uses the public-domain USDA NAIP imagery exposed by the [USGS National Map imagery service](https://imagery.nationalmap.gov/arcgis/rest/services/USGSNAIPImagery/ImageServer). No Google services, accounts, API keys, subscriptions, or paid SDKs are required. The GPS marker and uncertainty circle remain above either background. + +The browser loads aerial images directly from `imagery.nationalmap.gov` on demand, limited to Mississippi's bounding box. This is an online government-hosted imagery layer, not a self-hosted/offline collection. No imagery archive is downloaded to the VPS. The ImageServer's `exportImage` operation is used with matching Web Mercator tile bounds, natural-color rendering, and attribution. Imagery acquisition dates vary; the photographs are not live. If an aerial image fails to load, the page switches back to Street and offers retry by selecting Aerial again. The map initially opens over southern Mississippi until the first car fix arrives. + +Rebuild and restart the server to include the updated embedded page, then reload the browser. The car client needs no changes. diff --git a/client/macker b/client/macker index 49a5b64..4bccd79 100755 Binary files a/client/macker and b/client/macker differ diff --git a/scripts/prepare-addresses.sh b/scripts/prepare-addresses.sh new file mode 100755 index 0000000..35f37c4 --- /dev/null +++ b/scripts/prepare-addresses.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +# Build free local address data for Mississippi, including Jackson to the coast. +set -euo pipefail +for dependency in curl osmium go; do + if ! command -v "$dependency" >/dev/null 2>&1; then + echo "Missing $dependency. Install curl, Go, and osmium-tool (osmium on Arch)." >&2 + exit 1 + fi +done +repo_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)" +cd "$repo_dir" +work_dir="$(mktemp -d)" +trap 'rm -rf -- "$work_dir"' EXIT +curl --fail --location --retry 3 --output "$work_dir/mississippi.osm.pbf" \ + https://download.geofabrik.de/north-america/us/mississippi-latest.osm.pbf +# Referenced nodes are retained by default; required for building footprints. +osmium tags-filter "$work_dir/mississippi.osm.pbf" nw/addr:housenumber \ + --output "$work_dir/addresses.osm" +go run ./server -import-osm "$work_dir/addresses.osm" \ + -addresses "${1:-data/mississippi-addresses.json}" +echo 'Address data ready. Restart the server to load it.' diff --git a/server/index.html b/server/index.html index 1b265e8..9e5b22d 100644 --- a/server/index.html +++ b/server/index.html @@ -10,12 +10,51 @@

Macker

Work car · Live location

-
Current speed—Waiting for GPS
Last update—No location received yet
Nearby address—Waiting for GPS

Waiting for the car’s first GPS fix…

GPS uncertainty unavailable

+
Current speed—Waiting for GPS
Last update—No location received yet
Nearby address—Waiting for GPS

Waiting for the car’s first GPS fix…

GPS uncertainty unavailable

Street map · OpenStreetMap