Skip to content

Operations on Windows

Every command runs from the repository root in PowerShell. The scripts live in distributions\docker\ and never delete Docker volumes.

Task Command
First install powershell -ExecutionPolicy Bypass -File distributions\docker\install.ps1
Check prerequisites only … install.ps1 -Check
Upgrade / redeploy … deploy.ps1
Upgrade with a catalog migration … deploy.ps1 -AllowMigration (after a dry run)
Roll back the image … deploy.ps1 -Rollback pre-<version>
Cold backup … backup.ps1 (optional -Label before-upgrade)
Restore a backup … restore.ps1 -File <backup.tgz> -ReplaceLiveData

install.ps1 does the following:

  1. Checks Docker Desktop and that port 8081 is free.
  2. Creates .env from .env.example.
  3. Builds the API and MapCache images.
  4. Creates the data volume loka-v26-data (owned by UID 10001).
  5. Starts the API, then MapCache.
  6. Prints the one-time setup code. Open http://127.0.0.1:8081 and create the first administrator with it.

The script refuses to run when the data volume already exists. Never reinstall over existing data; upgrade instead.

  1. A candidate image is built while the running image keeps serving.
  2. The script compares the catalog schema (/api/v2/status → schemaVersion against loka version).
  3. If the schema changes, it stops unless you add -AllowMigration. With the flag it first takes a cold backup to C:\dev\loka-backups with a .sha256 file.
  4. It tags the running image loka-v2-trial:pre-<version> (your rollback), then starts the candidate. compose.postgis.yml is added automatically when the volume loka-v26-pgsecrets exists.
  5. It waits until /status reports the new version. Without a migration, a failed start rolls back automatically.

Recommended for a migration: restore a backup into a copy (loka-v26-data-dryrun), run the candidate against it on port 8082, check it, then deploy with -AllowMigration.

backup.ps1 stops the API and MapCache for about a minute (200 MB), tars the whole data volume and writes a SHA-256 file. The tar holds:

  • the catalog (SQLite)
  • datasets, mapfiles and styles
  • the tile cache
  • secrets: the session key, and the PostGIS passwords in config/postgis/

Keep backup files as private as the server. Copy them off the machine regularly.

restore.ps1 -File <tgz> -ReplaceLiveData:

  1. Verifies the checksum.
  2. Checks that the archive contains catalog/loka.db.
  3. Takes a safety backup of the current data (-SkipSafetyBackup turns this off).
  4. Empties the volume, extracts the archive, fixes ownership, and restarts.

If the backup is older than the current schema, run the image of that time afterwards: deploy.ps1 -Rollback pre-<version>. A new image refuses an older catalog only when it cannot migrate it; an old image never opens a newer catalog.

  • Recommended: Data Stores → Add → PostGIS → host, port, database, schema, user, password. The connection is tested before it is saved.
    • The password is stored only in LOKA_DATA_DIR/config/postgis/<store>.pgpass (file mode 0600).
    • Use a read-only database role.
  • Alternative (operator alias): put pg_service.conf and pgpass into the volume loka-v26-pgsecrets (owner 10001, mode 0600), then create the store with the alias.
  • Publishing modes:
    • Live: MapServer reads the table on every request. Cached tiles expire after 5 minutes. Use Refresh extent when data grows outside the original area.
    • Snapshot: a copy of the table. Refresh it from the store page or the layer page (Refresh snapshot).
  • Account menu → API tokens → New token. The token is shown once.
  • In QGIS: add a WMS/WMTS/WFS connection with a URL from a layer’s Publishing tab, then Authentication → Basic, with your user name and the token as password.
  • Tokens are read-only (WMS, WFS, WMTS/TMS only). They use your role and workspace access, and you can revoke them at any time.
  • Security → Users → Workspaces limits a non-admin user (and their tokens) to selected workspaces.

ENC charts are for monitoring and situational awareness. Loka is not an ECDIS and the display is not for navigation.

Presentation files (once per server). The lookup table and symbols are not part of Loka. Put them into enc-presentation/ in the data directory, owned by UID 10001:

