A shared map grammar. Controlled edits. Explicit renderer capabilities.
Structured styles · Deterministic compilation · Evidence-based review
简体中文 · Runnable example · Download · GeoStyle
OpenStyle is an open-source TypeScript toolkit for AI-assisted cartography. It separates map representation, deterministic compilation and review utilities so applications can design, edit and inspect styles over real geographic data.
Early alpha · v0.7.0 prerelease — Download the eight-package installation bundle from GitHub Releases. npm publication is not complete; APIs may change.
Map styling should be grammar-checked before it leaves the model. openstyle gives AI agents a bounded shape to fill in, a deterministic compiler that turns that shape into standards-compliant SLD, and a curated prompt manual so the model doesn't have to invent OGC XML from memory.
The toolkit separates map representation, compilation and creation policies:
- Schema (
@openstyle/schema) — the JSON shape (with zod runtime validation) that an LLM must produce. Small, opinionated, complete for real cartography needs (scale layering, classification, labels, symbolizers). - Compiler (
@openstyle/compiler) — turns a validatedStyleModelinto strict OGC SLD 1.0 XML. No LLM ever touches<sld:...>. - Manual + AI helpers (
@openstyle/manual,@openstyle/ai) — a distilled version of the GeoServer SLD Cookbook, plus system-prompt builders and field-reference validators, so any AI agent can pick up the format quickly. - Cartography (
@openstyle/cartography) — canonical map patches, classification-aware road casing, compact review context, pixel diagnostics and bounded repair decisions. Applications bring their own renderer capture, model transport and persistence.
flowchart LR
A[Application / AI agent] --> V[Schema validation]
V --> S[StyleModel: one layer]
V --> M[OpenStyle: whole map]
S --> C[SLD compiler]
C --> G[GeoServer]
S --> O[OpenLayers adapter]
M --> O
M --> L[MapLibre adapter]
M <--> P[Controlled edits and review]
Adapters declare their capabilities and report unsupported expressions; rendering parity is not assumed. Applications supply data, captures, model transport, accounts and persistence. Successful compilation and pixel diagnostics are not visual acceptance.
![]() Yangshuo · Field atlas |
![]() Gardiner · Yellowstone River atlas |
GeoStyle uses OpenStyle for structured 2D styles and reusable cartography logic. These are actual application renders, including application-specific materials and human review, not outputs of a standalone compiler call. Image credits · Explore GeoStyle
| Package | Description |
|---|---|
@openstyle/schema |
StyleModel TypeScript type + zod schema + validators |
@openstyle/compiler |
compileToSld / formatSld — deterministic SLD 1.0 emitter |
@openstyle/cartography |
Atomic map edits, casing, render diagnostics and review contracts |
@openstyle/adapter |
Renderer capability declarations and negotiation |
@openstyle/openlayers |
compileToOpenLayers — deterministic OpenLayers StyleFunction adapter |
@openstyle/maplibre |
compileOpenStyleToMapLibre — deterministic MapLibre Style Specification adapter with explicit capability negotiation |
@openstyle/manual |
Cookbook-distilled prompt manual (scale ladders, palettes, few-shot) |
@openstyle/ai |
Prompts, validators, request policies and output-budget decisions |
The reusable GeoStyle creation functions are implemented in this repository and consumed by GeoStyle. Version 0.7.0 is distributed as a GitHub prerelease; npm publication is separate and has not been completed. See the extraction record, offline workflow example, and release instructions.
Download openstyle-0.7.0-bundle.zip from the v0.7.0 release, extract it, and run pnpm install inside its directory. The bundle pins all eight OpenStyle packages to included tarballs; external dependencies still need registry access or a populated pnpm cache. Then import the packages normally:
import { StyleModelSchema } from "@openstyle/schema";
import { compileToSld } from "@openstyle/compiler";
const model = StyleModelSchema.parse({
name: "population_choropleth",
geom: "polygon",
classification: {
field: "POP_DENS",
classes: [
{ label: "Low", filter: { op: "lt", value: 100 }, symbolizer: { kind: "polygon", fill: "#f7fbff" } },
{ label: "High", filter: { op: "gte", value: 100 }, symbolizer: { kind: "polygon", fill: "#08306b" } },
],
},
});
const sld = compileToSld(model);
// -> "<StyledLayerDescriptor ...>...</StyledLayerDescriptor>"After installing and building from source, run:
node examples/cartography-workflow/run.mjsThe example replays two real style edits, checks road casing, compiles two renderer targets and exercises review and request policies. It makes no model or map-service requests. Pixel checks use a labeled calibration pattern, not browser acceptance of a real map. Inspect the inputs, assertions and output.
openstyle/
├── packages/
│ ├── schema/ # zod schema + types
│ ├── compiler/ # SLD 1.0 XML emitter
│ ├── cartography/ # controlled edits, evidence and workflow contracts
│ ├── adapter/ # renderer capability negotiation
│ ├── maplibre/ # MapLibre whole-map adapter
│ ├── manual/ # AI prompt manual & few-shot library
│ ├── ai/ # system-prompt builder + validators
│ └── openlayers/ # OpenLayers StyleFunction adapter
├── apps/
│ └── docs/ # VitePress documentation site
├── skills/ # Claude Code skills (sld-generator, sld-review, sld-cookbook)
├── examples/ # end-to-end demos
└── .changeset/ # release notes
git clone https://github.com/gaopengbin/openstyle.git
cd openstyle
pnpm install --frozen-lockfile
pnpm build
pnpm typecheck
pnpm testRequires Node ≥ 18.18; the repository pins pnpm 10.32.1. The release workflow uses Node 22. Build first so downstream packages can resolve the generated type declarations.
- OGC SLD 1.0.0 Implementation Specification (02-070)
- OGC Symbology Encoding 1.1.0 (05-077r4)
- GeoServer SLD Cookbook
- GeoServer SLD Reference
See CONTRIBUTING.md. Issues and PRs welcome once the schema stabilizes.
MIT © 2026 gaopengbin and openstyle contributors
Built by Laogao · GeoStyle · Issues & feedback

