Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.
/ geojson Public archive

Libraries and utilities for using GeoJSON in Clojure.

Notifications You must be signed in to change notification settings

FarmLogs/geojson

Repository files navigation

GeoJSON

Clojure utilities for using GeoJSON.

Installation

Add the following dependency to your project.clj:

[com.farmlogs/geojson "1.1.0"]

pre-commit

  • Install: https://pre-commit.com/
  • running locally: This will also happen automatically before committing to a branch, but you can also run the tasks with pre-commit run --all-files

Usage

This library's utilities act on clojure maps structured as GeoJSON.

The validation namespace verifies that a given GeoJSON is valid, following the details of the geojson spec.

(require '[geojson.validate :as gv])

(gv/valid? {:type "Point" :coordinates [0 0]})
(gv/valid? {:type "Feature"
            :properties {:name "Null Island"}
            :geometry {:type "Point" :coordinates [0 0]}})
(gv/valid? {:type "GeometryCollection"
            :geometries [{:type "Point" :coordinates [0 0]}
                         {:type "Polygon" :coordinates [[[0 0] [0 1] [1 1] [1 0] [0 0]]]}
                         {:type "LineString" :coordinates [[0 0] [1 1] [1 2]]}]})