package rtree

  1. Overview
  2. Docs

Module S.Value

Values stored in the Rtree.

Values are stored in the Rtree and must provide a means of calculating an envelope (minimal bounding box).

An example

A two-dimensional lines that uses Rectangle as a bounding box could be implemented as

module Line = struct
  type t = { p0 : float * float; p1 : float * float }
  type envelope = Rtree.Rectangle.t

  let equal = Stdlib.( = )

  let envelope { p0 = x1, y1; p1 = x2, y2 } =
    let x0 = Float.min x1 x2 in
    let x1 = Float.max x1 x2 in
    let y0 = Float.min y1 y2 in
    let y1 = Float.max y1 y2 in
    Rtree.Rectangle.v ~x0 ~y0 ~x1 ~y1
end

Note that a runtime representation must also be provided.

Interface

type t

A type for things stored in the Rtree.

val equal : t -> t -> bool

equal a b checks if the value a is equal to b.

val pp : Format.formatter -> t -> unit

pp fmt v is a pretty printer for values.

type envelope = Envelope.t

A type for envelopes in the Rtree.

val envelope : t -> envelope

Given a value, calculates the envelope for it.