[Mapbender-commits] r3567 - in branches/print_dev/http/print: .
classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed Feb 18 11:02:42 EST 2009
Author: mschulz
Date: 2009-02-18 11:02:42 -0500 (Wed, 18 Feb 2009)
New Revision: 3567
Added:
branches/print_dev/http/print/classes/mbMeasureDecorator.php
Modified:
branches/print_dev/http/print/classes/mbMapDecorator.php
branches/print_dev/http/print/classes/mbTemplatePdf.php
branches/print_dev/http/print/mod_printPDF_div.php
branches/print_dev/http/print/print_functions.php
branches/print_dev/http/print/testConfigTemplate.json
Log:
added simple mbMeasureDecorator
Modified: branches/print_dev/http/print/classes/mbMapDecorator.php
===================================================================
--- branches/print_dev/http/print/classes/mbMapDecorator.php 2009-02-18 08:52:26 UTC (rev 3566)
+++ branches/print_dev/http/print/classes/mbMapDecorator.php 2009-02-18 16:02:42 UTC (rev 3567)
@@ -53,7 +53,8 @@
$res = $this->pdf->objPdf->k * ($this->res_dpi/72);
$myURL = new stripRequest($array_urls[0]);
$e = new mb_notice("mbMapDecorator: original bbox: ".$myURL->get('BBOX'));
- $this->pdf->setMapExtent($this->adjustBbox(explode(",",$myURL->get('BBOX')), $myURL->get('srs')));
+ #$this->pdf->setMapExtent($this->adjustBbox(explode(",",$myURL->get('BBOX')), $myURL->get('srs')));
+ $this->pdf->setMapInfo($this->conf->x_ul, $this->conf->y_ul, $width, $height, $this->adjustBbox(explode(",",$myURL->get('BBOX')), $myURL->get('srs')));
$e = new mb_notice("mbMapDecorator: adjusted bbox: ".$this->pdf->getMapExtent());
for($i=0; $i<count($array_urls); $i++){
$m = new stripRequest($array_urls[$i]);
Added: branches/print_dev/http/print/classes/mbMeasureDecorator.php
===================================================================
--- branches/print_dev/http/print/classes/mbMeasureDecorator.php (rev 0)
+++ branches/print_dev/http/print/classes/mbMeasureDecorator.php 2009-02-18 16:02:42 UTC (rev 3567)
@@ -0,0 +1,79 @@
+<?php
+class mbMeasureDecorator extends mbTemplatePdfDecorator {
+
+ protected $pageElementType = "measure";
+ protected $elementId;
+
+ public function __construct($pdfObj, $elementId, $mapConf, $controls) {
+ parent::__construct($pdfObj, $mapConf, $controls);
+ $this->elementId = $elementId;
+ $this->override();
+ $this->decorate();
+ }
+
+ public function override() {}
+
+ public function decorate() {
+ include (dirname(__FILE__)."/../print_functions.php");
+
+ global $mapOffset_left, $mapOffset_bottom, $map_height, $map_width, $coord;
+ global $yAxisOrientation;
+ $yAxisOrientation = 1;
+
+ if (isset($_REQUEST["measured_x_values"]) && $_REQUEST["measured_x_values"] != "") {
+ $x_value_str = $_REQUEST["measured_x_values"];
+ $y_value_str = $_REQUEST["measured_y_values"];
+ $e = new mb_notice("mbMeasureDecorator: x values: ".$x_value_str);
+ $e = new mb_notice("mbMeasureDecorator: y values: ".$y_value_str);
+ }
+ else {
+ return "No measurements found.";
+ }
+
+ $coord = mb_split(",",$this->pdf->getMapExtent());
+ $mapInfo = $this->pdf->getMapInfo();
+ foreach ($mapInfo as $k => $v) {
+ $e = new mb_notice("mbMeasureDecorator: mapInfo: ".$k."=".$v);
+ }
+ $mapOffset_left = $mapInfo["x_ul"];
+ $mapOffset_bottom = $mapInfo["y_ul"];
+ $map_height = $mapInfo["height"];
+ $map_width = $mapInfo["width"];
+
+ // get the arrays, be aware of the different y-axis values
+ $theFullArr = makeCoordPairs($x_value_str, $y_value_str);
+ foreach ($theFullArr as $oneFullArr) {
+ $e = new mb_notice("mbMeasureDecorator: coordinates: ".implode(" ",array_values($oneFullArr)));
+ }
+ $thePolyArr = makePolyFromCoord($theFullArr);
+ $e = new mb_notice("mbMeasureDecorator: coordinates: ".implode(" ",$thePolyArr));
+
+ if (isClosedPolygon($theFullArr)) {
+ $isClosed = TRUE;
+ }
+ else {
+ $isClosed = FALSE;
+ }
+ $nr_of_points = count($theFullArr);
+ $e = new mb_notice("mbMeasureDecorator: closed polygon: ".$isClosed);
+
+ if ($isClosed) {
+ $this->pdf->objPdf->Polygon($thePolyArr);
+ }
+ else {
+ $theStrokePointPairs = makeStrokePointPairs($theFullArr);
+ for($i = 0; $i < count($theStrokePointPairs); $i++) {
+ $line = $theStrokePointPairs[$i];
+ $e = new mb_notice("mbMeasureDecorator: line coordinates: ".implode(" ",$line));
+ if ($i != count($theStrokePointPairs) - 1) {
+ $this->pdf->objPdf->Line($line[0], $line[1], $line[2], $line[3]);
+ }
+ }
+ }
+
+ }
+
+
+}
+
+?>
\ No newline at end of file
Modified: branches/print_dev/http/print/classes/mbTemplatePdf.php
===================================================================
--- branches/print_dev/http/print/classes/mbTemplatePdf.php 2009-02-18 08:52:26 UTC (rev 3566)
+++ branches/print_dev/http/print/classes/mbTemplatePdf.php 2009-02-18 16:02:42 UTC (rev 3567)
@@ -5,7 +5,7 @@
class mbTemplatePdf extends mbPdf {
/* it seems several decorators are going to need this information */
- public $mapExtent;
+ public $mapInfo = array();
public function __construct($jsonConf) {
$this->confPdf = $jsonConf;
@@ -18,14 +18,28 @@
$this->outputFileName = $this->generateOutputFileName("map","pdf");
}
+ public function setMapInfo($x_ul, $y_ul, $width, $height, $aBboxString) {
+ $this->mapinfo["x_ul"] = $x_ul;
+ $this->mapinfo["y_ul"] = $y_ul;
+ $this->mapinfo["width"] = $width;
+ $this->mapinfo["height"] = $height;
+ $this->mapinfo["extent"] = $aBboxString;
+ $e = new mb_notice("mbTemplatePdf: setting mapInfo ...");
+ }
+
+ public function getMapInfo() {
+ $e = new mb_notice("mbTemplatePdf: getting mapInfo ..");
+ return $this->mapinfo;
+ }
+
public function setMapExtent($aBboxString) {
- $this->mapExtent = $aBboxString;
- $e = new mb_notice("mbTemplatePdf: setting mapExtent to ".$this->mapExtent);
+ $this->mapinfo["extent"] = $aBboxString;
+ $e = new mb_notice("mbTemplatePdf: setting mapExtent to ".$this->mapinfo["extent"]);
}
-
+
public function getMapExtent() {
- $e = new mb_notice("mbTemplatePdf: getting mapExtent as ".$this->mapExtent);
- return $this->mapExtent;
+ $e = new mb_notice("mbTemplatePdf: getting mapExtent as ".$this->mapinfo["extent"]);
+ return $this->mapinfo["extent"];
}
public function render() {
@@ -50,7 +64,10 @@
break;
case "para":
$err = new mbParagraphDecorator($this, $pageElementId, $pageElementConf, $controls);
- break;
+ break;
+ case "measure":
+ $err = new mbMeasureDecorator($this, $pageElementId, $pageElementConf, $controls);
+ break;
}
}
Modified: branches/print_dev/http/print/mod_printPDF_div.php
===================================================================
--- branches/print_dev/http/print/mod_printPDF_div.php 2009-02-18 08:52:26 UTC (rev 3566)
+++ branches/print_dev/http/print/mod_printPDF_div.php 2009-02-18 16:02:42 UTC (rev 3567)
@@ -62,6 +62,20 @@
}
/**
+ * update form values helper function
+ *
+ */
+function updateFormField(formData, key, value) {
+ for(var j=0; j < formData.length; j++){
+ if (formData[j].name == key) {
+ formData[j].value = value;
+ break;
+ }
+ }
+}
+
+
+/**
* Validates and updates form data values.
* Adds the elements before the submit button.
*
@@ -83,25 +97,35 @@
}
}
}
- for(var j=0; j < formData.length; j++){
- if (formData[j].name == "map_url") {
- formData[j].value = f.map_url.value;
- break;
- }
- }
+ updateFormField(formData, "map_url", f.map_url.value);
//overview_url
var ind_overview = getMapObjIndexByName('overview');
+ if(mb_mapObj[ind_overview].mapURL != false ){
+ updateFormField(formData, "overview_url", mb_mapObj[ind_overview].mapURL);
+ }
- if(mb_mapObj[ind_overview].mapURL != false ){
- for(var j=0; j < formData.length; j++){
- if (formData[j].name == "overview_url") {
- formData[j].value = mb_mapObj[ind_overview].mapURL;
- break;
+ // write the measured coordinates
+ if (mod_measure_RX != undefined && mod_measure_RY != undefined) {
+ var tmp_x = '';
+ var tmp_y = '';
+ for(i = 0; i < mod_measure_RX.length; i++) {
+ if(tmp_x != '') {
+ tmp_x += ','
}
+ tmp_x += mod_measure_RX[i];
}
- }
+ for(i = 0; i < mod_measure_RY.length; i++) {
+ if(tmp_y != '') {
+ tmp_y += ','
+ }
+ tmp_y += mod_measure_RY[i];
+ }
+ updateFormField(formData, "measured_x_values", tmp_x);
+ updateFormField(formData, "measured_y_values", tmp_y);
+ }
+
if (f.map_url.value!="") {
return true;
} else {
Modified: branches/print_dev/http/print/print_functions.php
===================================================================
--- branches/print_dev/http/print/print_functions.php 2009-02-18 08:52:26 UTC (rev 3566)
+++ branches/print_dev/http/print/print_functions.php 2009-02-18 16:02:42 UTC (rev 3567)
@@ -61,6 +61,7 @@
*/
function transformForPDF ($theRealCoord, $theType) {
global $mapOffset_left, $mapOffset_bottom, $map_height, $map_width, $coord;
+ global $yAxisOrientation;
$thePDFvalue = "";
@@ -77,7 +78,10 @@
$real_shown_height = $coord[3] - $coord[1];
$ratio_to_display = $map_height / $real_shown_height;
$target_height = $theRealCoord - $coord[1];
- $thePDFvalue = $mapOffset_bottom + ($target_height * $ratio_to_display);
+ if (isset($yAxisOrientation) && $yAxisOrientation==1)
+ $thePDFvalue = $map_height + $mapOffset_bottom - ($target_height * $ratio_to_display);
+ else
+ $thePDFvalue = $mapOffset_bottom + ($target_height * $ratio_to_display);
break;
default:
// a non valid parameter was given
Modified: branches/print_dev/http/print/testConfigTemplate.json
===================================================================
--- branches/print_dev/http/print/testConfigTemplate.json 2009-02-18 08:52:26 UTC (rev 3566)
+++ branches/print_dev/http/print/testConfigTemplate.json 2009-02-18 16:02:42 UTC (rev 3567)
@@ -57,6 +57,9 @@
"width" : 280,
"height" : 185
},
+ "messung" : {
+ "type" : "measure"
+ },
"minikarte" : {
"type" : "overview",
"res_dpi" : 72,
More information about the Mapbender_commits
mailing list