File Needed Source
chartsymbols.xml, s57attributes.csv, rastersymbols-*.png chartsymbols.xml is required OpenCPN s57data (GPL; check the licence for your use)
s57objectclasses.csv Recommended: the layer picker shows names instead of six-letter codes OpenCPN s57data
PortrayalCatalog/ Recommended: SVG symbols, line styles, colours IHO S-101 Portrayal Catalogue
font.ttf Recommended: without it no text is drawn Any TrueType font, for example DejaVu Sans Condensed

Without chartsymbols.xml the ENC Charts page says so and imports are refused (503 ENC_NOT_CONFIGURED).

Import. Console → ENC Charts → choose a workspace → one exchange set ZIP (as the hydrographic office delivers it) or cell files (XXXXXXXX.000, their updates, CATALOG.031) → Import.

  • The upload is answered at once; the chart is built in the background, about 5 seconds per cell, one chart at a time. The list shows Building, Ready or Failed with the reason.
  • Cells that are cancelled by their producer, damaged (catalogue checksum) or given twice are left out and listed under the preview.
  • A restart of the server during a build marks the chart Failed. Delete it and import again. Do not deploy while a chart is building.
  • A chart cannot be changed: to add cells or updates, import a new chart and delete the old one.
  • S-63 (encrypted) exchange sets are decrypted when the server has a hardware id (LOKA_S63_HW_ID, five hexadecimal characters, a secret) and the ZIP file holds the PERMIT.TXT issued for it; otherwise they are refused with 422 S63_NOT_SUPPORTED and a summary of the cells and permits found. Signatures are not checked yet. See docs/S63.md.

Tiles. A ready chart is a tile cache layer. After the build, tiles are filled ahead in the background (it shows as a job on the Tile Cache page): expect minutes and about 10 MB per cell. Tiles hold the default display; a changed setting is drawn live.

Disk. A chart needs about 2 to 3 MB per cell under enc/, plus its tiles under mapcache/cache/. Deleting a chart removes both.

Clients. WMS: /api/v2/enc-charts/<id>/wms (WMS 1.1.1 GetMap, EPSG:3857, LAYERS = the chart’s service name), with a session or an API token. Optional parameters: safety_contour, shallow_contour, deep_contour, safety_depth (metres), show_standard, show_other, show_meta, show_buoyage_boundary (the A/B line of buoyage-system areas, off by default), show_text, show_text_important, show_text_names, show_text_marks, show_text_lights, show_text_other (0 or 1). Tiles: the WMTS/XYZ addresses of the tile cache, layer name = the chart id.

Display presets and hidden layers. In a chart’s Preview, Layers hides kinds of objects (lights, cables, soundings, …) and Save as… stores the current settings (display categories, text, depths, hidden layers) as a preset on the server. Writers can create, change and delete presets; everyone signed in can use them. Other programs add &preset=<id> or &hide=LIGHTS,SOUNDG to a WMS address; parameters in the address win over the preset. Hiding works on charts imported with this version; older charts must be imported again. Tiles hold the default display only, so a preset is drawn live.

Colours and style. The palette (Day, Dusk, Night) is chosen at import and can be changed on the chart’s Style tab. The same tab takes an optional style file (JSON): colors replaces S-52 colour tokens with #RRGGBB, classes hides object classes for good. Apply style writes the chart’s mapfiles again in a few seconds; the data is not imported again and the tiles are drawn anew in the background. A chart with a style file no longer shows the S-52 colours. Charts imported before this version must be imported again before their style can be changed.

Public access. Off for every chart. An administrator can switch it on in the chart’s Access panel; then /api/v2/public/enc-charts/<id>/wms and /api/v2/public/enc-charts/<id>/tiles/{z}/{x}/{y}.png answer without sign-in. Nothing else becomes public, and the switch is written to the audit log. Use it only for data whose licence allows open distribution.

MapServer workers. ENC charts are drawn by MapServer processes that stay running (FastCGI), up to four. If a worker fails, the request is repeated as a CGI. LOKA_MAPSERV_FASTCGI=0 turns the workers off. The answer header X-Enc-Renderer says which was used; Server-Timing says where the time went.

Backup. Charts and their tiles are inside the data directory and are part of the cold backup. Schema v11 adds the tables enc_charts and enc_cells, v12 the public switch, v13 the table enc_presets; an image with schema v10 cannot open a newer catalog.

