# An embedded DSL for OpenStreetMap

*2026-10-01 — idea*


Status: Ongoing
Level: PartII
Year: 2026
Project: TESSERA, a pixelwise geospatial foundation model
Supervisors: Patrick Ferris, Anil Madhavapeddy
Students: Matt Occleshaw


[OpenStreetMap](https://www.openstreetmap.org/) (OSM) holds a rich set of
geographic data, including some unusual things like locations of [bins](https://wiki.openstreetmap.org/wiki/Tag:amenity=waste_basket) or whether a
[pedestrian crossing](https://wiki.openstreetmap.org/wiki/Tag:highway=crossing)
has [tactile paving](https://wiki.openstreetmap.org/wiki/Key:tactile_paving).
Programmatic access to this detail could help many people, especially those with
access needs. Examples include planning routes that only use streets with
tactile aids for blind or visually impaired people, finding nearby [public
toilets](https://wiki.openstreetmap.org/wiki/Tag:amenity=toilets), or finding the
[accessible entrances](https://wiki.openstreetmap.org/wiki/Key:entrance) (with [wheelchair access](https://wiki.openstreetmap.org/wiki/Key:wheelchair) tags) to every Cambridge college (a very specific usecase, but you get the idea we hope!).

OSM stores its data as key-value tags, and the data is entirely crowdsourced.
The project enforces no strict schema. The community has defined some
conventions for common kinds of entity on its
[wiki](https://wiki.openstreetmap.org/wiki/Map_features), but they are followed
to very different extents. A tag system maintained organically by a community
in this way is often called a
[folksonomy](https://en.wikipedia.org/wiki/Folksonomy).

Existing query tools include
[Overpass](https://wiki.openstreetmap.org/wiki/Overpass_API), which offers
high-level queries through an API, and [osmium](https://osmcode.org/osmium-tool/),
which offers fast lower-level queries over local data. Neither handles the
incomplete folksonomy well. A query for a route to a station along lit roads
might filter on [`[lit=yes]`](https://wiki.openstreetmap.org/wiki/Key:lit) in Overpass, but this silently drops every road
that has no `lit` tag. Absence can be selected with `[!lit]`, but it is still
treated as false, and reconciling the two by hand greatly complicates queries.

This project will make incompleteness part of the semantics of a query DSL.
Filters will return a certain set and a possible set. By embedding the DSL in
OCaml, it can use the type system to tell certain results from possible ones.
It can also use typed tag accessors, in the form of
[lenses and prisms](https://arxiv.org/abs/1703.10857), that separate present,
absent and malformed values. A tag value that cannot be interpreted under the
community's conventions is then treated as unknown, just like a missing tag,
so both sources of incompleteness are handled the same way. The gap between the
certain and the possible is also useful in itself, since it shows OSM
contributors where data is missing that would settle the query.

## Related ideas

- [Global habitat maps from Tessera embeddings](https://anil.recoil.org/ideas/tessera-habitat-maps) could
  feed into this work by supplying habitat information for use in queries.
- [Handling GPS uncertainty in point labels for Tessera](https://anil.recoil.org/ideas/tessera-gbif-uncertainty)
  addresses a similar problem of reasoning about uncertain geographic data.

## Related

- [Handling GPS uncertainty in point labels for Tessera](https://anil.recoil.org/ideas/tessera-gbif-uncertainty) (idea, 2026-10-01)
  Available · Part II
- [Global habitat maps from Tessera embeddings](https://anil.recoil.org/ideas/tessera-habitat-maps) (idea, 2026-08-01)
  Ongoing · Postdoc

---
Canonical: https://anil.recoil.org/ideas/ocaml-osm-dsl
Type: idea
License: CC BY 4.0 <https://creativecommons.org/licenses/by/4.0/>
Tags: ocaml, geospatial, programming
