Library
Module
Module type
Parameter
Class
Class type
Types for TopoJSON objects
TopoJSON objects are primarily made up of geometry primitives that are the same as those used in Geojson
. For example you can have a single Point
or Linestring
.
These are grouped under the Geometry
module and in particular the Geometry.geometry
type. These can be accessed and pattern-matched against using the Geometry.geometryfunction
. For example:
let is_linestring t =
let open Topojson in
match Geometry.geometry t with
| Geometry.LineString _ -> true
| _ -> false
module Geometry : sig ... end
The Topology.t
is the most common TopoJSON object for the main document. This contains a map of geometry objects along with other important components of the topology including the arc index and transform information.
module Topology : sig ... end
Finally we have the main TopoJSON object. Most frequently this will be a Topology.t
but could technically be a standalone Geometry.t
according to the specification.
type topojson =
| Topology of Topology.t
| Geometry of Geometry.t
The underlying TopoJSON datastructure.
*)val topology_exn : t -> Topology.t
Accessor for the TopoJSON data. This will try to access a Topology.t
.contents
val bbox : t -> float array option
Accessor for the optional bounding-box for the entire TopoJSON object.
Construct a new TopoJSON object, optionally with a bounding-box.
of_json json
converts the JSON to a topojson object (a type t
) or an error.