gnu: All snippets report errors using exceptions, else return #t.
[jackhill/guix/guix.git] / gnu / packages / geo.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016 Leo Famulari <leo@famulari.name>
3 ;;; Copyright © 2016 Alex Griffin <a@ajgrf.com>
4 ;;; Copyright © 2017, 2018 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
5 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
6 ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
7 ;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
8 ;;;
9 ;;; This file is part of GNU Guix.
10 ;;;
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
15 ;;;
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
20 ;;;
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23
24 (define-module (gnu packages geo)
25 #:use-module (guix build-system glib-or-gtk)
26 #:use-module (guix build-system gnu)
27 #:use-module (guix build-system python)
28 #:use-module (guix build-system scons)
29 #:use-module (guix download)
30 #:use-module ((guix licenses) #:prefix license:)
31 #:use-module (guix packages)
32 #:use-module (guix utils)
33 #:use-module (gnu packages boost)
34 #:use-module (gnu packages check)
35 #:use-module (gnu packages compression)
36 #:use-module (gnu packages databases)
37 #:use-module (gnu packages fontutils)
38 #:use-module (gnu packages glib)
39 #:use-module (gnu packages gnome)
40 #:use-module (gnu packages gtk)
41 #:use-module (gnu packages image)
42 #:use-module (gnu packages icu4c)
43 #:use-module (gnu packages pkg-config)
44 #:use-module (gnu packages python)
45 #:use-module (gnu packages webkit)
46 #:use-module (gnu packages wxwidgets)
47 #:use-module (gnu packages xml))
48
49 (define-public geos
50 (package
51 (name "geos")
52 (version "3.6.2")
53 (source (origin
54 (method url-fetch)
55 (uri (string-append "http://download.osgeo.org/geos/geos-"
56 version
57 ".tar.bz2"))
58 (sha256
59 (base32
60 "0ak5szby29l9l0vy43dm5z2g92xzdky20q1gc1kah1fnhkgi6nh4"))))
61 (build-system gnu-build-system)
62 (arguments `(#:phases
63 (modify-phases %standard-phases
64 (add-after
65 'unpack 'patch-test-shebangs
66 (lambda _
67 (substitute* '("tests/xmltester/testrunner.sh"
68 "tests/geostest/testrunner.sh")
69 (("/bin/sh") (which "sh")))
70 #t)))))
71 (inputs
72 `(("glib" ,glib)))
73 (home-page "https://geos.osgeo.org/")
74 (synopsis "Geometry Engine for Geographic Information Systems")
75 (description
76 "GEOS provides a spatial object model and fundamental geometric
77 functions. It is a C++ port of the Java Topology Suite (JTS). As such,
78 it aims to contain the complete functionality of JTS in C++. This
79 includes all the OpenGIS Simple Features for SQL spatial predicate
80 functions and spatial operators, as well as specific JTS enhanced
81 topology functions.")
82 (license (list license:lgpl2.1+ ; Main distribution.
83 license:zlib ; tests/xmltester/tinyxml/*
84 license:public-domain)))) ; include/geos/timeval.h
85
86 (define-public gnome-maps
87 (package
88 (name "gnome-maps")
89 (version "3.26.2")
90 (source (origin
91 (method url-fetch)
92 (uri (string-append "mirror://gnome/sources/" name "/"
93 (version-major+minor version) "/"
94 name "-" version ".tar.xz"))
95 (sha256
96 (base32
97 "0l40l7m9dyphvasiq1jxrn6ivavs1xwzn0bzz2x1z7x73955q783"))))
98 (build-system glib-or-gtk-build-system)
99 (arguments
100 `(#:configure-flags ;; Ensure that geoclue is referred to by output.
101 (list (string-append "LDFLAGS=-L"
102 (assoc-ref %build-inputs "geoclue") "/lib")
103 (string-append "CFLAGS=-I"
104 (assoc-ref %build-inputs "geoclue") "/include"))
105 #:phases
106 (modify-phases %standard-phases
107 (add-after 'install 'wrap
108 (lambda* (#:key inputs outputs #:allow-other-keys)
109 (let ((out (assoc-ref outputs "out"))
110 (gi-typelib-path (getenv "GI_TYPELIB_PATH"))
111 (goa-path (string-append
112 (assoc-ref inputs "gnome-online-accounts")
113 "/lib"))
114 (webkitgtk-path (string-append
115 (assoc-ref inputs "webkitgtk")
116 "/lib")))
117 (wrap-program (string-append out "/bin/gnome-maps")
118 `("GI_TYPELIB_PATH" ":" prefix (,gi-typelib-path))
119
120 ;; There seems to be no way to embed the path of
121 ;; libgoa-1.0.so.0, libwebkit2gtk-4.0.so.37 and
122 ;; libjavascriptcoregtk-4.0.so.18.
123 `("LD_LIBRARY_PATH" ":" prefix (,goa-path ,webkitgtk-path)))
124 #t))))))
125 (native-inputs
126 `(("gobject-introspection" ,gobject-introspection)
127 ("intltool" ,intltool)
128 ("pkg-config" ,pkg-config)))
129 (inputs
130 `(("folks" ,folks)
131 ("libchamplain" ,libchamplain)
132 ("libgee" ,libgee)
133 ("libsecret" ,libsecret)
134 ("libsoup" ,libsoup)
135 ("libgweather" ,libgweather)
136 ("libxml2" ,libxml2)
137 ("gdk-pixbuf" ,gdk-pixbuf)
138 ("glib-networking" ,glib-networking)
139 ("geoclue" ,geoclue)
140 ("geocode-glib" ,geocode-glib)
141 ("gfbgraph" ,gfbgraph)
142 ("gjs" ,gjs)
143 ("glib" ,glib)
144 ("gnome-online-accounts" ,gnome-online-accounts)
145 ("gsettings-desktop-schemas" ,gsettings-desktop-schemas)
146 ("rest" ,rest)
147 ("webkitgtk" ,webkitgtk)))
148 (propagated-inputs
149 `(("gtk+3" ,gtk+)))
150 (synopsis "Graphical map viewer and wayfinding program")
151 (description "GNOME Maps is a graphical map viewer. It uses map data from
152 the OpenStreetMap project. It can provide directions for walking, bicycling,
153 and driving.")
154 (home-page "https://wiki.gnome.org/Apps/Maps")
155 (license license:gpl2+)))
156
157 (define-public libgaiagraphics
158 (package
159 (name "libgaiagraphics")
160 (version "0.5")
161 (source
162 (origin
163 (method url-fetch)
164 (uri (string-append "https://www.gaia-gis.it/gaia-sins/libgaiagraphics-"
165 version ".tar.gz"))
166 (sha256
167 (base32
168 "076afqv417ag3hfvnif0qc7qscmnq1dsf6y431yygwgf34rjkayc"))))
169 (build-system gnu-build-system)
170 (native-inputs
171 `(("pkg-config" ,pkg-config)))
172 (inputs
173 `(("cairo" ,cairo)
174 ("libpng" ,libpng)
175 ("libjepeg-turbo" ,libjpeg-turbo)
176 ("libtiff" ,libtiff)
177 ("libgeotiff" ,libgeotiff)
178 ("proj.4" ,proj.4)
179 ("libxml2" ,libxml2)
180 ("zlib" ,zlib)))
181 (synopsis "Gaia common graphics support")
182 (description "libgaiagraphics is a library supporting
183 common-utility raster handling methods.")
184 (home-page "https://www.gaia-gis.it/fossil/libgaiagraphics/index")
185 (license license:lgpl3+)))
186
187 (define-public libgeotiff
188 (package
189 (name "libgeotiff")
190 (version "1.4.2")
191 (source
192 (origin
193 (method url-fetch)
194 (uri (string-append "http://download.osgeo.org/geotiff/libgeotiff/libgeotiff-"
195 version ".tar.gz"))
196 (sha256
197 (base32
198 "0vjy3bwfhljjx66p9w999i4mdhsf7vjshx29yc3pn5livf5091xd"))
199 (modules '((guix build utils)))
200 (snippet
201 '(begin
202 ;; Remove .csv files, distributed from EPSG under a restricted
203 ;; license. See LICENSE for full license text.
204 (for-each delete-file (find-files "." "\\.csv$"))
205 ;; Now that we have removed the csv files, we need to modify the Makefile.
206 (substitute* "Makefile.in"
207 (("^all-am: .*$")
208 "all-am: Makefile $(LTLIBRARIES) $(HEADERS) geo_config.h\n")
209 (("^install-data-am: .*$")
210 "install-data-am: install-includeHEADERS"))
211 #t))))
212 (build-system gnu-build-system)
213 (inputs
214 `(("libjpeg-turbo" ,libjpeg-turbo)
215 ("libtiff" ,libtiff)
216 ("proj.4" ,proj.4)
217 ("zlib" ,zlib)))
218 (arguments
219 `(#:configure-flags
220 (list (string-append "--with-zlib")
221 (string-append "--with-jpeg")
222 (string-append "--with-libtiff=" (assoc-ref %build-inputs "libtiff")))))
223 (synopsis "Library for handling GeoTIFF (geographic enabled TIFF)")
224 (description "libgeotiff is a library on top of libtiff for reading and
225 writing GeoTIFF information tags.")
226 (home-page "https://trac.osgeo.org/geotiff/")
227 ;; This is a mixture of various contributions under different licenses.
228 ;; Note that the EPSG database is NOT "free to use" as the LICENSE file
229 ;; states, as its commercial redistribution is restricted. Hence, we have
230 ;; removed it from the package.
231 (license (list license:public-domain
232 license:x11
233 license:bsd-3
234 (license:non-copyleft "file://LICENSE"
235 "See LICENSE in the distribution.")))))
236
237 (define-public libspatialite
238 (package
239 (name "libspatialite")
240 (version "4.3.0a")
241 (source
242 (origin
243 (method url-fetch)
244 (uri (string-append "https://www.gaia-gis.it/gaia-sins/libspatialite-"
245 version ".tar.gz"))
246 (sha256
247 (base32
248 "16d4lpl7xrm9zy4gphy6nwanpjp8wn9g4wq2i2kh8abnlhq01448"))))
249 (build-system gnu-build-system)
250 (native-inputs
251 `(("pkg-config" ,pkg-config)))
252 (inputs
253 `(("freexl" ,freexl)
254 ("geos" ,geos)
255 ("libxml2" ,libxml2)
256 ("proj.4" ,proj.4)
257 ("sqlite" ,sqlite)
258 ("zlib" ,zlib)))
259 (arguments
260 `(#:phases
261 (modify-phases %standard-phases
262 ;; 3 tests are failing, ignore them:
263 (add-after 'unpack 'ignore-broken-tests
264 (lambda _
265 (substitute* '("test/Makefile.in")
266 (("\tcheck_sql_stm.*" all) "\tcheck_multithread$(EXEEXT) \\\n")
267 (("(\tch.*) check_v.*ble2.*$" all vt1) (string-append vt1 " \\\n"))
268 (("\tch.* (check_v.*ble4.*)$" all vt4) (string-append "\t" vt4)))
269 #t)))))
270 (synopsis "Extend SQLite to support Spatial SQL capabilities")
271 (description
272 "SpatiaLite is a library intended to extend the SQLite core to support
273 fully fledged Spatial SQL capabilities.")
274 (home-page "https://www.gaia-gis.it/fossil/libspatialite/index")
275 ;; For the genuine libspatialite-sources holds:
276 ;; Any of the licenses MPL1.1, GPL2+ or LGPL2.1+ may be picked.
277 ;; Files under src/control_points are from GRASS
278 ;; and are licensed under GPL2+ only.
279 ;; src/md5.[ch]: Placed into the public domain by Alexander Peslyak.
280 (license (list license:gpl2+
281 license:lgpl2.1+
282 license:mpl1.1
283 license:public-domain))))
284
285 (define-public proj.4
286 (package
287 (name "proj.4")
288 (version "4.9.3")
289 (source (origin
290 (method url-fetch)
291 (uri (string-append "http://download.osgeo.org/proj/proj-"
292 version ".tar.gz"))
293 (sha256
294 (base32
295 "1xw5f427xk9p2nbsj04j6m5zyjlyd66sbvl2bkg8hd1kx8pm9139"))))
296 (build-system gnu-build-system)
297 (arguments
298 `(#:phases
299 (modify-phases %standard-phases
300 (add-after 'unpack 'patch-test-paths
301 (lambda _
302 (substitute* '("nad/test27"
303 "nad/test83"
304 "nad/testvarious"
305 "nad/testdatumfile"
306 "nad/testflaky"
307 "nad/testIGNF")
308 (("/bin/rm") (which "rm")))
309 #t))
310 ;; Precision problems on i686 and other platforms. See:
311 ;; https://web.archive.org/web/20151006134301/http://trac.osgeo.org/proj/ticket/255
312 ;; Disable failing test.
313 (add-after 'patch-test-paths 'ignore-failing-tests
314 (lambda _
315 (substitute* '("nad/Makefile.in")
316 (("\tPROJ_LIB.*" all) (string-append "#" all)))
317 #t)))))
318 (inputs
319 `(("glib" ,glib)))
320 (home-page "http://proj4.org/")
321 (synopsis "Cartographic Projections Library")
322 (description
323 "Proj.4 is a library for converting coordinates between cartographic
324 projections.")
325 (license (list license:expat
326 ;; src/PJ_patterson.c
327 license:asl2.0
328 ;; src/geodesic.c/h
329 license:x11
330 ;; Embedded EPSG database.
331 (license:non-copyleft "http://www.epsg.org/TermsOfUse")
332 ;; cmake/*
333 license:boost1.0))))
334
335 (define-public mapnik
336 (package
337 (name "mapnik")
338 (version "3.0.18")
339 (source
340 (origin
341 (method url-fetch)
342 (uri (string-append "https://github.com/mapnik/mapnik/releases/download/v"
343 version "/mapnik-v" version ".tar.bz2"))
344 (sha256
345 (base32
346 "06frcikaj2mgz3abfk5h0z4j3hbksi0zikwjngbjv4p5f3pwxf8q"))))
347 (build-system scons-build-system)
348 (inputs
349 `(("boost" ,boost)
350 ("cairo" ,cairo)
351 ("freetype" ,freetype)
352 ("harfbuzz" ,harfbuzz)
353 ("icu4c" ,icu4c)
354 ("libjpeg-turbo" ,libjpeg-turbo)
355 ("libpng" ,libpng)
356 ("libtiff" ,libtiff)
357 ("libwebp" ,libwebp)
358 ("libxml2" ,libxml2)
359 ("proj.4" ,proj.4)
360 ("sqlite" ,sqlite)
361 ("zlib" ,zlib)))
362 (native-inputs
363 `(("pkg-config" ,pkg-config)))
364 (arguments
365 `(#:scons ,scons-python2
366 #:scons-flags
367 (list "CC=gcc"
368 (string-append "PREFIX=" %output)
369 (string-append "CUSTOM_LDFLAGS=-Wl,-rpath=" %output "/lib"))))
370 (home-page "http://mapnik.org/")
371 (synopsis "Toolkit for developing mapping applications")
372 (description "Mapnik is a toolkit for developing mapping applications. It
373 is basically a collection of geographic objects like maps, layers,
374 datasources, features, and geometries. At its core is a C++ shared library
375 providing algorithms and patterns for spatial data access and visualization.
376 The library does not rely on any specific windowing system and can be deployed
377 to any server environment. It is intended to play fair in a multi-threaded
378 environment and is aimed primarily, but not exclusively, at web-based
379 development.")
380 (license (list license:lgpl2.1+
381 ;; demo/viewer, demo/python/rundemo.py
382 license:gpl2+
383 ;; deps/boost, deps/mapbox, deps/agg/include/agg_conv_offset.h
384 license:boost1.0
385 ;; deps/mapnik/sparsehash
386 license:bsd-3
387 ;; deps/agg
388 (license:non-copyleft "file://deps/agg/copying")))))
389
390 (define-public python2-mapnik
391 (package
392 (name "python2-mapnik")
393 (version "3.0.16")
394 (source
395 (origin
396 (method url-fetch)
397 (uri (string-append "https://github.com/mapnik/python-mapnik/archive/v"
398 version ".tar.gz"))
399 (file-name (string-append name "-" version ".tar.gz"))
400 (sha256
401 (base32
402 "0w7wg72gnwmbjani9sqk42p2jwqkrl9hsdkawahni5m05xsifcb4"))))
403 (build-system python-build-system)
404 (inputs
405 `(("boost" ,boost)
406 ("harfbuzz" ,harfbuzz)
407 ("icu4c" ,icu4c)
408 ("libjpeg-turbo" ,libjpeg-turbo)
409 ("libpng" ,libpng)
410 ("libtiff" ,libtiff)
411 ("libwebp" ,libwebp)
412 ("mapnik" ,mapnik)
413 ("proj.4" ,proj.4)
414 ("python2-pycairo" ,python2-pycairo)))
415 (native-inputs
416 (let ((test-data-input
417 (lambda (repository version hash)
418 (origin
419 (method url-fetch)
420 (uri (string-append "https://github.com/mapnik/" repository
421 "/archive/v" version ".tar.gz"))
422 (file-name (string-append "python-mapnik-" repository
423 "-" version ".tar.gz"))
424 (sha256 (base32 hash))))))
425 `(("python2-nose" ,python2-nose)
426 ;; Test data is released as separate tarballs
427 ("test-data"
428 ,(test-data-input "test-data" "3.0.18"
429 "10cvgn5gxn8ldrszj24zr1vzm5w76kqk4s7bl2zzp5yvkhh8lj1n"))
430 ("test-data-visual"
431 ,(test-data-input "test-data-visual" "3.0.18"
432 "1cb9ghy8sis0w5fkp0dvwxdqqx44rhs9a9w8g9r9i7md1c40r80i")))))
433 (arguments
434 `(#:python ,python-2 ; Python 3 support is incomplete, and the build fails
435 #:phases
436 (modify-phases %standard-phases
437 ;; Unpack test data into the source tree
438 (add-after 'unpack 'unpack-submodules
439 (lambda* (#:key inputs #:allow-other-keys)
440 (let ((unpack (lambda (source target)
441 (with-directory-excursion target
442 (invoke "tar" "xvf" (assoc-ref inputs source)
443 "--strip-components=1")))))
444 (unpack "test-data" "test/data")
445 (unpack "test-data-visual" "test/data-visual"))))
446 ;; Skip failing tests
447 (add-after 'unpack 'skip-tests
448 (lambda _
449 (let ((skipped-tests (list "test_vrt_referring_to_missing_files"
450 "test_unicode_regex_replace"
451 "test_proj_antimeridian_bbox"
452 "test_render_with_scale_factor")))
453 (substitute* "setup.cfg"
454 (("\\[nosetests\\]" all)
455 (string-append all "\nexclude=^("
456 (string-join skipped-tests "|") ")$")))))))))
457 (home-page "https://github.com/mapnik/python-mapnik")
458 (synopsis "Python bindings for Mapnik")
459 (description "This package provides Python bindings for Mapnik.")
460 (license license:lgpl2.1+)))
461
462 (define-public spatialite-gui
463 (package
464 (name "spatialite-gui")
465 (version "1.7.1")
466 (source
467 (origin
468 (method url-fetch)
469 (uri (string-append "https://www.gaia-gis.it/gaia-sins/spatialite_gui-"
470 version ".tar.gz"))
471 (sha256
472 (base32
473 "1r05dz9pyc8vsd2wbqxcsracpfbaamz470rcyp2myfpqwznv376b"))))
474 (build-system gnu-build-system)
475 (native-inputs
476 `(("pkg-config" ,pkg-config)))
477 (inputs
478 `(("freexl" ,freexl)
479 ("geos" ,geos)
480 ("libgaiagraphics" ,libgaiagraphics)
481 ("libspatialite" ,libspatialite)
482 ("libxml2" ,libxml2)
483 ("proj.4" ,proj.4)
484 ("sqlite" ,sqlite)
485 ("wxwidgets" ,wxwidgets-2)
486 ("zlib" ,zlib)))
487 (synopsis "Graphical user interface for SpatiaLite")
488 (description "Spatialite-gui provides a visual interface for viewing and
489 maintaining a spatialite database. You can easily see the structure of the
490 tables and data contents using point and click functions, many of which
491 construct common SQL queries, or craft your own SQL queries.")
492 (home-page "https://www.gaia-gis.it/fossil/spatialite_gui/index")
493 (license license:gpl3+)))