souvik-das-tech/mapnest 是一个托管在 GitHub 上的开源项目,主要使用 Go 编写,采用 Apache License 2.0 许可证。
仓库全名
souvik-das-tech/mapnest
README 摘要
Lightweight map publishing, powered by MapServer . A GeoServer-style REST API and admin UI for publishing PostGIS, S3 and GeoTIFF data as WMS / WFS. Quick start · API only or API + UI · API guide · Documentation · Security Why MapNest? GeoServer is powerful, but it is a Java application that usually wants 1–2 GB of heap, a dense admin UI and a lot of clicking. If you are building a GIS app and mostly need to publish…
Lightweight map publishing, powered by MapServer. GeoServer-style REST API + admin UI to publish PostGIS, S3 and GeoTIFF data as WMS/WFS with SLD styles. Use it API-only or with the UI.
GeoServer is powerful, but it is a Java application that usually wants 1–2 GB of
heap, a dense admin UI and a lot of clicking. If you are building a GIS app and
mostly need to publish layers and style them, that is a lot of machinery.
MapNest keeps the GeoServer workflow you know (workspaces → stores → layers →
styles) and puts it on top of MapServer, the fast C map engine from OSGeo:
GeoServer
MapNest
Idle memory (whole stack)
~1–2 GB JVM heap
~115 MB (measured)
Start-up
tens of seconds
seconds
Configure by API
REST API
REST API, every feature (OpenAPI 3)
Styles
SLD
Your existing SLD (converted once), or a short JSON format
Config storage
XML data directory
One SQLite file; mapfile generated, validated and versioned
Your data
read/write possible
Read-only by design
Throughput: 182 WMS GetMap requests/s with p95 latency of 35 ms on a laptop
(details).
GeoServer is still the better choice if you need built-in tile caching
(WMTS/GeoWebCache), WPS processing, or per-user security across many workspaces.
Features
Stores: PostGIS databases, S3-compatible buckets (AWS, MinIO, SeaweedFS…)
and local raster folders. Every connection is tested before it is saved.
Layers: publish tables, views and GeoTIFF / Cloud Optimized GeoTIFF files.
Geometry type, SRID, extent and bands are detected for you; missing SRIDs get
suggestions. Non-COG rasters get an automatic fast copy.
Styles: upload GeoServer SLD 1.0 / SE 1.1 (filters, scale ranges,
marks, icons, labels, raster colour maps). Unsupported parts are reported, never
silently dropped. Several styles per layer, chosen with WMS STYLES=.
Icons: upload PNGs once, reference them from SLD by file name.
Workspaces: group stores per project or client, each with its own
/ows/<workspace> endpoint.
Safe changes: every change regenerates the MapServer mapfile, validates it
with MapServer before it goes live, swaps it atomically and keeps the last
50 versions for one-click rollback. No restarts.
Admin UI: guided wizards, live map previews, style editor with instant
preview, attribute statistics for classified styles, map viewer with
GetFeatureInfo, copy-paste snippets for OpenLayers, Leaflet and QGIS.
Operations: one-file backup and restore, health checks, structured JSON
logs with an audit trail.
Secure by default: no default password, sign-in lockout, server-side
sessions, strict security headers, encrypted secrets, hardened containers,
and a VAPT Level 1 checklist.
Two ways to use it
MapNest ships as two independent Docker stacks. Run only what you need.
flowchart LR
subgraph web["web/ — optional"]
UI["Admin UI<br/>React + nginx :3000"]
end
subgraph server["server/ — the core"]
API["msapi<br/>REST API :8081"]
MS["MapServer<br/>WMS / WFS :8080"]
DB[("msadmin.db<br/>SQLite")]
MF["generated<br/>mapfiles"]
end
Scripts["Your scripts, CI,<br/>backend services"] -- "X-API-Key" --> API
UI -- "/api" --> API
UI -- "/ows" --> MS
API --> DB
API -- "write · validate · swap" --> MF
MF -- read --> MS
Apps["Web & desktop GIS<br/>OpenLayers · Leaflet · QGIS"] -- "WMS / WFS" --> MS
MS -- "read-only" --> Data[("Your PostGIS · S3 · GeoTIFFs")]
API only
API + Admin UI
Run
server/
server/ and web/
Best for
Automation, CI/CD, infrastructure-as-code, embedding map publishing in your own product
Teams that also want to click through stores, layers and styles
You use
curl / any HTTP client with X-API-Key
Browser sign-in; the same API underneath
Extra footprint
none
~15 MB (nginx)
The UI has no private back door: everything it does is a public API call, so
anything you can do in the UI you can script, and vice versa.
Quick start
Requirements: Docker with Compose v2.24 or newer. Nothing else is installed on
the host.
1. The core: API + MapServer
git clone https://github.com/souvik-das-tech/mapnest.git
cd mapnest
docker network create gis-net # once per host
cd server
cp .env.example .env
# Fill in three secrets in server/.env:
# MSAPI_ADMIN_PASSWORD your own, at least 12 characters
# MSAPI_API_KEY openssl rand -hex 32
# MSAPI_SECRET_KEY openssl rand -base64 32
docker compose up -d --build
curl -s localhost:8081/api/v1/health # {"status":"ok", ...}
MSAPI refuses to start with missing, short or well-known secrets and tells you
why in docker logs msapi.
2a. Use it from the API
Publish a PostGIS table and style it, in four calls:
export API=http://localhost:8081/api/v1 H="X-API-Key: <your MSAPI_API_KEY>"
# 1. connect a database (tested before it is saved; use a read-only role)
curl -sH "$H" -X POST $API/stores -H 'Content-Type: application/json' -d '{
"name": "city_db", "type": "postgis",
"connection": {"host": "db.example.com", "database": "gis", "user": "map_reader", "password": "…"}}'
# 2. publish a table (geometry, SRID and extent are detected)
curl -sH "$H" -X POST $API/layers -H 'Content-Type: application/json' \
-d '{"name": "roads", "title": "Roads", "store": "city_db", "table": "roads"}'
# 3. upload your GeoServer SLD
curl -sH "$H" -X POST "$API/styles?name=roads_by_class" \
-H 'Content-Type: application/vnd.ogc.sld+xml' --data-binary @roads.sld
# 4. make it the layer's default style
curl -sH "$H" -X PUT $API/layers/roads/styles -H 'Content-Type: application/json' \
-d '{"default": "roads_by_class"}'
MapNest is built to pass a Level 1 vulnerability assessment out of the box: no
default credentials, sign-in lockout, server-side sessions with idle timeout,
strict CSP and security headers, rate limits, hidden server versions, AES-256-GCM
encrypted secrets, read-only data access, an audit log and hardened containers.
CI runs tests, govulncheck, npm audit, Trivy, CodeQL and gitleaks.
See SECURITY.md for the production checklist and how to report a
vulnerability privately.
Project layout
server/ core stack: MapServer + msapi (Go REST API)
msapi/ the API: cmd/, internal/{api,config,store,mapfile,sld,inspect,...}
mapserver/ MapServer and Apache configuration
web/ optional stack: React admin UI served by nginx
src/ features/{stores,layers,styles,icons,map,system,...}
nginx*, tls/ reverse proxy, security headers, optional HTTPS (Caddy)
docs/ guides, security checklist, logo
dev/ sample SLDs and icons, k6 load test
Contributing
Issues and pull requests are welcome. Read CONTRIBUTING.md and
the Code of Conduct. Everything (tests, builds, the dev
server) runs in Docker, so you do not need Go or Node installed.
Credits
All map rendering, WMS and WFS are done by MapServer,
an OSGeo project, run from the stock
camptocamp/mapserver image.
Raster access uses GDAL. MapNest manages MapServer’s
configuration; the heavy lifting belongs to the MapServer and GDAL communities.
评论