Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Merge topic/with-dataset #15

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject element84/clj-gdal "0.3.2"
(defproject element84/clj-gdal "0.3.3"
:description "Clojure-idiomatic GDAL wrapper"
:url "http://github.com/Element84/clj-gdal"
:license {:name "Eclipse Public License"
Expand Down
5 changes: 5 additions & 0 deletions src/gdal/band.clj
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@
[band]
(.GetYSize band))

(defn get-size
"Fetch number of pixels along x and y axis"
[band]
[(get-x-size band) (get-y-size band)])

(defn has-arbitrary-overviews
"Check for arbitrary overviews"
[band]
Expand Down
23 changes: 20 additions & 3 deletions src/gdal/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,28 @@
[]
(gdal/AllRegister))

(defn open
"Open a raster file as a Dataset object"
[path]
(defmulti open class)

(defmethod open java.lang.String [path]
(gdal/Open path))

(defmethod open java.io.File [file]
(gdal/Open (.getAbsolutePath file)))

(defn close
"Frees native resources associated to dataset, closes file."
[dataset]
(.delete dataset))

(defmacro with-dataset
[[binding path] & body]
`(let [dataset# (open ~path)
~binding dataset#]
(try
(do ~@body)
(finally
(close dataset#)))))

(defn version-info
"Get information about the current version of GDAL"
[& request]
Expand Down