Liking cljdoc? Tell your friends :D

com.dcj/honeysql-postgis

Clojars Project md-docs build-provenance

PostGIS function helpers for HoneySQL.

Install

deps.edn:

{:deps {com.dcj/honeysql-postgis {:mvn/version "0.3.0"}}}

HoneySQL itself is not a dependency. Every function returns a plain vector in HoneySQL's DSL and nothing here calls HoneySQL, so declaring it would force a version on you for no benefit. The vectors are compatible with HoneySQL 2.

Usage

(require '[honeysql-postgis.helpers :as h]
         '[honey.sql :as sql])

(sql/format-expr (h/ST_3DDistance :t_trajectory :loi))
;; => ["ST_3DDISTANCE(t_trajectory, loi)"]

They compose, which is how a projected distance gets built:

(-> (h/ST_MakePoint -122.0 37.5 16.1)
    (h/ST_SetSRID 4326)
    (h/ST_Transform 6419)
    sql/format-expr)
;; => ["ST_TRANSFORM(ST_SETSRID(ST_MAKEPOINT(?, ?, ?), CAST(? AS INTEGER)), CAST(? AS INTEGER))"
;;     -122.0 37.5 16.1 4326 6419]

ST_Transform and ST_SetSRID cast the SRID

Those two add something the bare call does not, and it is the reason to reach for them rather than writing the vector by hand. A bound parameter arrives at PostGIS as bigint, while both function signatures take integer, so the call does not resolve:

ERROR: function st_setsrid(geometry, bigint) does not exist

So they wrap the SRID in [:cast srid :integer]:

(sql/format-expr (h/ST_Transform :g 6419))
;; => ["ST_TRANSFORM(g, CAST(? AS INTEGER))" 6419]

(sql/format-expr [:ST_Transform :g 6419])          ; the bare call
;; => ["ST_TRANSFORM(g, ?)" 6419]                  ; no cast, and it fails

The SRID stays a parameter; only its type is pinned.

The rest

ST_X, ST_Y, ST_Z, ST_M, ST_AsText, ST_DumpPoints, ST_MakePoint, ST_MakeLine, ST_3DDistance and ST_3DClosestPoint each return the vector you would otherwise write, so they are a naming convenience: (h/ST_X :g) reads as PostGIS where [:ST_X :g] reads as data.

API documentation

The full API reference is embedded in the JAR as Markdown via codox-md, and is discoverable at runtime through clj-doc-browse:

(require '[doc.browse :as docs])

(docs/print-doc "honeysql-postgis.helpers")

Development

clojure -M:test                 # kaocha
clojure -M:nrepl                # REPL with cider-nrepl and clj-doc-browse
clojure -T:build ci             # test, docs, provenance, jar
clojure -T:build install        # install into ~/.m2
clojure -T:build tag            # tag HEAD as v<version>
clojure -T:build deploy         # Clojars

The version lives in build.clj and nowhere else. deploy refuses unless the tree is clean and v<version> points at HEAD, and it selects the Clojars token by the artifact's group, so nothing need be passed on the command line.

License

MIT License — Copyright (c) 2026 Clark Communications Corporation

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close