Console → Data Stores → Weather (GRIB) → choose a workspace and all GRIB files of a forecast (or one ZIP of them) → Save. Every parameter becomes a raster layer; the layer preview has a time slider.

  • Known parameters: TMP at 2 m (shown in °C), UGRD/VGRD at 10 m (speed and an arrow layer), APCP (precipitation; with several accumulations per step the shortest is used), HTSGW (waves). Other fields get a colour scale over their data range.
  • WMS clients pick a step with TIME=YYYY-MM-DDThh:mm:ssZ (GetCapabilities lists them under the time dimension). Weather layers are not tile-cached.
  • To spread a colour scale over the data instead of fixed values (a forecast in odd units), set "stretch": true in the layer style (PUT /api/v2/layers/{id}/style/draft, then publish).
  • A new forecast is a new import; delete the old layers when they are no longer needed.

7b. 3D buildings from a polygon layer — since 1.5.0

Section titled “7b. 3D buildings from a polygon layer — since 1.5.0”

Console → 3D Tiles → From buildings → pick a polygon layer, the height field (metres) and/or the storeys field, and optionally an elevation layer as ground → Build. The result is an ordinary hosted tileset (3D Tiles 1.1, glTF tiles with EXT_mesh_features / EXT_structural_metadata: id, name, height per building), served and shared like an imported one.

  • Height per building: the height field, else storeys × storey height (default 3 m), else the default height (default 10 m; 0 leaves such buildings out), times the height factor.
  • Ground: without an elevation layer the buildings stand on the ellipsoid (height 0), which is what a 3D client without terrain draws. With one, each building stands on the terrain at its centre, sunk 1 m so a slope leaves no gap; for terrain served in ellipsoidal heights the EGM96 geoid is added, as for the terrain tiles themselves.
  • Up to 500 000 buildings per layer, in tiles of at most 2 000. Multipolygons become one building per part with the same id.
  • API: POST /api/v2/layers/{id}/tileset3d with heightField, levelsField, storeyHeight, defaultHeight, heightFactor, nameField, elevationLayerId, displayName, workspaceId.

Console → Elevation → a layer → Open in CesiumJS, or 3D Tiles → a tileset → Workspace in CesiumJS, opens GET /api/v2/workspaces/{id}/scene3d: a CesiumJS page with the workspace’s ready elevation layers as terrain (quantized-mesh, with vertical exaggeration), its 3D tilesets (light and coloured by height, optional sun shadows at a chosen local time), every published layer as a draped WMS with its own opacity, and a line-of-sight tool: click the observer and the target, optionally with a polygon layer of buildings standing on the terrain; the server’s answer is drawn in 3D (ground seen green, hidden red, the sight line, the obstruction) with distance and obstruction height. Like the 3D Tiles preview it runs on the console session (same origin, no token) under its own Content-Security-Policy. CesiumJS is served by Loka Server itself (/vendor/cesium/1.121.1/, part of the console build), so it works offline.

7c. Aeronautical data (AIXM 5.1) — since 1.5.0

Section titled “7c. Aeronautical data (AIXM 5.1) — since 1.5.0”

Console → Data Stores → Aeronautical (AIXM) → choose a workspace and AIXM 5.1 files (.xml, .aixm, or one ZIP of them) → Save. Up to three vector layers are made (four from ARINC 424, with procedures), named after the file: airspaces (polygons), points (airports, heliports, navaids, designated points, obstacles) and routes (route segments), each with the aeronautical chart style:

Kind Drawn as
TMA, CTA solid blue line with a light blue band along the inside (no fill, so stacked sectors keep the map readable)
CTR · ATZ dashed blue line with a narrower band · dotted blue line
Prohibited / restricted / danger area solid line hatched on the inside (dark red / red / orange)
FIR, UIR, sector grey line with ticks
Aerodrome: civil · joint civil and military · military double ring with four ticks · ring with four ticks · double ring (controlType)
Heliport ring with centre
VOR · VOR/DME hexagon with centre · the hexagon in a rectangle
VORTAC, TACAN · DME three-armed TACAN shape · square with centre
NDB · NDB/DME rings of dots · the same in a square
VOR, VOR/DME, VORTAC a compass rose round the symbol (true north), at scales larger than 1:1,500,000; drawn by a layer of its own under the points, so the rose never pushes the labels of nearby navaids and aerodromes off the map
Navaid label data box: name over frequency (or channel) and ident, framed in the navaid colour
Navaid that is a compulsory reporting point the same symbol filled
Compulsory · on-request reporting point filled triangle · open triangle
RNAV waypoint: fly-by · fly-over four-pointed star · the star in a circle; filled when compulsory (DesignatedPoint type COORD, or RNAV-only waypoints from ARINC 424)
Obstacle · lighted obstacle · group inverted V with a small circle at its base · with rays above · two of them (group YES); label = elevation of the top (ft) over the height above ground in brackets (verticalExtent)
ATS route segment line, designator in a box; dash-dot for an advisory or flight information route (designatorSuffix F or G); arrowheads in the direction of flight for a one-way segment (RouteAvailability direction FORWARD or BACKWARD)

