[ANN] rtree 0.3.0

On behalf of the geocaml programmers, I am happy to announce the release of rtree.0.3.0. This release, after some community feedback removes the dependency on repr. For debugging and avoiding costly Stdlib.( = ) comparisons, users must now provide their own pp and equal functions for whatever they are storing in the rtree.

It seems I did not add an announcement for rtree.0.2.0 which added removal functions.

Migration Guide

Without having to hand-write your functions, users who are already depending on rtree can reuse their runtime type representation to define their pp and equal functions, like so:

module Line = struct
  type t = { p0 : float * float; p1 : float * float }

  let t =
    let open Repr in
    record "line" (fun p0 p1 -> { p0; p1 })
    |+ field "p0" (pair float float) (fun t -> t.p0)
    |+ field "p1" (pair float float) (fun t -> t.p1)
    |> sealr

  (* ADDED: New lines that add [equal] and [pp] functions defined
     using the existing runtime type representation. *)
  let equal = Repr.equal t |> Repr.unstage
  let pp = Repr.pp t

  type envelope = Rtree.Rectangle.t

  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

module R = Rtree.Make(Rtree.Rectangle)(Line)

However, users are encouraged to drop the dependency altogether and instead define these functions by hand.

Happy grouping-spatially! :two_hump_camel:

5 Likes