nur-packages

My NUR packages
git clone git://git.sikmir.ru/nur-packages
Log | Files | Refs | README | LICENSE

commit 4abfb87876060fbd533f8ee82a7f2255843712ac
parent 6a2100d4d06fa05bbf86e7797b31dbdf63c29beb
Author: Nikolay Korotkiy <sikmir@gmail.com>
Date:   Sun, 22 Nov 2020 19:45:28 +0300

Add map-tiler

Diffstat:
Mnix/sources.json | 14++++++++++++++
Mpkgs/default.nix | 1+
Apkgs/tools/geo/map-tiler/default.nix | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
Apkgs/tools/geo/map-tiler/gobject.patch | 27+++++++++++++++++++++++++++
Apkgs/tools/geo/map-tiler/python3.patch | 38++++++++++++++++++++++++++++++++++++++
5 files changed, 132 insertions(+), 0 deletions(-)

diff --git a/nix/sources.json b/nix/sources.json @@ -555,6 +555,20 @@ "url": "https://github.com/slazav/map_podm/archive/8b7994ba4a4bdc9673e982cf1f528cca1653d060.tar.gz", "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" }, + "map-tiler": { + "branch": "master", + "builtin": false, + "date": "2019-10-24T19:20:49Z", + "description": "Raster maps to map tiles", + "homepage": "https://github.com/wladich/map-tiler", + "owner": "wladich", + "repo": "map-tiler", + "rev": "1dc5be65e58638f5899cd6cdc2010e00ce5e62d4", + "sha256": "0y0ww7qsbgbc7xyh2dfp9xgvjqjah10ms44504023gqvbi9y206v", + "type": "tarball", + "url": "https://github.com/wladich/map-tiler/archive/1dc5be65e58638f5899cd6cdc2010e00ce5e62d4.tar.gz", + "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" + }, "mapper": { "branch": "master", "builtin": false, diff --git a/pkgs/default.nix b/pkgs/default.nix @@ -160,6 +160,7 @@ lib.makeScope newScope ( imgdecode = callPackage ./tools/geo/imgdecode { }; ish = callPackage ./tools/networking/ish { }; lsdreader = callPackage ./tools/dict/lsdreader { }; + map-tiler = callPackage ./tools/geo/map-tiler { }; morse-talk = callPackage ./tools/morse-talk { }; musig = callPackage ./tools/audio/musig { }; ocad2img = perlPackages.callPackage ./tools/geo/ocad2img { diff --git a/pkgs/tools/geo/map-tiler/default.nix b/pkgs/tools/geo/map-tiler/default.nix @@ -0,0 +1,52 @@ +{ lib, python3Packages, sources +, gobject-introspection, pango +, maprec, ozi_map, pyimagequant }: + +python3Packages.buildPythonApplication { + pname = "map-tiler"; + version = lib.substring 0 10 sources.map-tiler.date; + + src = sources.map-tiler; + + patches = [ + ./gobject.patch + ./python3.patch + ]; + + postPatch = '' + 2to3 -n -w *.py lib/*.py + substituteInPlace tiles_update.py \ + --replace "from . import image_store" "import image_store" \ + --replace "from .lib" "from lib" + ''; + + nativeBuildInputs = [ gobject-introspection pango ]; + + pythonPath = with python3Packages; [ + pillow purepng + pygobject3 pycairo + maprec ozi_map pyimagequant + ]; + + dontUseSetuptoolsBuild = true; + + doCheck = false; + + installPhase = '' + site_packages=$out/lib/${python3Packages.python.libPrefix}/site-packages + mkdir -p $site_packages + cp -r *.py lib $site_packages + + buildPythonPath "$out $pythonPath" + makeWrapper $site_packages/tiles_update.py $out/bin/tiles_update \ + --set PYTHONPATH $site_packages:$program_PYTHONPATH \ + --set GI_TYPELIB_PATH $GI_TYPELIB_PATH + ''; + + meta = with lib; { + inherit (sources.map-tiler) description homepage; + license = licenses.free; + maintainers = [ maintainers.sikmir ]; + platforms = platforms.unix; + }; +} diff --git a/pkgs/tools/geo/map-tiler/gobject.patch b/pkgs/tools/geo/map-tiler/gobject.patch @@ -0,0 +1,27 @@ +diff --git i/lib/attribution.py w/lib/attribution.py +index 1422bb6..1e07064 100644 +--- i/lib/attribution.py ++++ w/lib/attribution.py +@@ -1,8 +1,11 @@ + # coding: utf-8 + from PIL import Image + import cairo +-import pango +-import pangocairo ++import gi ++gi.require_version('Pango', '1.0') ++gi.require_version('PangoCairo', '1.0') ++from gi.repository import Pango as pango ++from gi.repository import PangoCairo as pangocairo + import math + + +@@ -27,7 +30,7 @@ def check_font_installed(): + + + def create_path(ctx, text, font_size_px, rotate): +- check_font_installed() ++ #check_font_installed() + ctx.set_line_width(font_size_px / 5.) + ctx.set_line_join(cairo.LINE_JOIN_ROUND) + ctx.save() diff --git a/pkgs/tools/geo/map-tiler/python3.patch b/pkgs/tools/geo/map-tiler/python3.patch @@ -0,0 +1,38 @@ +diff --git i/tiles_update.py w/tiles_update.py +index 2d73b9a..88be9da 100755 +--- i/tiles_update.py ++++ w/tiles_update.py +@@ -124,10 +124,10 @@ class JobManager(object): + fingerprint = maprecord.fingerprint + attrib_filename = attribution.get_attrib_path(maprecord.image_path) + if os.path.exists(attrib_filename): +- fingerprint = hashlib.sha1(fingerprint) +- fingerprint.update(':~:' + open(attrib_filename).read()) ++ fingerprint = hashlib.sha1(str(fingerprint).encode('utf-8')) ++ fingerprint.update(str(':~:' + open(attrib_filename).read()).encode('utf-8')) + info_filename = attribution.get_info_path(maprecord.image_path) +- fingerprint.update(':~:' + open(info_filename).read()) ++ fingerprint.update(str(':~:' + open(info_filename).read()).encode('utf-8')) + fingerprint = fingerprint.hexdigest() + return fingerprint + +@@ -225,8 +225,8 @@ def get_reprojected_image(tile_x, tile_y, level, map_reference): + src_has_alpha = True + cell_size = 64 + mesh = [] +- for cell_x in xrange(tile_size / cell_size): +- for cell_y in xrange(tile_size / cell_size): ++ for cell_x in xrange(int(tile_size / cell_size)): ++ for cell_y in xrange(int(tile_size / cell_size)): + x1 = cell_x * cell_size + y1 = cell_y * cell_size + x2 = x1 + cell_size +@@ -370,7 +370,7 @@ def build_overviews(altered_tiles): + + + def filename_arg_type(s): +- return s.decode(sys.getfilesystemencoding()) ++ return s + + + def parse_image_format(s):