A minimal WMS server built on mapnik-java, using only the JDK's built-in HTTP server. It is a demo of the wrapper, not a production map server.
It resolves dev.avelar:mapnik-java from this repository through a Gradle composite build (includeBuild("../..") in settings.gradle.kts). To use a released version from Maven Central, delete that line.
Build the native shim once from the repository root:
cmake -S native -B build/cmake && cmake --build build/cmakeThen:
cd examples/wms-server
./gradlew run --args="8080"curl "http://localhost:8080/wms?SERVICE=WMS&REQUEST=GetCapabilities"
curl -o map.png "http://localhost:8080/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&LAYERS=land,route&STYLES=&CRS=EPSG:4326&BBOX=-90,-180,90,180&WIDTH=800&HEIGHT=400&FORMAT=image/png"It also works with WMS clients. For example, GDAL:
gdal_translate -of PNG "WMS:http://localhost:8080/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&LAYERS=land,route&CRS=EPSG:4326&BBOX=-90,-180,90,180&FORMAT=image/png" out.png -outsize 400 200- Versions 1.1.1 (
SRS) and 1.3.0 (CRS). - Requests:
GetCapabilitiesandGetMap. Anything else returnsOperationNotSupported. - Two layers,
landandroute, read from the bundled style withMapnikMap.layerNames().LAYERSpicks any subset (MapnikMap.setActiveLayers). Names are case-sensitive. - CRS
EPSG:4326,CRS:84andEPSG:3857, applied withMapnikMap.setSrs. The data is stored in EPSG:4326 and Mapnik reprojects it. Axis order follows the spec: with 1.3.0 andEPSG:4326theBBOXisminy,minx,maxy,maxx; withCRS:84,EPSG:3857or 1.1.1 it isx,y. - Formats
image/pngandimage/jpeg. Sizes up to 4096. - Parameter names are case-insensitive.
- Errors are OGC
ServiceExceptionReportXML with HTTP 400.
- Other CRSs are rejected. Any PROJ-known CRS would work in the wrapper, but each one needs its own axis-order rule and capabilities entry here.
- The
BBOXis used exactly (AspectFixMode.RESPECT). If its aspect ratio differs fromWIDTH:HEIGHT, the image is stretched, as the WMS spec says. LAYERSturns layers on or off. Drawing order is always the style's order, not the order in the request, so a request cannot putlandaboveroute.- No
GetFeatureInfo, noSLD, no caching. - Each request renders with its own
MapnikMap, because maps are not thread-safe. A real server would pool them.
./gradlew testStarts the server on a free port and checks capabilities, both versions, axis order, zoom, both formats, every error case, and concurrent requests.