[Mapbender-commits] r8120 - in branches/2.7/http: extensions/fpdf
img javascripts plugins print print/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Sep 8 13:01:26 EDT 2011
Author: kmq
Date: 2011-09-08 10:01:26 -0700 (Thu, 08 Sep 2011)
New Revision: 8120
Added:
branches/2.7/http/img/pinblau.png
Modified:
branches/2.7/http/extensions/fpdf/mb_fpdi.php
branches/2.7/http/javascripts/geometry.js
branches/2.7/http/plugins/mb_print.php
branches/2.7/http/print/A4_landscape_template.json
branches/2.7/http/print/classes/mbPermanentImgDecorator.php
branches/2.7/http/print/printFactory.php
Log:
print Highlights
Modified: branches/2.7/http/extensions/fpdf/mb_fpdi.php
===================================================================
--- branches/2.7/http/extensions/fpdf/mb_fpdi.php 2011-09-08 09:55:14 UTC (rev 8119)
+++ branches/2.7/http/extensions/fpdf/mb_fpdi.php 2011-09-08 17:01:26 UTC (rev 8120)
@@ -63,15 +63,15 @@
else
$info=$this->images[$file];
//Automatic width and height calculation if needed
- if($w==0 && $h==0)
+ if($w===0 && $h===0)
{
//Put image at 72 dpi
$w=$info['w']/$this->k;
$h=$info['h']/$this->k;
}
- if($w==0)
+ if($w===0)
$w=$h*$info['w']/$info['h'];
- if($h==0)
+ if($h===0)
$h=$w*$info['h']/$info['w'];
$x_rot = $x;
@@ -168,7 +168,7 @@
imagedestroy($plain_img);
//first embed mask image (w, h, x, will be ignored)
- $maskImg = $this->Image($tmp_alpha, 0,0,0,0, 'PNG', '', true);
+ $maskImg = $this->Image($tmp_alpha, 0,0,null,null, 'PNG', '', true);
//embed image, masked with previously embedded mask
$this->Image($tmp_plain,$x,$y,$w,$h,'PNG',$link, false, $maskImg);
Added: branches/2.7/http/img/pinblau.png
===================================================================
(Binary files differ)
Property changes on: branches/2.7/http/img/pinblau.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: branches/2.7/http/javascripts/geometry.js
===================================================================
--- branches/2.7/http/javascripts/geometry.js 2011-09-08 09:55:14 UTC (rev 8119)
+++ branches/2.7/http/javascripts/geometry.js 2011-09-08 17:01:26 UTC (rev 8120)
@@ -2170,7 +2170,7 @@
* @param {Object} aStyle the style of the div tags
* @param {Integer} the line width of the jsGraphics lines
*/
-function Highlight(aTargetArray, aTagName, aStyle, aLineWidth) {
+function Highlight(aTargetArray, aTagName, aStyle, aLineWidth, printable) {
var nodes = [];
/**
* removes a {@link MultiGeometry} object from the geometry Array
@@ -2234,6 +2234,9 @@
gA = new GeometryArray();
this.paint();
}
+ if (printable){
+ window.GlobalPrintableGeometries = null;
+ }
};
/**
@@ -2241,6 +2244,9 @@
*
*/
this.paint = function() {
+ if (printable){
+ window.GlobalPrintableGeometries = gA;
+ }
this.hide();
for (var i=0; i < canvas.length; i++) {
if (typeof(canvas[i]) == "object") {canvas[i].clean();}
Modified: branches/2.7/http/plugins/mb_print.php
===================================================================
--- branches/2.7/http/plugins/mb_print.php 2011-09-08 09:55:14 UTC (rev 8119)
+++ branches/2.7/http/plugins/mb_print.php 2011-09-08 17:01:26 UTC (rev 8120)
@@ -472,20 +472,30 @@
}
//write the permanent highlight image, if defined
- if ($("img.mapSymbol").length > 0) {
- var imgSrc = $("img.mapSymbol").attr("src");
- var TopLeftPos = $("img.mapSymbol").position();
- var TopLeftRealPos = makeClickPos2RealWorldPos(myTarget, TopLeftPos.left, TopLeftPos.top);
+ var markers = [];
+ var pixelpos= null;
+ var realpos= [null,null];
+ var feature = null;
- var BottomRightPos = $("img.mapSymbol").position();
- BottomRightPos.top = BottomRightPos.top + $("img.mapSymbol").height();
- BottomRightPos.left = BottomRightPos.left + $("img.mapSymbol").width();
- var BottomRightRealPos = makeClickPos2RealWorldPos(myTarget, BottomRightPos.left, BottomRightPos.top);
+ if(GlobalPrintableGeometries){
+ for(var idx = 0; idx < GlobalPrintableGeometries.count(); idx++ ) {
+ feature = GlobalPrintableGeometries.get(idx);
+ realpos = feature.get(0).get(0);
+ // The offsets are set to 40, meaning that images will need to be 80 x 80 with the tip of the marker- pixel being in the middle
+ markers.push({
+ position: [realpos.x,realpos.y],
+ path:"../img/pinblau.png",
+ width: 40 * 2,
+ height: 40 * 2,
+ offset_x: 40,
+ offset_y: 40,
+ });
+ }
+ var permanentImage = JSON.stringify(markers);
+ updateFormField(formData, "mypermanentImage", permanentImage);
- var permanentImg = imgSrc + "___" + TopLeftRealPos[0] + "___" + TopLeftRealPos[1] + "___" + BottomRightRealPos[0] + "___" + BottomRightRealPos[1];
- updateFormField(formData, "mypermanentImage", permanentImg);
}
if (f.map_url.value!="") {
Modified: branches/2.7/http/print/A4_landscape_template.json
===================================================================
--- branches/2.7/http/print/A4_landscape_template.json 2011-09-08 09:55:14 UTC (rev 8119)
+++ branches/2.7/http/print/A4_landscape_template.json 2011-09-08 17:01:26 UTC (rev 8120)
@@ -1,207 +1,210 @@
-{
- "type" : "templatePDF",
- "orientation" : "L",
- "units" : "mm",
- "format" : "a4",
- "controls" : [
- {
- "id" : "title",
- "label" : "Titel",
- "type" : "text",
- "size" : 20,
- "pageElementsLink" : {
- "titel" : "value"
- }
- },
- {
- "id" : "dpi",
- "label" : "DPI",
- "type" : "select",
- "size" : 20,
- "pageElementsLink" : {
- "karte" : "res_dpi"
- },
- "options" : [
- {
- "value" : "72",
- "label" : "72 dpi"
- },
- {
- "value" : "144",
- "label" : "144 dpi"
- },
- {
- "value" : "288",
- "label" : "288 dpi"
- }
- ]
- },
- {
- "id" : "comment1",
- "label" : "Kommentar1",
- "type" : "textarea",
- "size" : 5,
- "pageElementsLink" : {
- "kommentar1" : "value"
- }
- },
- {
- "id" : "comment2",
- "label" : "Kommentar 2",
- "type" : "textarea",
- "size" : 5,
- "pageElementsLink" : {
- "kommentar2" : "value"
- }
- },
- {
- "id" : "angle",
- "label" : "Winkel",
- "type" : "text",
- "pageElementsLink" : {
- "nordpfeil" : "angle",
- "karte" : "angle",
- "minikarte" : "angle"
- }
- },
- {
- "id" : "coordinates",
- "type" : "hidden"
- },
- {
- "id" : "scale",
- "label" : "Maßstab",
- "type" : "text",
- "pageElementsLink" : {
- "scale" : "value"
- }
- }
- ],
- "pages" : [
- {
- "tpl" : "A4_landscape_template.pdf",
- "useTplPage" : 1,
- "elements" : {
- "karte" : {
- "type" : "map",
- "res_dpi" : 72,
- "x_ul" : 8.8,
- "y_ul" : 13.6,
- "width" : 203.5,
- "height" : 180.8,
- "coords" : 1,
- "coords_font_family" : "Arial",
- "coords_font_size" : 8
- },
- "messung" : {
- "type" : "measure",
- "do_fill" : 0,
- "fill_color" : {
- "r" : 255,
- "g" : 0,
- "b" : 0
- },
- "do_stroke" : 0,
- "stroke_color" : {
- "r" : 0,
- "g" : 0,
- "b" : 0
- },
- "line_style" : {
- "width" : 1.0
- }
- },
- "minikarte" : {
- "type" : "overview",
- "res_dpi" : 72,
- "x_ul" : 222.3,
- "y_ul" : 13.6,
- "width" : 67.5,
- "height" : 60
- },
- "titel" : {
- "type" : "text",
- "x_ul" : 9,
- "y_ul" : 10,
- "font_family" : "Arial",
- "font_size" : 14
- },
- "scale" : {
- "type" : "text",
- "x_ul" : 245,
- "y_ul" : 123.8,
- "font_family" : "Arial",
- "font_size" : 12,
- "value" : "scale"
- },
- "date" : {
- "type" : "text",
- "x_ul" : 245,
- "y_ul" : 114,
- "font_family" : "Arial",
- "font_size" : 12,
- "value" : "date"
- },
- "time" : {
- "type" : "text",
- "x_ul" : 270,
- "y_ul" : 114,
- "font_family" : "Arial",
- "font_size" : 11,
- "value" : "time"
- },
- "nordpfeil" : {
- "type" : "image",
- "x_ul" : 230,
- "y_ul" : 85.5,
- "width" : 16,
- "height" : 16,
- "angle" : 0,
- "filename" : "./img/northarrow.png"
- },
- "kommentar1" : {
- "type" : "para",
- "x_ul" : 219,
- "y_ul" : 145,
- "font_family" : "Arial",
- "font_size" : 12,
- "width" : 45,
- "height" : 7,
- "align" : "L",
- "border" : 0,
- "fill" : 1,
- "border_width" : 0.5
- },
- "kommentar2" : {
- "type" : "para",
- "x_ul" : 219,
- "y_ul" : 152.5,
- "font_family" : "Arial",
- "font_size" : 12,
- "width" : 45,
- "height" : 7,
- "align" : "L",
- "border" : 0,
- "fill" : 1,
- "border_width" : 0.5
- }
- }
- },
- {
- "tpl" : "A4_landscape_template.pdf",
- "useTplPage" : 2,
- "elements" : {
- "legende" : {
- "type" : "legend",
- "x_ul" : 10,
- "y_ul" : 38,
- "width" : 90,
- "height" : 160,
- "font_family" : "Arial",
- "font_size" : 9,
- "scale" : 0.5
- }
- }
- }
- ]
+{
+ "type" : "templatePDF",
+ "orientation" : "L",
+ "units" : "mm",
+ "format" : "a4",
+ "controls" : [
+ {
+ "id" : "title",
+ "label" : "Titel",
+ "type" : "text",
+ "size" : 20,
+ "pageElementsLink" : {
+ "titel" : "value"
+ }
+ },
+ {
+ "id" : "dpi",
+ "label" : "DPI",
+ "type" : "select",
+ "size" : 20,
+ "pageElementsLink" : {
+ "karte" : "res_dpi"
+ },
+ "options" : [
+ {
+ "value" : "72",
+ "label" : "72 dpi"
+ },
+ {
+ "value" : "144",
+ "label" : "144 dpi"
+ },
+ {
+ "value" : "288",
+ "label" : "288 dpi"
+ }
+ ]
+ },
+ {
+ "id" : "comment1",
+ "label" : "Kommentar1",
+ "type" : "textarea",
+ "size" : 5,
+ "pageElementsLink" : {
+ "kommentar1" : "value"
+ }
+ },
+ {
+ "id" : "comment2",
+ "label" : "Kommentar 2",
+ "type" : "textarea",
+ "size" : 5,
+ "pageElementsLink" : {
+ "kommentar2" : "value"
+ }
+ },
+ {
+ "id" : "angle",
+ "label" : "Winkel",
+ "type" : "text",
+ "pageElementsLink" : {
+ "nordpfeil" : "angle",
+ "karte" : "angle",
+ "minikarte" : "angle"
+ }
+ },
+ {
+ "id" : "coordinates",
+ "type" : "hidden"
+ },
+ {
+ "id" : "scale",
+ "label" : "Maßstab",
+ "type" : "text",
+ "pageElementsLink" : {
+ "scale" : "value"
+ }
+ }
+ ],
+ "pages" : [
+ {
+ "tpl" : "A4_landscape_template.pdf",
+ "useTplPage" : 1,
+ "elements" : {
+ "karte" : {
+ "type" : "map",
+ "res_dpi" : 72,
+ "x_ul" : 8.8,
+ "y_ul" : 13.6,
+ "width" : 203.5,
+ "height" : 180.8,
+ "coords" : 1,
+ "coords_font_family" : "Arial",
+ "coords_font_size" : 8
+ },
+ "messung" : {
+ "type" : "measure",
+ "do_fill" : 0,
+ "fill_color" : {
+ "r" : 255,
+ "g" : 0,
+ "b" : 0
+ },
+ "do_stroke" : 0,
+ "stroke_color" : {
+ "r" : 0,
+ "g" : 0,
+ "b" : 0
+ },
+ "line_style" : {
+ "width" : 1.0
+ }
+ },
+ "permanentImage" : {
+ "type" : "permanentImage"
+ },
+ "minikarte" : {
+ "type" : "overview",
+ "res_dpi" : 72,
+ "x_ul" : 222.3,
+ "y_ul" : 13.6,
+ "width" : 67.5,
+ "height" : 60
+ },
+ "titel" : {
+ "type" : "text",
+ "x_ul" : 9,
+ "y_ul" : 10,
+ "font_family" : "Arial",
+ "font_size" : 14
+ },
+ "scale" : {
+ "type" : "text",
+ "x_ul" : 245,
+ "y_ul" : 123.8,
+ "font_family" : "Arial",
+ "font_size" : 12,
+ "value" : "scale"
+ },
+ "date" : {
+ "type" : "text",
+ "x_ul" : 245,
+ "y_ul" : 114,
+ "font_family" : "Arial",
+ "font_size" : 12,
+ "value" : "date"
+ },
+ "time" : {
+ "type" : "text",
+ "x_ul" : 270,
+ "y_ul" : 114,
+ "font_family" : "Arial",
+ "font_size" : 11,
+ "value" : "time"
+ },
+ "nordpfeil" : {
+ "type" : "image",
+ "x_ul" : 230,
+ "y_ul" : 85.5,
+ "width" : 16,
+ "height" : 16,
+ "angle" : 0,
+ "filename" : "./img/northarrow.png"
+ },
+ "kommentar1" : {
+ "type" : "para",
+ "x_ul" : 219,
+ "y_ul" : 145,
+ "font_family" : "Arial",
+ "font_size" : 12,
+ "width" : 45,
+ "height" : 7,
+ "align" : "L",
+ "border" : 0,
+ "fill" : 1,
+ "border_width" : 0.5
+ },
+ "kommentar2" : {
+ "type" : "para",
+ "x_ul" : 219,
+ "y_ul" : 152.5,
+ "font_family" : "Arial",
+ "font_size" : 12,
+ "width" : 45,
+ "height" : 7,
+ "align" : "L",
+ "border" : 0,
+ "fill" : 1,
+ "border_width" : 0.5
+ }
+ }
+ },
+ {
+ "tpl" : "A4_landscape_template.pdf",
+ "useTplPage" : 2,
+ "elements" : {
+ "legende" : {
+ "type" : "legend",
+ "x_ul" : 10,
+ "y_ul" : 38,
+ "width" : 90,
+ "height" : 160,
+ "font_family" : "Arial",
+ "font_size" : 9,
+ "scale" : 0.5
+ }
+ }
+ }
+ ]
}
Modified: branches/2.7/http/print/classes/mbPermanentImgDecorator.php
===================================================================
--- branches/2.7/http/print/classes/mbPermanentImgDecorator.php 2011-09-08 09:55:14 UTC (rev 8119)
+++ branches/2.7/http/print/classes/mbPermanentImgDecorator.php 2011-09-08 17:01:26 UTC (rev 8120)
@@ -17,80 +17,106 @@
global $mapOffset_left, $mapOffset_bottom, $map_height, $map_width, $coord;
global $yAxisOrientation;
$yAxisOrientation = 1;
+ $coord = mb_split(",",$this->pdf->getMapExtent());
+ $mapInfo = $this->pdf->getMapInfo();
+ $mapOffset_left = $mapInfo["x_ul"];
+ $mapOffset_bottom = $mapInfo["y_ul"];
+ $map_height = $mapInfo["height"];
+ $map_width = $mapInfo["width"];
+
if (isset($_REQUEST["mypermanentImage"]) && $_REQUEST["mypermanentImage"] != "") {
- $permanentImgStr = $_REQUEST["mypermanentImage"];
- $e = new mb_notice("mbPermanentImgDecorator: mypermanentImage values: ".$permanentImgStr);
+ $permanentImage = $_REQUEST["mypermanentImage"];
}
else {
return "No mypermanentImage values found.";
}
-
- $array_permanentImage = explode("___", $_REQUEST["mypermanentImage"]);
- $coord = mb_split(",",$this->pdf->getMapExtent());
- $mapInfo = $this->pdf->getMapInfo();
- $mapOffset_left = $mapInfo["x_ul"];
- $mapOffset_bottom = $mapInfo["y_ul"];
- $map_height = $mapInfo["height"];
- $map_width = $mapInfo["width"];
- # mypermanentImage (highlight symbol from geometry.js)
- if(count($array_permanentImage)>0){
- $permanentImage = $array_permanentImage[0];
- if($permanentImage=='false'){
- $permanentImage='';
- }
- $permanentImage_upperLeft_x = $array_permanentImage[1] ;
- $permanentImage_upperLeft_y = $array_permanentImage[2] ;
- $permanentImage_bottomRight_x = $array_permanentImage[3] ;
- $permanentImage_bottomRight_y = $array_permanentImage[4] ;
+ $markers = json_decode($permanentImage);
+ foreach( $markers as $marker){
- $real_width = $coord[2] - $coord[0];
- $ratio = $map_width / $real_width;
+ // left edge of the map on pdf
+ $pdf_map_x1 = $mapInfo["x_ul"]; // unit: mm
- $real_left = $permanentImage_upperLeft_x - $coord[0];
- $left = $mapOffset_left + ($real_left * $ratio);
+ // width of the map on the pdf
+ $pdf_map_dx =$mapInfo["width"]; //unit mm
+
- $real_right = $permanentImage_bottomRight_x - $coord[0];
- $right = $mapOffset_right + ($real_right * $ratio);
+ // left edge of the map on the map
+ $map_x1 = $coord[0]; // unit: coord
+ // right edge of the map on the map
+ $map_x2 = $coord[2]; // unit: coord
+
+ // width of map in on map
+ $map_dx = $map_x2 - $map_x1; //unit: coord
+
- $width = abs($left - $right);
- $width = 20;
- // delta map height in coords
- $real_height = $coord[3] - $coord[1];
- // ratio betwen map height in pt and map height in coord
- $ratio = ($map_height / $real_height);
+ // left edge of the image on map
+ $img_x1 = $marker->position[0]; //unit: coord
+
+ // the distance between the left edge of the map and the image on the map
+ $img_off_x = $img_x1 - $map_x1; //unit: coord
- // top position in coords
- $real_top = $permanentImage_upperLeft_y - $coord[1];
- // top position in pt
- $top = ($map_height - ($real_top * $ratio));
- $real_bottom = $permanentImage_bottomRight_y - $coord[1];
- // top position in pt
- $bottom = ($map_height - ($real_bottom * $ratio));
+ // add the marker offset to the left
+ $pdf_marker_off_x = ($marker->offset_x * 25.4)/$_REQUEST['dpi']; //unit: mm
+
+ // left edge of the image on the pdf
+ $pdf_img_off_x = ($pdf_map_x1 + $img_off_x * ($pdf_map_dx/$map_dx)) - $pdf_marker_off_x ; //unit: mm
- $height = abs($top - $bottom);
- $height = 20;
+ // width of the image on the pdf
+ $pdf_img_dx = ($marker->width * 25.4)/$_REQUEST['dpi']; //unit: mm
+
+ // top edge of the map on pdf
+ $pdf_map_y1 = $mapInfo["y_ul"]; // unit: mm
+ // height of the map on the pdf
+ $pdf_map_dy =$mapInfo["height"]; //unit mm
+
-$n = new mb_notice("mbPermanentImgDecorator: map_height :".$map_height);
-$n = new mb_notice("mbPermanentImgDecorator: real_height :".$real_height);
-$n = new mb_notice("mbPermanentImgDecorator: ratio :".$ratio);
-$n = new mb_notice("mbPermanentImgDecorator: target_height ============".$target_height);
+ // top edge of the map on the map
+ $map_y1 = $coord[1]; // unit: coord
+ // bottom edge of the map on the map
+ $map_y2 = $coord[3]; // unit: coord
+
+ // height of map in on map
+ $map_dy = $map_y2 - $map_y1; //unit: coord
+
-$n = new mb_notice("mbPermanentImgDecorator: left ============".$left);
-$n = new mb_notice("mbPermanentImgDecorator: top ============".$top);
- $this->pdf->objPdf->Image($permanentImage, $left, $top, $width, $height, 'png');
+ // top edge of the image on map
+ $img_y1 = $marker->position[1]; //unit: coord
+
+ // the distance between the top edge of the map and the image on the map
+ $img_off_y = $img_y1 - $map_y1; //unit: coord
- }
+
+ // add the marker offset to the top
+ $pdf_marker_off_y = ($marker->offset_y * 25.4)/$_REQUEST['dpi']; //unit: mm
+
+ // top edge of the image on the pdf
+ $pdf_img_off_y = $pdf_map_dy - ($pdf_map_y1 + $img_off_y * ($pdf_map_dy/$map_dy)) + $pdf_marker_off_y; //unit: mm
+
+ // width of the image on the pdf
+ $pdf_img_dy = ($marker->width * 25.4)/$_REQUEST['dpi']; //unit: mm
+
+
+ $left = $pdf_img_off_x;
+ $top = $pdf_img_off_y;
+ $width = $pdf_img_dx;
+ $height = $pdf_img_dy;
+ $path = dirname(__FILE__)."/../../frames/".$marker->path;
+ $this->pdf->objPdf->Image($path, $left, $top, $width, $height, 'png');
+
+
}
+
+ }
}
-?>
\ No newline at end of file
+?>
Modified: branches/2.7/http/print/printFactory.php
===================================================================
--- branches/2.7/http/print/printFactory.php 2011-09-08 09:55:14 UTC (rev 8119)
+++ branches/2.7/http/print/printFactory.php 2011-09-08 17:01:26 UTC (rev 8120)
@@ -23,14 +23,14 @@
$pdf->logRequests = $logRequests;
$pdf->logType = $logType;
-$pdf->render();
try {
+ $pdf->render();
$pdf->save();
}
catch (Exception $e) {
- new mb_exception($e->message);
- die;
+ new mb_exception($e->getMessage());
+ die($e->getMessage());
}
print $pdf->returnAbsoluteUrl();
-?>
\ No newline at end of file
+?>
More information about the Mapbender_commits
mailing list