///|
fn Topology::absolute_geometry(self : Topology, g : Json) -> Json {
  match kind(g) {
    "Point" =>
      replace_fields(
        g,
        Map([("coordinates", self.point(field(g, "coordinates")).to_json())]),
      )
    "MultiPoint" =>
      replace_fields(
        g,
        Map([
          (
            "coordinates",
            array(field(g, "coordinates")).map(p => self.point(p)).to_json(),
          ),
        ]),
      )
    "GeometryCollection" =>
      replace_fields(
        g,
        Map([
          (
            "geometries",
            array(field(g, "geometries"))
            .map(c => self.absolute_geometry(c))
            .to_json(),
          ),
        ]),
      )
    _ => g
  }
}

///|
/// Convert stored deltas and points to absolute positions while retaining shared arc references.
pub fn Topology::dequantize(self : Topology) -> Topology raise TopoError {
  let arcs = []
  for i = 0; i < array(field(self.data, "arcs")).length(); i = i + 1 {
    arcs.push(self.arc(i))
  }
  let objects : Map[String, Json] = Map([])
  for name in self.names() {
    objects[name] = self.absolute_geometry(self.object(name))
  }
  let out = match self.data {
    Object(m) => m.copy()
    _ => Map([])
  }
  out.remove("transform")
  out["arcs"] = arcs.to_json()
  out["objects"] = Json::object(objects)
  read(Json::object(out).stringify())
}