Module Cosmetyc.Basic

This module provides a simpler interface (without all its modular complexity) to the Cosmetyc library. It is not meant to be as expressive as the full library, but just to provide the minimal expected functions. Its source code can be an entry point on how to use the library in a more advanced manner.

OpenStreetMap Objects

Nodes

type node = Repr.Raw.node

A representation for OSM nodes.

val node_id : node -> Common.Id.t

Get the identifier of a node.

val node_tags : node -> Common.Tags.t

Get all the tags (key/value) of a node.

val node_position : node -> Common.Position.t

The position of a node, in spherical coordinates.

val create_node : ?id:Common.Id.t -> ?tags:Common.Tags.t -> Common.Position.t -> node

Smart constructor for node. If no identifier is provided, a new one will be generated.

Ways

type way = Repr.Raw.way

A representation for OSM ways.

val way_id : way -> Common.Id.t

Get the identifier of a way.

val way_tags : way -> Common.Tags.t

Get all the tags (key/value) of a way.

val way_nodes : way -> node list

Get the list of nodes of a way.

val create_way : ?id:Common.Id.t -> ?tags:Common.Tags.t -> node list -> way

Smart constructor for node. If no identifier is provided, a new one will be generated.

Relations

type relation = Repr.Raw.relation

A representation for OSM relations.

val relation_id : relation -> Common.Id.t

Get the identifier of a relation.

val relation_tags : relation -> Common.Tags.t

Get all the tags (key/value) of a relation.

type role = string

The role of a relation member. It may be the empty string.

type object_type = Repr.Raw.obj =
  1. | Node of node
  2. | Way of way
  3. | Relation of relation

A type to represent objects, of whichever kind.

val relation_members : relation -> (role * object_type) list

Get all the members of a relation, as well as their associated role.

val create_relation : ?id:Common.Id.t -> ?tags:Common.Tags.t -> (role * object_type) list -> relation

Smart constructor for node. If no identifier is provided, a new one will be generated.

OSM Data

type flux = object_type Stdlib.Seq.t

A flux of OSM objects

Input: getting OSM data from external sources

exception Parse_error of string

An exception that can be raised by the following input functions.

val read_GeoJson : Stdlib.in_channel -> flux

Parse a GeoJson file in a channel. The channel will be closed by the function.

val read_GeoJson_string : string -> flux

Parse a string representing the content of a GeoJson file.

val read_OSM_XML : Stdlib.in_channel -> flux

Parse an OSM XML file in a channel. The channel will be closed by the function.

val read_OSM_XML_string : string -> flux

Parse a string representing the content of an OSM XML file.

Output: exporting data to external locations

exception Write_error of string

An exception that can be raised by the following output functions.

val write_OSM_XML : ?indent:bool -> Stdlib.out_channel -> flux -> unit

Output an OSM XML file into an out-channel.

val write_OSM_XML_string : ?indent:bool -> flux -> string

Output an OSM XML file into a string. The optional argument states whether it should be indented.