D .ocamlformat => .ocamlformat +0 -0
M Makefile => Makefile +0 -1
@@ 28,7 28,6 @@ test/assert.ml:
build: lib/res.ml
@echo "let git_sha = \""`git rev-parse --short HEAD`"\"" > bin/version.ml
- @echo "let date = \""`date +'%FT%T%z'`"\"" >> bin/version.ml
dune build bin/geohash.exe
all: build
M bin/geohash.ml => bin/geohash.ml +2 -2
@@ 20,6 20,6 @@
let () =
(match Lib.Cgi.request_from_env () |> Lib.Cgi.consolidate with
- | Ok req -> Cgi.handle stdout req
- | Error _ -> Sys.argv |> Array.to_list |> Shell.exec)
+ | Ok req -> Cgi.handle stdout req
+ | Error _ -> Sys.argv |> Array.to_list |> Shell.exec)
|> exit
M bin/shell.ml => bin/shell.ml +7 -8
@@ 29,8 29,7 @@ let to_hash h = Ok [ h; "not implemented yet." ]
let print_version oc =
let exe = Filename.basename Sys.executable_name in
- Printf.fprintf oc "%s: https://mro.name/%s/v%s, built: %s\n" exe "geohash"
- Version.git_sha Version.date;
+ Printf.fprintf oc "%s: https://mro.name/%s/v%s\n" exe "geohash" Version.git_sha;
0
let print_help oc =
@@ 54,11 53,11 @@ let exec args =
| [ "-h" ] | [ "--help" ] -> print_help oc
| [ "-V" ] | [ "--version" ] -> print_version oc
| [ "--doap" ] ->
- Printf.fprintf oc "%s" Lib.Res.doap_rdf;
- 0
+ Printf.fprintf oc "%s" Lib.Res.doap_rdf;
+ 0
| [ i ] ->
- (i |> to_hash |> function
- | Ok h -> h |> String.concat " -> " |> Printf.fprintf oc "%s"
- | Error _ -> "ouch" |> Printf.fprintf oc "%s");
- 0
+ (i |> to_hash |> function
+ | Ok h -> h |> String.concat " -> " |> Printf.fprintf oc "%s"
+ | Error _ -> "ouch" |> Printf.fprintf oc "%s");
+ 0
| _ -> err 2 [ "get help with -h" ]
A doc/dune => doc/dune +1 -0
@@ 0,0 1,1 @@
+(documentation (package geohash))<
\ No newline at end of file
A doc/index.mld => doc/index.mld +29 -0
@@ 0,0 1,29 @@
+{0 Geohash}
+
+#🌐 geohash converter 🐫. Commandline and CGI. Zero-config, single-file.
+
+Convert WGS84 lat/lon pairs to {{:http://niemeyer.net/} Gustavo Niemeyer}s
+{{:http://en.wikipedia.org/wiki/Geohash} Geohash} and back. Web and commandline, 🐪,
+statically linked, single-file, zero-config.
+
+{1 Install}
+
+geohash.cgi is designed to be run and operated by yourself on your own webspace.
+
+1. download the cgi file from the {{:https://mro.name} downloads},
+
+2. copy it to a webserver and make it excutable (chmod 555),
+
+3. visit the url with your browser
+
+{1 Lat,Lon -> Geohash}
+
+{:https://demo.mro.name/geohash.cgi/?q=geo:31.630660,-7.984850}
+
+{:https://demo.mro.name/geohash.cgi/?q=31.630660,-7.984850}
+
+Do a HTTP 302 redirect to the according geohash.
+
+{1 Geohash -> GPX}
+
+{:https://demo.mro.name/geohash.cgi/evd7fq1tgw2k}
A dune-project => dune-project +29 -0
@@ 0,0 1,29 @@
+(lang dune 2.7)
+; https://dune.readthedocs.io/en/latest/opam.html#generating-opam-files
+
+(name geohash)
+
+(implicit_transitive_deps true)
+(generate_opam_files true)
+
+(license GPLv3)
+(maintainers "Marcus Rohrmoser <work@mro.name>")
+(authors "The GeoHash# programmers")
+
+(homepage https://demo.mro.name/geohash.cgi)
+(bug_reports https://codeberg.org/mro/geohash/issues)
+(source (uri git+ssh://codeberg.org/mro/geohash.git))
+
+(package
+ (name geohash)
+ (synopsis "#🌐 geohash converter 🐫. Commandline and CGI. Zero-config, single-file.")
+ (description "Convert WGS84 lat/lon pairs to [Gustavo Niemeyer](http://niemeyer.net/)s
+[Geohash](http://en.wikipedia.org/wiki/Geohash) and back. Web and commandline, 🐪,
+statically linked, single-file, zero-config.")
+ (tags (Social Web GeoHash CGI RFC3875))
+ (depends
+ (optint (>= 0.3))
+ (tyre (>= 0.5))
+ (odoc :with-doc)
+ (ocaml (and (>= 4.05) (< 4.12)))
+))
A geohash.opam => geohash.opam +36 -0
@@ 0,0 1,36 @@
+# This file is generated by dune, edit dune-project instead
+opam-version: "2.0"
+synopsis:
+ "#🌐 geohash converter 🐫. Commandline and CGI. Zero-config, single-file."
+description: """
+Convert WGS84 lat/lon pairs to [Gustavo Niemeyer](http://niemeyer.net/)s
+[Geohash](http://en.wikipedia.org/wiki/Geohash) and back. Web and commandline, 🐪,
+statically linked, single-file, zero-config."""
+maintainer: ["Marcus Rohrmoser <work@mro.name>"]
+authors: ["The GeoHash# programmers"]
+license: "GPLv3"
+tags: ["Social" "Web" "GeoHash" "CGI" "RFC3875"]
+homepage: "https://demo.mro.name/geohash.cgi"
+bug-reports: "https://codeberg.org/mro/geohash/issues"
+depends: [
+ "dune" {>= "2.7"}
+ "optint" {>= "1.0"}
+ "tyre"
+ "odoc" {with-doc}
+ "ocaml" {>= "4.05" & < "4.12"}
+]
+build: [
+ ["dune" "subst"] {dev}
+ [
+ "dune"
+ "build"
+ "-p"
+ name
+ "-j"
+ jobs
+ "@install"
+ "@runtest" {with-test}
+ "@doc" {with-doc}
+ ]
+]
+dev-repo: "git+ssh://codeberg.org/mro/geohash.git"
A lib/geohash.mli => lib/geohash.mli +9 -0
@@ 0,0 1,9 @@
+
+(** Hello, world! *)
+
+
+ (** encode a WGS84 (lat,lon) coordinate pair into Geohash of given length. *)
+ val encode : int -> (float * float) -> (string, int) result
+
+ (** decode a geohash base32 string to a WGS84 coordinate region center,delta. *)
+ val decode : string -> (((float * float) * (float * float)), string) result