[Mapbender-commits] r9326 - in trunk/mapbender: http/css http/geoportal http/include http/plugins http/print http/print/classes lib resources/db resources/db/pgsql/UTF-8/update
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Dec 3 01:15:50 PST 2015
Author: pschmidt
Date: 2015-12-03 01:15:50 -0800 (Thu, 03 Dec 2015)
New Revision: 9326
Added:
trunk/mapbender/http/print/classes/mbSvgDecorator.php
trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.8_pgsql_UTF-8.sql
Removed:
trunk/mapbender/http/print/classes/mbSvgDecorator.php
Modified:
trunk/mapbender/http/css/digitize_new.css
trunk/mapbender/http/geoportal/geoportal_splash.php
trunk/mapbender/http/include/mapbender_logo_new.php
trunk/mapbender/http/plugins/mb_digitize_widget.php
trunk/mapbender/http/plugins/mb_print.php
trunk/mapbender/http/print/
trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
trunk/mapbender/resources/db/install.sh
Log:
add copy element
Modified: trunk/mapbender/http/css/digitize_new.css
===================================================================
--- trunk/mapbender/http/css/digitize_new.css 2015-12-01 13:22:43 UTC (rev 9325)
+++ trunk/mapbender/http/css/digitize_new.css 2015-12-03 09:15:50 UTC (rev 9326)
@@ -20,6 +20,10 @@
background-image: url('../img/gnome/edit-copy.png');
}
+.digitize-paste {
+ background-image: url('../img/gnome/edit-paste.png');
+}
+
.digitize-cursor {
background-image: url('../img/osgeo_graphics/geosilk/cursor.png');
}
@@ -82,6 +86,12 @@
bottom: 20px;
}
+.bottom-right-20 {
+ position: absolute;
+ right: 20px;
+ bottom: 20px;
+}
+
.digitize-move {
background-image: url('../img/button_blue_red/pan_off.png');
}
Modified: trunk/mapbender/http/geoportal/geoportal_splash.php
===================================================================
--- trunk/mapbender/http/geoportal/geoportal_splash.php 2015-12-01 13:22:43 UTC (rev 9325)
+++ trunk/mapbender/http/geoportal/geoportal_splash.php 2015-12-03 09:15:50 UTC (rev 9326)
@@ -1,3 +1,3 @@
<?php
-echo "<table width='100%' style='background-color:#FFFFFF'><tr align='center'><td><br><br><br><br><img alt='ajax-loader' src='../img/ajax-loader.gif'>"."    "."<img alt='logo'src='../geoportal/geoportal_logo.png'>"."    "."<img alt='ajax-loader' src='../img/ajax-loader.gif'></td></tr><tr align='center'><td><br><strong>"._mb('please wait ... ')."</strong></td></tr>"."<tr align='center'><td><br>"._mb('Loading application: ')."" . $this->guiId . "</td></tr></table>";
+echo "<table width='100%' style='background-color:#FFFFFF'><tr align='center'><td><br><br><br><br><img alt='ajax-loader' src='../img/ajax-loader.gif'>"." "."<img alt='logo' src='../geoportal/geoportal_logo.png'>"." "."<img alt='ajax-loader' src='../img/ajax-loader.gif'></td></tr><tr align='center'><td><br><strong>"._mb('please wait ... ')."</strong></td></tr>"."<tr align='center'><td><br>"._mb('Loading application: ')."" . $this->guiId . "</td></tr></table>";
?>
Modified: trunk/mapbender/http/include/mapbender_logo_new.php
===================================================================
--- trunk/mapbender/http/include/mapbender_logo_new.php 2015-12-01 13:22:43 UTC (rev 9325)
+++ trunk/mapbender/http/include/mapbender_logo_new.php 2015-12-03 09:15:50 UTC (rev 9326)
@@ -1,3 +1,3 @@
<?php
-echo "<table width='100%' style='background-color:#FFFFFF'><tr align='center'><td><br><br><br><br><img alt='ajax-loader' src='../img/ajax-loader.gif'>"."    "."<img alt='logo'src='../img/logo_geoportal_neu.png'>"."    "."<img alt='ajax-loader' src='../img/ajax-loader.gif'></td></tr><tr align='center'><td><br><strong>"._mb('please wait ... ')."</strong></td></tr>"."<tr align='center'><td><br>"._mb('Loading application: ')."" . $this->guiId . "</td></tr></table>";
+echo "<table width='100%' style='background-color:#FFFFFF'><tr align='center'><td><br><br><br><br><img alt='ajax-loader' src='../img/ajax-loader.gif'>"." "."<img alt='logo' src='../img/logo_geoportal_neu.png'>"."    "."<img alt='ajax-loader' src='../img/ajax-loader.gif'></td></tr><tr align='center'><td><br><strong>"._mb('please wait ... ')."</strong></td></tr>"."<tr align='center'><td><br>"._mb('Loading application: ')."" . $this->guiId . "</td></tr></table>";
?>
Modified: trunk/mapbender/http/plugins/mb_digitize_widget.php
===================================================================
--- trunk/mapbender/http/plugins/mb_digitize_widget.php 2015-12-01 13:22:43 UTC (rev 9325)
+++ trunk/mapbender/http/plugins/mb_digitize_widget.php 2015-12-03 09:15:50 UTC (rev 9326)
@@ -73,17 +73,17 @@
var DigitizeApi = function (o) {
var digitizeHtml = '<div title="<?php echo _mb("Sketch");?>">' +
- '<div title="<?php echo _mb("Digitize new point");?>"class="digitize-image digitize-point"></div>' +
- '<div title="<?php echo _mb("Digitize new line");?>"class="digitize-image digitize-line"></div>' +
- '<div title="<?php echo _mb("Digitize new polygon");?>"class="digitize-image digitize-polygon"></div>' +
- '<div title="<?php echo _mb("Attributes of collection");?>"class="digitize-image digitize-attributes editFeatureCollection"></div>' +
- '</div>';
+ '<div title="<?php echo _mb("Digitize new point");?>"class="digitize-image digitize-point"></div>' +
+ '<div title="<?php echo _mb("Digitize new line");?>"class="digitize-image digitize-line"></div>' +
+ '<div title="<?php echo _mb("Digitize new polygon");?>"class="digitize-image digitize-polygon"></div>' +
+ '<div title="<?php echo _mb("Attributes of collection");?>"class="digitize-image digitize-attributes editFeatureCollection"></div>' +
+ '</div>';
var editHtml = '<div title="<?php echo _mb("Edit feature");?>">' +
- '<div class="digitize-preview"></div>' +
- '<span>my polygon</span><br></br>' +
- '<div title="<?php echo _mb("Edit style");?>" class="digitize-image digitize-style"></div>' +
- '<div title="<?php echo _mb("Edit attributes");?>" class="digitize-image digitize-attributes"></div>' +
+ '<div class="digitize-preview"></div>' +
+ '<span>my polygon</span><br></br>' +
+ '<div title="<?php echo _mb("Edit style");?>" class="digitize-image digitize-style"></div>' +
+ '<div title="<?php echo _mb("Edit attributes");?>" class="digitize-image digitize-attributes"></div>' +
// '<div class="digitize-image digitize-add"></div>' +
'<div title="<?php echo _mb("Delete feature");?>" class="digitize-image digitize-remove"></div>' +
'<div title="<?php echo _mb("Edit geometry");?>" class="digitize-image digitize-pencil"></div>' +
@@ -94,8 +94,13 @@
'<div title="<?php echo _mb("Delete vertex");?>" class="digitize-image digitize-delete-vertex"></div></fieldset>' +
'<div title="<?php echo _mb("Export geometry");?>" class="digitize-image digitize-export digitize-export-edit-dialog"></div>' +
'</div>';
+ var copyHtml = '<div title="<?php echo _mb("Copy feature");?>">' +
+ '<div class="digitize-preview"></div>' +
+ '<span>my polygon</span><br></br>' +
+ '<div title="<?php echo _mb("Paste");?>" class="digitize-image digitize-paste bottom-right-20"></div>' +
+ '</div>';
- var editAttributesHtml = '<div title="<?php echo _mb("Feature attributes");?>">' +
+ var editAttributesHtml = '<div title="<?php echo _mb("Feature attributes");?>">' +
'<div class="digitize-image digitize-style"></div>' +
'<div class="digitize-preview"></div><br></br>' +
// '<div class="attrAccordion">' +
@@ -106,7 +111,7 @@
'<div title="<?php echo _mb("Save object");?>" class="digitize-image digitize-save"></div>' +
'</div>';
- var tableEditAttributesHtml = '<div title="<?php echo _mb("Feature attributes");?>">' +
+ var tableEditAttributesHtml = '<div title="<?php echo _mb("Feature attributes");?>">' +
'<div title="<?php echo _mb("Edit style");?>" class="digitize-image digitize-style"></div>' +
'<div class="digitize-preview"></div><br></br>' +
'<div class="attrAccordion">' +
@@ -115,7 +120,7 @@
'<div title="<?php echo _mb("Save object");?>" class="digitize-image digitize-save"></div>' +
'</div>';
- var editStyleHtml = '<div title="<?php echo _mb("Edit style");?>">' +
+ var editStyleHtml = '<div title="<?php echo _mb("Edit style");?>">' +
'<div class="digitize-preview"></div>' +
'<form id="digitize-marker-form"><label><input type="radio" name="marker-type" checked="checked" value="predefined"><?php echo _mb("Predefined");?></input></label>' +
'<label><input type="radio" name="marker-type" value="custom"><?php echo _mb("Custom");?></input></label></form>' +
@@ -139,7 +144,7 @@
'<button name="digitize-reset-style"><?php echo _mb("Reset");?></button>' +
'</div>';
- var folderMenu = '<ul class="digitize-contextmenu">' +
+ var folderMenu = '<ul class="digitize-contextmenu">' +
'<li><div class="digitize-image digitize-pencil"></div><?php echo _mb("Edit");?></li>' +
'<li><div class="digitize-image digitize-zoomto"></div><?php echo _mb("Zoom to");?></li>' +
'<li><div class="digitize-image digitize-add"></div><?php echo _mb("New");?></li>' +
@@ -148,7 +153,7 @@
'<li><div class="digitize-image digitize-close"></div><?php echo _mb("Close");?></li>' +
'</ul>';
- var geomMenu = '<ul class="digitize-contextmenu">' +
+ var geomMenu = '<ul class="digitize-contextmenu">' +
'<li><div class="digitize-image digitize-pencil"></div><?php echo _mb("Edit");?></li>' +
'<li><div class="digitize-image digitize-zoomto"></div><?php echo _mb("Zoom to");?></li>' +
// '<li><div class="digitize-image digitize-add"></div><?php echo _mb("New");?></li>' +
@@ -159,7 +164,7 @@
'<li><div class="digitize-image digitize-close"></div><?php echo _mb("Close");?></li>' +
'</ul>';
- var geomPartMenu = '<ul class="digitize-contextmenu">' +
+ var geomPartMenu = '<ul class="digitize-contextmenu">' +
'<li><div class="digitize-image digitize-pencil"></div><?php echo _mb("Edit");?></li>' +
'<li><div class="digitize-image digitize-zoomto"></div><?php echo _mb("Zoom to");?></li>' +
'<li><div class="digitize-image digitize-export"></div><?php echo _mb("Export");?></li>' +
@@ -167,7 +172,7 @@
'<li><div class="digitize-image digitize-close"></div><?php echo _mb("Close");?></li>' +
'</ul>';
- // var exportHtml = '<div id="export-dialog" title="<?php echo _mb("Export my features");?>">'
+ // var exportHtml = '<div id="export-dialog" title="<?php echo _mb("Export my features");?>">'
// + '<form>'
// + '<label class="export-format-kml">KML<input type="radio" name="export-format" value="kml" checked="checked"></input></label>'
// + '<label class="export-format-gpx">GPX<input type="radio" name="export-format" value="gpx"></input></label>'
@@ -176,18 +181,19 @@
// + '</form>'
// + '</div>';
- var exportHtml = '<div id="export-dialog"><table><tbody>' +
- '<tr><td>KML:</td><td><label class="export-format-kml exportDatasetIcon" style="padding-top:11px;"></label></td><td class="exportDataLink kml" '+
- 'outputFormat="kml"><img src="../img/gnome/document-save.png"/></td></tr>' +
- '<tr><td>GPX:</td><td><label class="export-format-gpx exportDatasetIcon" style="padding-top:11px;"></label></td><td class="exportDataLink gpx" '+
- 'outputFormat="gpx"><img src="../img/gnome/document-save.png"/></td></tr>' +
- '<tr><td>GeoJson:</td><td><label class="export-format-geojson exportDatasetIcon" style="padding-top:11px;"></label></td><td class="exportDataLink geojson" ' +
- 'outputFormat="geojson"><img src="../img/gnome/document-save.png"/></td></tr>' +
- '</tbody></table></div>';
+ var exportHtml = '<div id="export-dialog"><table><tbody>' +
+ '<tr><td>KML:</td><td><label class="export-format-kml exportDatasetIcon" style="padding-top:11px;"></label></td><td class="exportDataLink kml" '+
+ 'outputFormat="kml"><img src="../img/gnome/document-save.png"/></td></tr>' +
+ '<tr><td>GPX:</td><td><label class="export-format-gpx exportDatasetIcon" style="padding-top:11px;"></label></td><td class="exportDataLink gpx" '+
+ 'outputFormat="gpx"><img src="../img/gnome/document-save.png"/></td></tr>' +
+ '<tr><td>GeoJson:</td><td><label class="export-format-geojson exportDatasetIcon" style="padding-top:11px;"></label></td><td class="exportDataLink geojson" ' +
+ 'outputFormat="geojson"><img src="../img/gnome/document-save.png"/></td></tr>' +
+ '</tbody></table></div>';
var digitizeDialog,
editDialog,
+ copyDialog,
attributesDialog,
editStyleDialog,
icons = null,
@@ -260,6 +266,23 @@
editStyleDialog.dialog('close');
});
+ copyDialog = $(copyHtml);
+ copyDialog.dialog({
+ autoOpen: false,
+ position: [o.$target.offset().left, o.$target.offset().top]
+ }).bind("dialogclose", function () {
+ button.stop();
+/*
+ $(this).find('.digitize-image').unbind('click');
+*/
+ that.destroy();
+ $('#kmlTree li.kmltree-selected').removeClass('kmltree-selected');
+/*
+ attributesDialog.dialog('close');
+ editStyleDialog.dialog('close');
+ editDialog.dialog('close');
+*/
+ });
attributesDialog = $(editAttributesHtml);
attributesDialog.dialog({
autoOpen: false,
@@ -576,6 +599,7 @@
menu.menu('destroy').remove();
});
menu.children('li:has(.digitize-pencil)').bind('click', editObject($link, menu));
+ menu.children('li:has(.digitize-copy)').bind('click', copyObject($link, menu));
menu.children('li:has(.digitize-export)').bind('click', function() {
var kml = $('#mapframe1').data('kml');
var url = $link.parent().parent().attr('title');
@@ -886,6 +910,41 @@
};
};
+ var copyObject = function($link, menu) {
+ return function(e) {
+ copyDialog.find('*').unbind();
+ if($link.hasClass('kmltree-selected')) {
+ copyDialog.dialog('close');
+ return;
+ }
+ copyDialog.dialog('close');
+ $link.addClass('kmltree-selected').siblings().removeClass('kmltree-selected');
+ var idx = $link.attr('idx');
+ var kml = $('#mapframe1').data('kml');
+ var url = $link.parent().parent().attr('title');
+ var feature = kml._kmls[url].data.features[idx];
+
+ copyDialog.find('span').text(feature.properties.name);
+ copyDialog.dialog('open');
+
+ copyDialog.find('.digitize-paste').bind('click', function() {
+ var extent = $('#mapframe1').mapbender().extent;
+ var mapcenter = Proj4js.transform(kml.targetProj, kml.wgs84, extent.center);
+ var copied = kml.copyFeature(feature, mapcenter);
+ var copied_idx = kml.addFeature(url, kml.translateFeature(copied, mapcenter));
+ kml.zoomToFeature(url, copied_idx);
+ copyDialog.dialog('close');
+ $link.removeClass('kmltree-selected');
+ $('#kmlTree li li[title="'+url+'"] [idx="'+copied_idx+'"]').click();
+ });
+
+ var preview = copyDialog.find('.digitize-preview').html('').get(0);
+ kml.renderPreview(feature, preview);
+ if(menu)
+ menu.menu('destroy').remove();
+ };
+ };
+
var contextmenuLayer = function() {
var $link;
@@ -992,7 +1051,14 @@
});
});
attributesDialog.find('.digitize-save').bind('click', function() {
- kml.addGeometry(pts, digitizingFor, attributesDialog);
+ var attributes = {};
+ attributesDialog.find('table input').each(function() {
+ var name = $(this).attr('name');
+ if (name) {
+ attributes[name] = $(this).val();
+ }
+ });
+ kml.addGeometry(pts, digitizingFor, attributes);
attributesDialog.find('.digitize-save').unbind('click');
attributesDialog.dialog('close');
// digit.modeOff()
Modified: trunk/mapbender/http/plugins/mb_print.php
===================================================================
--- trunk/mapbender/http/plugins/mb_print.php 2015-12-01 13:22:43 UTC (rev 9325)
+++ trunk/mapbender/http/plugins/mb_print.php 2015-12-03 09:15:50 UTC (rev 9326)
@@ -656,7 +656,16 @@
updateFormField(formData, "map_svg_kml", "");
if(kml._kmls && $('#kml-rendering-pane svg:first').length){
for(var key in kml._kmls){ // object exists -> add svg
- updateFormField(formData, "map_svg_kml", '<?xml version="1.0" encoding="UTF-8"?>\n' + $($('#kml-rendering-pane').get(0)).html());
+ var svgStr = $($('#kml-rendering-pane').get(0)).html();
+ /* TODO start bug fix: multiple attributes xmlns="http://www.w3.org/2000/svg" by root svg at IE 9,10,11*/
+ var root = svgStr.match(/^<svg[^>]+/g);
+ if(root[0].match(/xmlns=["']http:\/\/www.w3.org\/2000\/svg["']/g).length > 1){
+ var svg1 = root[0].replace(/ xmlns=["']http:\/\/www.w3.org\/2000\/svg["']/g,'');
+ updateFormField(formData, "map_svg_kml", svg1 + ' xmlns="http://www.w3.org/2000/svg"' + svgStr.substring(root[0].length));
+ } else {
+ updateFormField(formData, "map_svg_kml", svgStr);
+ }
+ /* end bug fix */
break;
}
}
Property changes on: trunk/mapbender/http/print
___________________________________________________________________
Added: svn:ignore
+ .~lock.A4_portrait_official_template.odg#
.~lock.A4_portrait_template.odg#
.~lock.Hochformat_A4.odg#
Deleted: trunk/mapbender/http/print/classes/mbSvgDecorator.php
===================================================================
--- trunk/mapbender/http/print/classes/mbSvgDecorator.php 2015-12-01 13:22:43 UTC (rev 9325)
+++ trunk/mapbender/http/print/classes/mbSvgDecorator.php 2015-12-03 09:15:50 UTC (rev 9326)
@@ -1,118 +0,0 @@
-<?php
-
-class mbSvgDecorator extends mbTemplatePdfDecorator
-{
-// protected $pageElementType = "svg";
-// protected $elementId;
-
- protected $pageElementType = "map";
- protected $elementId;
- protected $filename;
- /* a decorator should declare which parameters could be overwritten through the request object */
- protected $overrideMembersFromRequest = array("res_dpi", "angle");
- protected $res_dpi;
- protected $angle = 0;
-
- public function __construct($pdfObj, $elementId, $mapConf, $controls, $svgParam)
- {
- parent::__construct($pdfObj, $mapConf, $controls);
- $this->elementId = $elementId;
- $this->filename = TMPDIR . "/" . parent::generateOutputFileName($svgParam, "png");
- $this->svgParam = $svgParam;
- $this->override();
- $this->decorate();
- }
-
- public function override()
- {
-
- }
-
- public function decorate()
- {
- require_once (dirname(__FILE__) . "/../print_functions.php");
-
- global $mapOffset_left, $mapOffset_bottom, $map_height, $map_width, $coord;
- global $yAxisOrientation;
- $yAxisOrientation = 1;
- $doc = new \DOMDocument();
- if (isset($_REQUEST[$this->svgParam]) && $_REQUEST[$this->svgParam] != "" && @$doc->loadXML($_REQUEST[$this->svgParam])) {
- $e = new mb_notice("mbSvgDecorator: svg: " . $_REQUEST[$this->svgParam]);
- } else {
- return "No svg found.";
- }
- $xpath = new \DOMXPath($doc);
- $xpath->registerNamespace("xlink", "http://www.w3.org/1999/xlink");
- $xpath->registerNamespace("svg", "http://www.w3.org/2000/svg");
- $coord = mb_split(",", $this->pdf->getMapExtent());
- $mapInfo = $this->pdf->getMapInfo();
- foreach ($mapInfo as $k => $v) {
- $e = new mb_notice("mbSvgDecorator: mapInfo: " . $k . "=" . $v);
- }
- $mapOffset_left = $mapInfo["x_ul"];
- $mapOffset_bottom = $mapInfo["y_ul"];
- $map_height = $mapInfo["height"];
- $map_width = $mapInfo["width"];
- $map_extent = explode(',', $mapInfo["extent"]);
-
- $oext = explode(',', $_REQUEST["svg_extent"]);
- $angle = isset($_REQUEST['angle']) && $_REQUEST['angle'] != "" ? floatval($_REQUEST['angle']) : 0;
- $svg_w = intval(preg_replace('[^0-9]', '', $doc->documentElement->getAttribute("width")));
- $svg_h = intval(preg_replace('[^0-9]', '', $doc->documentElement->getAttribute("height")));
- $res = $this->pdf->objPdf->k * ($this->conf->res_dpi / 72);
- $map_width_px = intval(round($map_width * $res));
- $map_height_px = intval(round($map_height * $res));
-
- // calculate factors for x and y
- $k_svg_x = ($oext[2] - $oext[0]) / $svg_w;
- $k_svg_y = ($oext[3] - $oext[1]) / $svg_h;
- // calculate offsets for x and y
- $offset_svg_x_px = ($oext[0] - $map_extent[0]) / $k_svg_x;
- $offset_svg_y_px = ($oext[3] - $map_extent[3]) / $k_svg_y;
- $svg_bbox_w = ($map_extent[2] - $map_extent[0]) / $k_svg_x;
- $svg_bbox_h = ($map_extent[3] - $map_extent[1]) / $k_svg_y;
-
- $scale = 1;
- $padding = 2;
- if ($svg_bbox_w > $svg_bbox_h) {
- $scale = ($map_width_px - $padding) / $svg_bbox_w;
- } else {
- $scale = ($map_height_px - $padding) / $svg_bbox_h;
- }
- if ($angle != 0) {
- $neededHeight = round(abs(sin(deg2rad($angle)) * $map_width_px) + abs(cos(deg2rad($angle)) * $map_width_px));
- $neededWidth = round(abs(sin(deg2rad($angle)) * $map_height_px) + abs(cos(deg2rad($angle)) * $map_height_px));
- $x = $offset_svg_x_px * $scale + ($neededWidth - $map_width_px) / 2;
- $y = (-$offset_svg_y_px * $scale) + ($neededHeight - $map_height_px) / 2;
- $doc->documentElement->setAttribute("height", $neededHeight);
- $doc->documentElement->setAttribute("width", $neededWidth);
- } else {
- $x = $offset_svg_x_px * $scale;
- $y = -$offset_svg_y_px * $scale;
- $doc->documentElement->setAttribute("height", $map_height_px);
- $doc->documentElement->setAttribute("width", $map_width_px);
- }
- foreach ($xpath->query("//*[@d]", $doc->documentElement) as $elm) {
- $elm->setAttribute('transform', "translate($x,$y) scale($scale,$scale)"); #rotate($angle, $rx0, $ry0)
- }
-
- foreach ($xpath->query("//*[@style]", $doc->documentElement) as $elm) {
- $elm->removeAttribute('style');
- }
- $imagick = new \Imagick();
- $imagick->setBackgroundColor(new \ImagickPixel('transparent'));
- $imagick->readImageBlob($doc->saveXML());
- $imagick->setImageFormat("png32");
- if ($angle != 0) {
- $imagick->rotateImage(new ImagickPixel('transparent'), $angle);
-// $imgWidth = $imagick->getImageWidth();
-// $imgHeight = $imagick->getImageHeight();
-// $imagick->cropImage($map_width_px, $map_height_px, ($imgWidth-$map_width_px)/2, ($imgHeight-$map_height_px)/2); orig, imagick bug?
- $imagick->cropImage($map_width_px, $map_height_px, ($neededWidth - $map_width_px) / 2,
- ($neededHeight - $map_height_px) / 2);
- }
- file_put_contents($this->filename, $imagick->getImageBlob());
- $this->pdf->objPdf->Image($this->filename, $mapOffset_left, $mapOffset_bottom, $map_width, $map_height, 'png');
- $this->pdf->unlink($this->filename);
- }
-}
Copied: trunk/mapbender/http/print/classes/mbSvgDecorator.php (from rev 9302, trunk/mapbender/http/print/classes/mbMeasureDecorator.php)
===================================================================
--- trunk/mapbender/http/print/classes/mbSvgDecorator.php (rev 0)
+++ trunk/mapbender/http/print/classes/mbSvgDecorator.php 2015-12-03 09:15:50 UTC (rev 9326)
@@ -0,0 +1,118 @@
+<?php
+
+class mbSvgDecorator extends mbTemplatePdfDecorator
+{
+// protected $pageElementType = "svg";
+// protected $elementId;
+
+ protected $pageElementType = "map";
+ protected $elementId;
+ protected $filename;
+ /* a decorator should declare which parameters could be overwritten through the request object */
+ protected $overrideMembersFromRequest = array("res_dpi", "angle");
+ protected $res_dpi;
+ protected $angle = 0;
+
+ public function __construct($pdfObj, $elementId, $mapConf, $controls, $svgParam)
+ {
+ parent::__construct($pdfObj, $mapConf, $controls);
+ $this->elementId = $elementId;
+ $this->filename = TMPDIR . "/" . parent::generateOutputFileName($svgParam, "png");
+ $this->svgParam = $svgParam;
+ $this->override();
+ $this->decorate();
+ }
+
+ public function override()
+ {
+
+ }
+
+ public function decorate()
+ {
+ require_once (dirname(__FILE__) . "/../print_functions.php");
+
+ global $mapOffset_left, $mapOffset_bottom, $map_height, $map_width, $coord;
+ global $yAxisOrientation;
+ $yAxisOrientation = 1;
+ $doc = new \DOMDocument();
+ if (isset($_REQUEST[$this->svgParam]) && $_REQUEST[$this->svgParam] != "" && @$doc->loadXML($_REQUEST[$this->svgParam])) {
+ $e = new mb_notice("mbSvgDecorator: svg: " . $_REQUEST[$this->svgParam]);
+ } else {
+ return "No svg found.";
+ }
+ $xpath = new \DOMXPath($doc);
+ $xpath->registerNamespace("xlink", "http://www.w3.org/1999/xlink");
+ $xpath->registerNamespace("svg", "http://www.w3.org/2000/svg");
+ $coord = mb_split(",", $this->pdf->getMapExtent());
+ $mapInfo = $this->pdf->getMapInfo();
+ foreach ($mapInfo as $k => $v) {
+ $e = new mb_notice("mbSvgDecorator: mapInfo: " . $k . "=" . $v);
+ }
+ $mapOffset_left = $mapInfo["x_ul"];
+ $mapOffset_bottom = $mapInfo["y_ul"];
+ $map_height = $mapInfo["height"];
+ $map_width = $mapInfo["width"];
+ $map_extent = explode(',', $mapInfo["extent"]);
+
+ $oext = explode(',', $_REQUEST["svg_extent"]);
+ $angle = isset($_REQUEST['angle']) && $_REQUEST['angle'] != "" ? floatval($_REQUEST['angle']) : 0;
+ $svg_w = intval(preg_replace('[^0-9]', '', $doc->documentElement->getAttribute("width")));
+ $svg_h = intval(preg_replace('[^0-9]', '', $doc->documentElement->getAttribute("height")));
+ $res = $this->pdf->objPdf->k * ($this->conf->res_dpi / 72);
+ $map_width_px = intval(round($map_width * $res));
+ $map_height_px = intval(round($map_height * $res));
+
+ // calculate factors for x and y
+ $k_svg_x = ($oext[2] - $oext[0]) / $svg_w;
+ $k_svg_y = ($oext[3] - $oext[1]) / $svg_h;
+ // calculate offsets for x and y
+ $offset_svg_x_px = ($oext[0] - $map_extent[0]) / $k_svg_x;
+ $offset_svg_y_px = ($oext[3] - $map_extent[3]) / $k_svg_y;
+ $svg_bbox_w = ($map_extent[2] - $map_extent[0]) / $k_svg_x;
+ $svg_bbox_h = ($map_extent[3] - $map_extent[1]) / $k_svg_y;
+
+ $scale = 1;
+ $padding = 2;
+ if ($svg_bbox_w > $svg_bbox_h) {
+ $scale = ($map_width_px - $padding) / $svg_bbox_w;
+ } else {
+ $scale = ($map_height_px - $padding) / $svg_bbox_h;
+ }
+ if ($angle != 0) {
+ $neededHeight = round(abs(sin(deg2rad($angle)) * $map_width_px) + abs(cos(deg2rad($angle)) * $map_width_px));
+ $neededWidth = round(abs(sin(deg2rad($angle)) * $map_height_px) + abs(cos(deg2rad($angle)) * $map_height_px));
+ $x = $offset_svg_x_px * $scale + ($neededWidth - $map_width_px) / 2;
+ $y = (-$offset_svg_y_px * $scale) + ($neededHeight - $map_height_px) / 2;
+ $doc->documentElement->setAttribute("height", $neededHeight);
+ $doc->documentElement->setAttribute("width", $neededWidth);
+ } else {
+ $x = $offset_svg_x_px * $scale;
+ $y = -$offset_svg_y_px * $scale;
+ $doc->documentElement->setAttribute("height", $map_height_px);
+ $doc->documentElement->setAttribute("width", $map_width_px);
+ }
+ foreach ($xpath->query("//*[@d]", $doc->documentElement) as $elm) {
+ $elm->setAttribute('transform', "translate($x,$y) scale($scale,$scale)"); #rotate($angle, $rx0, $ry0)
+ }
+
+ foreach ($xpath->query("//*[@style]", $doc->documentElement) as $elm) {
+ $elm->removeAttribute('style');
+ }
+ $imagick = new \Imagick();
+ $imagick->setBackgroundColor(new \ImagickPixel('transparent'));
+ $imagick->readImageBlob($doc->saveXML());
+ $imagick->setImageFormat("png32");
+ if ($angle != 0) {
+ $imagick->rotateImage(new ImagickPixel('transparent'), $angle);
+// $imgWidth = $imagick->getImageWidth();
+// $imgHeight = $imagick->getImageHeight();
+// $imagick->cropImage($map_width_px, $map_height_px, ($imgWidth-$map_width_px)/2, ($imgHeight-$map_height_px)/2); orig, imagick bug?
+ $imagick->cropImage($map_width_px, $map_height_px, ($neededWidth - $map_width_px) / 2,
+ ($neededHeight - $map_height_px) / 2);
+ }
+ file_put_contents($this->filename, $imagick->getImageBlob());
+ $this->pdf->objPdf->Image($this->filename, $mapOffset_left, $mapOffset_bottom, $map_width, $map_height, 'png');
+ $this->pdf->unlink($this->filename);
+ }
+}
Modified: trunk/mapbender/lib/mb.ui.displayKmlFeatures.js
===================================================================
--- trunk/mapbender/lib/mb.ui.displayKmlFeatures.js 2015-12-01 13:22:43 UTC (rev 9325)
+++ trunk/mapbender/lib/mb.ui.displayKmlFeatures.js 2015-12-03 09:15:50 UTC (rev 9326)
@@ -426,14 +426,15 @@
var item = this._kmls[url];
var bbox = this.getBbox(item.data.features[idx]);
-
+ var bufferx = (bbox[2] - bbox[0]) * 0.2;
+ var buffery = (bbox[3] - bbox[1]) * 0.2;
var min = Proj4js.transform(this.wgs84, this.targetProj, {
- x: bbox[0],
- y: bbox[1]
+ x: bbox[0] - bufferx,
+ y: bbox[1] - buffery
});
var max = Proj4js.transform(this.wgs84, this.targetProj, {
- x: bbox[2],
- y: bbox[3]
+ x: bbox[2] + bufferx,
+ y: bbox[3] + buffery
});
map.calculateExtent(
@@ -484,8 +485,65 @@
setQueriedLayer: function(url) {
this.queriedLayer = url;
},
+
+ addFeature: function(url, feature) {
+ if(!feature){
+ return;
+ }
+ this.cache = {};
+ var itm = this._kmls[url];
+ feature.properties.created = feature.properties.updated = new Date().toISOString();
+ feature.properties.uuid = UUID.genV4().toString();
+ itm.data.features.push(feature);
+ $('#mapframe1').data('kml').element.trigger('kml:loaded', {
+ type: "geojson",
+ data: itm.data,
+ url: itm.url,
+ display: itm.display,
+ refreshing: true,
+ });
+ return itm.data.features.length - 1;
+ },
+ translateFeature: function(feature, newCentroid){
+ var fc = this.getCentroid(feature);
+ var dx = newCentroid.x - fc.x;
+ var dy = newCentroid.y - fc.y;
+ switch (feature.geometry.type.toLowerCase()) {
+ case 'point':
+ feature.geometry.coordinates[0] = feature.geometry.coordinates[0] + dx;
+ feature.geometry.coordinates[1] = feature.geometry.coordinates[1] + dy;
+ return feature;
+ case 'linestring':
+ var coords = feature.geometry.coordinates;
+ for(var j = 0; j < coords.length; j++){
+ coords[j][0] = coords[j][0] + dx;
+ coords[j][1] = coords[j][1] + dy;
+ }
+ return feature;
- addGeometry: function(pts, url, attributesDialog) {
+ case 'polygon':
+ coords = feature.geometry.coordinates;
+ for(var i = 0; i < coords.length; i++){
+ for(var j = 0; j < coords[i].length; j++){
+ coords[i][j][0] = coords[i][j][0] + dx;
+ coords[i][j][1] = coords[i][j][1] + dy;
+ }
+ }
+ return feature;
+ }
+ return undefined;
+ },
+
+
+ copyFeature: function(feature) {
+ var temp = $.extend(true, {}, feature);
+ temp.properties.name = temp.properties.name + '_copied';
+ temp.properties.created = feature.properties.updated = new Date().toISOString();
+ temp.properties.uuid = UUID.genV4().toString();
+ return temp;
+ },
+
+ addGeometry: function(pts, url, attributes) {
this.cache = {};
var $map = $(this.element).mapbender();
var self = this;
@@ -512,14 +570,10 @@
var modifiedGeom = $.extend(true, {}, geom);
var modifiedData = new MultiGeometry(tp);
// add geometry: proof if polygon or linestring and add area or length
+ for(var k_ in attributes){
+ multi.e.setElement(k_, attributes[k_]);
+ }
- attributesDialog.find('table input').each(function() {
- var name = $(this).attr('name');
- if (name) {
- multi.e.setElement($(this).attr('name'), $(this).attr('value'));
- }
- });
-
if (geom.geomType != 'point') {
if (geom.geomType == 'polygon') {
@@ -582,13 +636,6 @@
} else {
-
- attributesDialog.find('table input').each(function() {
- var name = $(this).attr('name');
- if (name) {
- multi.e.setElement($(this).attr('name'), $(this).val());
- }
- });
if (icon == "false" || icon === false) {
multi.e.setElement("iconOffsetX", -10);
multi.e.setElement("iconOffsetY", -34);
@@ -785,6 +832,11 @@
}
return bbox;
},
+
+ getCentroid: function(feature){
+ var bbox = this.getBbox(feature);
+ return bbox ? {x: (bbox[0] + bbox[2]) / 2, y: (bbox[1] + bbox[3]) / 2} : undefined;
+ },
getBbox: function(feature) {
switch (feature.geometry.type.toLowerCase()) {
Modified: trunk/mapbender/resources/db/install.sh
===================================================================
--- trunk/mapbender/resources/db/install.sh 2015-12-01 13:22:43 UTC (rev 9325)
+++ trunk/mapbender/resources/db/install.sh 2015-12-03 09:15:50 UTC (rev 9326)
@@ -143,6 +143,7 @@
pgsql/$DBENCODING/update/update_2.7.2_to_2.7.3_pgsql_$DBENCODING.sql \
pgsql/$DBENCODING/update/update_2.7.3_to_2.7.4_pgsql_$DBENCODING.sql \
pgsql/$DBENCODING/update/update_2.7.4_to_2.8_pgsql_$DBENCODING.sql \
+ pgsql/$DBENCODING/update/update_2.8_pgsql_$DBENCODING.sql \
pgsql/pgsql_serial_set_sequences_2.7.sql \
> _install.sql
echo "inserting data (this might take a while longer)"
Added: trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.8_pgsql_UTF-8.sql
===================================================================
--- trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.8_pgsql_UTF-8.sql (rev 0)
+++ trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.8_pgsql_UTF-8.sql 2015-12-03 09:15:50 UTC (rev 9326)
@@ -0,0 +1 @@
+UPDATE gui_element SET e_content='<div id="printPDF_working_bg"></div><div id="printPDF_working"><img src="../img/indicator_wheel.gif" style="padding:10px 0 0 10px">Generating PDF</div><div id="printPDF_input"><form id="printPDF_form" action="../print/printFactory.php"><div id="printPDF_selector"></div><div class="print_option"><input type="hidden" id="map_url" name="map_url" value=""/><input type="hidden" id="legend_url" name="legend_url" value=""/><input type="hidden" id="opacity" name="opacity" value=""/> <input type="hidden" id="overview_url" name="overview_url" value=""/><input type="hidden" id="map_scale" name="map_scale" value=""/><input type="hidden" name="measured_x_values" /><input type="hidden" name="measured_y_values" /><input type="hidden" name="map_svg_kml" /><input type="hidden" name="svg_extent" /><input type="hidden" name="map_svg_measures" /><br /></div><div class="print_option" id="printPDF_formsubmit"><input id="submit" type="submit" value="Print"><br /></div></f
orm><div id="printPDF_result"></div></div>' WHERE e_id='printPDF';
More information about the Mapbender_commits
mailing list