diff --git a/Makefile b/Makefile index 773c4d0..857c94f 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,7 @@ install: build install -m 755 ${INSTALLOPTS} backends/test $(DESTDIR)/usr/lib/tirex/backends install -m 755 ${INSTALLOPTS} backends/wms $(DESTDIR)/usr/lib/tirex/backends install -m 755 ${INSTALLOPTS} backends/mapserver $(DESTDIR)/usr/lib/tirex/backends + install -m 755 ${INSTALLOPTS} backends/openseamap $(DESTDIR)/usr/lib/tirex/backends install -m 755 ${INSTALLOPTS} -d $(DESTDIR)/etc/tirex install -m 644 ${INSTALLOPTS} etc/tirex.conf.dist $(DESTDIR)/etc/tirex/tirex.conf install -m 755 ${INSTALLOPTS} -d $(DESTDIR)/etc/tirex/renderer @@ -44,10 +45,13 @@ install: build install -m 644 ${INSTALLOPTS} etc/renderer/test.conf.dist $(DESTDIR)/etc/tirex/renderer/test.conf install -m 644 ${INSTALLOPTS} etc/renderer/test/checkerboard.conf.dist $(DESTDIR)/etc/tirex/renderer/test/checkerboard.conf install -m 755 ${INSTALLOPTS} -d $(DESTDIR)/etc/tirex/renderer/wms + install -m 755 ${INSTALLOPTS} -d $(DESTDIR)/etc/tirex/renderer/openseamap install -m 755 ${INSTALLOPTS} -d $(DESTDIR)/etc/tirex/renderer/mapserver install -m 644 ${INSTALLOPTS} etc/renderer/wms.conf.dist $(DESTDIR)/etc/tirex/renderer/wms.conf + install -m 644 ${INSTALLOPTS} etc/renderer/openseamap.conf.dist $(DESTDIR)/etc/tirex/renderer/openseamap.conf install -m 644 ${INSTALLOPTS} etc/renderer/mapserver.conf.dist $(DESTDIR)/etc/tirex/renderer/mapserver.conf install -m 644 ${INSTALLOPTS} etc/renderer/wms/demowms.conf.dist $(DESTDIR)/etc/tirex/renderer/wms/demowms.conf + install -m 644 ${INSTALLOPTS} etc/renderer/openseamap/openseamap.conf.dist $(DESTDIR)/etc/tirex/renderer/openseamap/openseamap.conf install -m 644 ${INSTALLOPTS} etc/renderer/mapserver/msdemo.conf.dist $(DESTDIR)/etc/tirex/renderer/mapserver/msdemo.conf install -m 644 ${INSTALLOPTS} etc/renderer/mapserver/msdemo.map $(DESTDIR)/etc/tirex/renderer/mapserver/msdemo.map install -m 644 ${INSTALLOPTS} etc/renderer/mapserver/fonts.lst $(DESTDIR)/etc/tirex/renderer/mapserver/fonts.lst diff --git a/backends/openseamap b/backends/openseamap new file mode 100755 index 0000000..731d03e --- /dev/null +++ b/backends/openseamap @@ -0,0 +1,39 @@ +#!/usr/bin/perl +#----------------------------------------------------------------------------- +# +# Tirex Tile Rendering System +# +# backends/openseamap +# +#----------------------------------------------------------------------------- +# See Tirex::Backend::Test for documentation. +#----------------------------------------------------------------------------- +# +# Copyright (C) 2019 Frederik Ramm +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; If not, see . +# +#----------------------------------------------------------------------------- + +use strict; +use warnings; + +use Tirex::Backend::OpenSeaMap; + +#----------------------------------------------------------------------------- + +my $backend = Tirex::Backend::OpenSeaMap->new(); +$backend->main(); + +#-- THE END ------------------------------------------------------------------ diff --git a/debian/changelog b/debian/changelog index ecd548c..8753875 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +tirex (0.6.1) UNRELEASED; urgency=medium + + * add openseamap backend + + -- Frederik Ramm E Wed, 21 Aug 2019 16:10:48 +0200 + tirex (0.6.0) UNRELEASED; urgency=medium * tirex-syncd to use ssh master, also allow multiple destinations diff --git a/debian/control b/debian/control index 0223d9c..1a03f6a 100644 --- a/debian/control +++ b/debian/control @@ -52,6 +52,13 @@ Description: Mapnik backend for the Tirex tile rendering system The Tirex suite of programs manages map tile rendering and caching. This is the Mapnik backend for creating maps with the Mapnik renderer. +Package: tirex-backend-openseamap +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, tirex-core, default-jre-headless | java8-runtime-headless +Description: OpenSeaMap backend for the Tirex tile rendering system + The Tirex suite of programs manages map tile rendering and caching. + This is the OpenSeaMap backend for creating maps with the OpenSeaMap renderer. + Package: tirex-syncd Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, tirex-core diff --git a/debian/rules b/debian/rules index 2d9d210..5921c26 100755 --- a/debian/rules +++ b/debian/rules @@ -48,7 +48,7 @@ binary-arch: build install # the following line handles all packages *except* tirex-core dh_install --no-package tirex-core --sourcedir=$(CURDIR)/debian/tmp # the following line handles *only* the tirex-core package, it excludes some perl libraries that should not end up in this package - dh_install --no-package tirex-backend-wms --no-package tirex-backend-mapserver --no-package tirex-backend-mapnik --no-package tirex-munin-plugin --no-package tirex-nagios-plugin --no-package tirex-syncd --no-package --tirex-example-map --exclude Munin --exclude Tirex::Backend::WMS --exclude Tirex::Backend::Mapserver --exclude Backend/WMS --exclude Backend/Mapserver --sourcedir=$(CURDIR)/debian/tmp + dh_install --no-package tirex-backend-wms --no-package tirex-backend-mapserver --no-package tirex-backend-openseamap --no-package tirex-backend-mapnik --no-package tirex-munin-plugin --no-package tirex-nagios-plugin --no-package tirex-syncd --no-package --tirex-example-map --exclude Munin --exclude Tirex::Backend::WMS --exclude Tirex::Backend::Mapserver --exclude Tirex::Backend::OpenSeaMap --exclude Backend/WMS --exclude Backend/Mapserver --exclude Backend/OpenSeaMap --sourcedir=$(CURDIR)/debian/tmp # dh_installmenu # dh_installdebconf # dh_installlogrotate diff --git a/etc/renderer/openseamap.conf.dist b/etc/renderer/openseamap.conf.dist new file mode 100644 index 0000000..978130e --- /dev/null +++ b/etc/renderer/openseamap.conf.dist @@ -0,0 +1,38 @@ +#----------------------------------------------------------------------------- +# +# Konfiguration for OpenSeaMap renderer +# +# /etc/tirex/renderer/openseamap.conf +# +#----------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# General configuration +#----------------------------------------------------------------------------- + +# symbolic name +name=openseamap + +# path to executable of renderer +path=/usr/lib/tirex/backends/openseamap + +# UDP port where the master can contact this renderer +# must be individual for each renderer +port=9334 + +# number of processes that should be started +procs=3 + +# syslog facility +#syslog_facility=daemon + +# activate this to see debug messages from renderer +#debug=1 + +#----------------------------------------------------------------------------- +# Backend specific configuration +#----------------------------------------------------------------------------- + +# none + +#-- THE END ------------------------------------------------------------------ diff --git a/etc/renderer/openseamap/openseamap.conf.dist b/etc/renderer/openseamap/openseamap.conf.dist new file mode 100644 index 0000000..b0ded66 --- /dev/null +++ b/etc/renderer/openseamap/openseamap.conf.dist @@ -0,0 +1,36 @@ +#----------------------------------------------------------------------------- +# +# Configuration for OpenSeaMap map +# +# /etc/tirex/renderer/openseamap/openseamap.conf +# +#----------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# General configuration +#----------------------------------------------------------------------------- + +# symbolic name of this map +name=openseamap + +# tile directory +tiledir=/var/lib/tirex/tiles/openseamap + +# minimum zoom level allowed (default 0) +#minz=0 + +# maximum zoom level allowed (default 17) +maxz=18 + +#----------------------------------------------------------------------------- +# Backend specific configuration +#----------------------------------------------------------------------------- + +# actual rendering program +jar=/srv/jrenderpgsql/jrenderpgsql.jar + +# how to access the database +dburl=jdbc:postgresql:///gis?user=postgres&password=postgres + + +#-- THE END ------------------------------------------------------------------ diff --git a/lib/Tirex/Backend/OpenSeaMap.pm b/lib/Tirex/Backend/OpenSeaMap.pm new file mode 100644 index 0000000..277b0cc --- /dev/null +++ b/lib/Tirex/Backend/OpenSeaMap.pm @@ -0,0 +1,123 @@ +#----------------------------------------------------------------------------- +# +# Tirex/Backend/OpenSeaMap.pm +# +#----------------------------------------------------------------------------- + +use strict; +use warnings; + +use List::Util qw(); +use Carp; + +use Tirex::Backend; + +#----------------------------------------------------------------------------- + +package Tirex::Backend::OpenSeaMap; +use base qw( Tirex::Backend ); + +=head1 NAME + +Tirex::Backend::OpenSeaMap - OpenSeaMap backend for Tirex + +=head1 DESCRIPTION + +This backend calls an external Java program to generate an OpenSeaMap +meta tile. The Java program is here: https://svn.openstreetmap.org/applications/editors/josm/plugins/seachart/jrenderpgsql/ + +Config parameters for the map file: + +=over 8 + +=item dburl the JDBC database connection URL, with username and password if needed + +=item jar the JAR file containing the JRenderPsql class to use + +=item scalefactor the scale factor (defaults to 1.0) + +=item tilesize the tile size (should be 256 * scalefactor to avoid issues) + +=head1 METHODS + +=head2 $backend->init() + +This method initializes things specific to this backend. + +=cut + +sub init +{ + my $self = shift; + + $self->{'border_width'} = 6; + GD::Image->trueColor(1); + +} + +=head2 $backend->check_map_config($map) + +=cut + +sub check_map_config +{ + my $self = shift; + my $map = shift; + + if ($Tirex::METATILE_COLUMNS != $Tirex::METATILE_ROWS) + { + Carp::croak("this plugin cannot work with non-square meta tiles"); + } + + if (!defined($map->{'jar'})) + { + Carp::croak("must configure renderer in map file"); + } + + if (!-f $map->{'jar'}) + { + Carp::croak("configured renderer " . $map->{'jar'} . " does not exist"); + } + + if (!defined($map->{'dburl'})) + { + Carp::croak("must configure dburl in map file"); + } +} + +=head2 $backend->create_metatile() + +Create a metatile. + +=cut + +sub create_metatile +{ + my $self = shift; + my $map = shift; + my $metatile = shift; + + my $xc = $metatile->get_x(); + my $yc = $metatile->get_y(); + my $zoom = $metatile->get_z(); + + my $pixel = $Tirex::PIXEL_PER_TILE; + my $tmpfile = "/tmp/tirex-$$-openseamap.png"; + my $cmdline = sprintf("java -jar %s --scale %f --tilesize %d '%s' %d %d %d %s", + $map->{'jar'}, $map->{'scalefactor'}, $map->{'tilesize'} * $Tirex::METATILE_COLUMNS, $map->{'dburl'}, $zoom , $xc, $yc, $tmpfile); + + ::syslog('debug', 'OpenSeaMap request: %s', $cmdline) if ($Tirex::DEBUG); + system($cmdline); + + my $image = GD::Image->new($tmpfile); + $image->alphaBlending(0); + $image->saveAlpha(1); + + unlink ($tmpfile); + return $image; +} + + +1; + +#-- THE END ------------------------------------------------------------------