The symbols are those of ICAO Annex 4, Appendix 2, checked against two AIPs that reproduce it (Singapore and Spain, GEN 2.3) and the AIXM symbol set (github.com/aixm/symbols, BSD-3); the shapes are redrawn, no files copied. Colours are not fixed by Annex 4. A designated point or navaid counts as compulsory when a route segment that starts or ends at it says reportingATC COMPULSORY.

Navaid frequencies and channels are read from the equipment features (VOR, DME, NDB, TACAN) that a Navaid links through navaidEquipment; airspace classes (A–G) from AirspaceLayerClass.

Labels: an area its identification (and class) over its upper and lower limit with a rule between them, placed inside the area just below its top (nested areas such as FIR, TMA and CTR so keep their labels apart; the anchor is stored as label_x, label_y and drawn by a label layer that is not offered on its own); aerodromes designator and name over the aerodrome data, elevation (ft) and longest runway (m, from Runway nominalLength), and the TWR, AFIS and ATIS frequencies (AirTrafficControlService and InformationService with their RadioCommunicationChannel); obstacles their elevation over their height in brackets; others their designator. Attributes kept: aixm_class, type, designator, name, icao, elevation_ft, runway_length_m, radio, upper_limit, lower_limit, reporting, control, lighted, group, height_ft, one_way, advisory, fly_over, aixm_id, plus symbol, label and the label anchor used by the style. Outer rings are stored clockwise (the hatching side).

The layer’s Style Editor shows the chart legend; Use the chart style puts it back after another style was published over it.

A full chart. The three layers carry no background. For a chart like a printed one, put them in a layer group over a land and sea background, bottom to top: sea, land, inland water, coastlines, borders, a graticule, then airspaces, routes, points. The demo does this as Jakarta aeronautical chart with VMap0 (oceansea_bnd_area, polbnda_bnd_area …; land #EEEADE, sea #C8E0F0). The group has one WMS address and is cached like any group. Its graticule (30’ lines with minute ticks, longer every 5’) is written by distributions/demo/make_graticule.py.

  • Of each feature’s time slices the BASELINE (or PERMDELTA) with the highest sequence and correction number is used. Coordinates in EPSG:4326 are read latitude first, CRS:84 longitude first; circles and arcs by centre point become polygons (5° steps).
  • A route segment without a curve of its own is drawn straight from its start to its end point (found by their identifiers in the same message).
  • Not read: runways, services, procedures, holding patterns and other feature classes (counted in the answer as otherFeatures); features whose geometry is only a reference to a feature outside the message (skipped).
  • ARINC 424 (the FAA CIFP file FAACIFP18, or the FAA’s ZIP as it is) goes through the same import and becomes the same layers: airports, heliports, runways, navaids, waypoints, airways, controlled and restrictive airspace, and a fourth layer of SIDs, STARs and approaches. The format is read from the content. Details and what is still to come: docs/ARINC424.md.
  • API: POST /api/v2/workspaces/{id}/aeronautical/import (multipart file, optional displayName). Example data: docs/examples/aixm/.
  • GET /api/v2/status returns the version and schema.
  • The OGC Services page shows live probes of MapServer and MapCache.
  • API logs: docker logs loka-v26-trial-api-1
  • MapCache logs: docker logs loka-v26-trial-mapcache-1 (the line graceful reload requested appears after catalog changes).
  • Live PostGIS layer fails: check the store’s Test connection. Alias stores need compose.postgis.yml, which deploy.ps1 adds automatically.
  • Never run docker compose down -v or docker volume prune on this project.