Skip to content

Pure OCaml parser for URIs for Geographic Locations

Notifications You must be signed in to change notification settings

geocaml/geo-uri

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

geo-uri

A pure OCaml library for building and parsing the geo URI scheme (a.k.a RFC5870).

Usage

You can build values using the v function. The simplest geo URI only has two components, each a coordinate.

# let geo = Geo_uri.v 12.34 45.67;;
val geo : Geo_uri.t = <abstr>
# Geo_uri.to_string geo;;
- : string = "geo:12.34,45.67"

More complex examples can add coordinate reference system (CRS) information, the level of uncertainty and additional key-value parameters.

# let geo = Geo_uri.v ~crs:`WGS84 ~uncertainty:1.2 ~params:[ "key", Some "value" ] 12.34 45.67;;
val geo : Geo_uri.t = <abstr>
# let s = Geo_uri.to_string geo;;
val s : string = "geo:12.34,45.67;crs=wgs84;u=1.2;key=value"

There are functions to get an OCaml value representing a geo URI from a string too.

# let geo' = Geo_uri.of_string s;;
val geo' : Geo_uri.t = <abstr>
# Geo_uri.coords_arr geo';;
- : float array = [|12.34; 45.67|]
# geo = geo' && s = Geo_uri.to_string geo';;
- : bool = true

About

Pure OCaml parser for URIs for Geographic Locations

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages