From 935387e6e80c6722b377d9567c85a7f9532998c9 Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@git-test.afi-sa.fr> Date: Sat, 19 Oct 2013 13:26:53 +0000 Subject: [PATCH] =?UTF-8?q?Ajout=20demo=20cr=C3=A9ation=20de=20tuiles=20po?= =?UTF-8?q?ur=20leaflet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 2 ++ scripts/leaflet/create_tiles.php | 31 ++++++++++++++++++++++++ scripts/leaflet/index.html | 41 ++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 scripts/leaflet/create_tiles.php create mode 100644 scripts/leaflet/index.html diff --git a/.gitattributes b/.gitattributes index 4c7eff28f50..57141f027e0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5558,6 +5558,8 @@ scripts/import_avis_csv.php -text scripts/import_sitotheque.php -text scripts/insert_licence.sh -text scripts/iosrd.sh -text +scripts/leaflet/create_tiles.php -text +scripts/leaflet/index.html -text scripts/majNoticesPanier.php -text scripts/majPaniers.php -text scripts/md5base64.pl -text diff --git a/scripts/leaflet/create_tiles.php b/scripts/leaflet/create_tiles.php new file mode 100644 index 00000000000..7c44ea7f07f --- /dev/null +++ b/scripts/leaflet/create_tiles.php @@ -0,0 +1,31 @@ +<?php +function createTilesSubcommand($zoom_level, $tile_width, $tiles_dir) { + $size = $tile_width * pow(2, $zoom_level); + + return + '\( mpr:output'. + ' -resize '.$size. + ' -write mpr:output'. + ' -crop '.$tile_width.'x'.$tile_width. + ' -set filename:f "'.$tiles_dir.'tile_%[fx:page.y/'.$tile_width.']_%[fx:page.x/'.$tile_width.'].jpg"'. + ' -write %[filename:f] \)'; + +} + + +function createSetOfTilesForZoomLevels($min_zoom, $max_zoom, $tiles_dir) { + $tile_commands = array_map( + function($zoom_level) use ($tiles_dir) { + $tiles_dir_for_zoom_level = $tiles_dir .'/'. ($zoom_level + 1).'/'; + is_dir($tiles_dir_for_zoom_level) || mkdir($tiles_dir_for_zoom_level, 0777, true); + return createTilesSubcommand($zoom_level, 256, $tiles_dir_for_zoom_level); + }, + array_reverse(range($min_zoom, $max_zoom)) + ); + + system('convert big.jpg -write mpr:output '.implode(' ',$tile_commands)); +} + +createSetOfTilesForZoomLevels(5, 5, './tiles'); +createSetOfTilesForZoomLevels(0, 4, './tiles'); +?> \ No newline at end of file diff --git a/scripts/leaflet/index.html b/scripts/leaflet/index.html new file mode 100644 index 00000000000..c81dcd02531 --- /dev/null +++ b/scripts/leaflet/index.html @@ -0,0 +1,41 @@ +<!DOCTYPE html> +<html> + <head> + <title>Test leaflet</title> + <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> + <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.css" /> + <!--[if lte IE 8]> + <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.ie.css" /> + <![endif]--> + + <script src="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.js"></script> + <style type="text/css"> + html, body { + height: 100%; + margin: 0; + } + + #map { + min-height: 100%; + background-color: black; + } + </style> + </head> + <body> + <div id="map" style="height:100%"></div> + + <script> + var map = L.map('map', { + maxZoom: 6, + minZoom: 2, + crs: L.CRS.Simple + }).setView([0, 0], 4); + + L.tileLayer('/tiling/tiles/{z}/tile_{y}_{x}.jpg', { + attribution: 'Bible de Souvigny', + noWrap: true + }).addTo(map); + + </script> + </body> +</html> -- GitLab