Files
map-asset-gateway/config/service.env.example
T
Harmon 747eed63b0 Basemap Pusher: catalog and distribution gateway for existing tiles
A Go service that scans existing basemap tile directories and vector files,
catalogues them in SQLite, issues scoped access tokens, and serves tiles and
downloads to downstream systems. It deliberately does not generate or process
raster data: GIS software produces the tiles, this service catalogues,
authorises and distributes them.

Capabilities
- scans basemap tile directories (manifest-based or raw z/x/y) and vector
  assets (.geojson, .json, .zip, shapefiles with sidecars)
- token auth with per-resource grants, expiry and coarse scopes (read, slice)
- resource health inspection flags a moved or deleted tile root before a client
  hits a 404
- downstream push with exponential-backoff retries and manual re-queue
- image slicing jobs driven by the GDAL bundled with QGIS, including VRT
  mosaicking so successive drone flights accumulate into one seamless layer
- a narrow, non-admin slicing API for external callers: submit, poll,
  idempotent by job code, completion callback
- ops console covering health, ledger, tokens, pushes, scans, slicing and
  service info
- native Windows service install/start/stop with crash recovery, auto-start and
  a rotating log file, so no NSSM or WinSW wrapper is needed

Verified with 49 tests plus live runs against real tile data and real GDAL.
2026-10-16 10:36:12 +08:00

68 lines
2.8 KiB
Bash

# Copy this file to config/service.env and adjust the machine-specific paths.
APP_ENV=dev
SERVICE_NAME=basemap-pusher
SERVICE_VERSION=0.2.0
SERVICE_COMMIT=local
API_HOST=127.0.0.1
API_PORT=8910
API_BASE_URL=http://127.0.0.1:8910
TILE_PUBLIC_BASE_URL=http://127.0.0.1:8910
VECTOR_PUBLIC_BASE_URL=http://127.0.0.1:8910
SQLITE_PATH=Z:\Code\tile-server\data\basemap-pusher.db
BASEMAP_SCAN_ROOT=Z:\Code\tile-server\data\tiles
VECTOR_SCAN_ROOT=Z:\Code\tile-server\data\geojson
AUTO_SCAN_ON_START=true
GOCACHE=Z:\Code\tile-server\.gocache
GOMODCACHE=Z:\Code\tile-server\.gomodcache
GOTMPDIR=Z:\Code\tile-server\.gotmp
GOPATH=Z:\Code\tile-server\.gopath
GOPROXY=https://goproxy.cn,direct
GOSUMDB=off
# --- Admin access ---------------------------------------------------------
# The admin console can mint tokens that read every basemap, so it must be
# protected whenever the service is reachable off-host. Binding to a non
# loopback API_HOST without credentials below makes startup fail on purpose.
#
# Browser console: set ADMIN_USER/ADMIN_PASSWORD (HTTP Basic).
# API clients: set ADMIN_TOKEN (Authorization: Bearer <token>).
# Leaving both empty is only allowed on 127.0.0.1 / ::1 / localhost.
#ADMIN_USER=ops
#ADMIN_PASSWORD=change-me
#ADMIN_TOKEN=change-me-too
# Comma-separated list of browser origins allowed to call the API. Empty means
# no cross-origin access at all; "*" allows every origin.
#CORS_ALLOWED_ORIGINS=https://maps.example.com
# Lifetime applied to newly created tokens when no explicit expiry is given.
# Use 0 to create tokens that never expire.
TOKEN_DEFAULT_TTL=720h
# --- Resource health & tile jobs -----------------------------------------
# How often catalogued paths are re-stat'ed so a moved/deleted resource is
# flagged before a client hits a 404. Use 0 to disable the periodic pass
# (the "立即巡检资源" button still works).
HEALTH_CHECK_INTERVAL=5m
# Command template that slices a raster into XYZ tiles. Placeholders:
# {input} {output} {zmin} {zmax} {tilesize} {format} {code}
# scripts/gdal2tiles-qgis.bat locates the GDAL bundled with QGIS (the Python
# bindings need the OSGeo4W environment, so a bare gdal2tiles.exe will not work).
TILE_JOB_COMMAND=D:\Code\tile-server\scripts\gdal2tiles-qgis.bat -p mercator -z {zmin}-{zmax} --xyz -w none --tilesize={tilesize} --exclude {input} {output}
# Where per-job stdout/stderr is written. Empty means <scan root>/.tile-jobs.
#TILE_JOB_LOG_DIR=
# Service tokens may carry the "slice" scope so an integration can submit tile
# jobs through POST /api/v1/slice/jobs without holding the admin credential.
# 多源镶嵌:提交多个源影像时,先用它拼成一张 VRT 再切片(逐像素拼接,
# 消除重叠区的瓦片接缝)。{inputs} 会展开成每个源各一个参数。
TILE_JOB_VRT_COMMAND=D:\Code\tile-server\scripts\gdalbuildvrt-qgis.bat -resolution highest {output_vrt} {inputs}