Hallo! Some time ago I told you that we made some small enhancements to p.mapper and wanted to contribute them to the main source.
Finally I found the time to download the actual p.mapper and try to apply our patches to it (the patches where made from 1.9.1). Most of our patches are not working any more and so little important or so special that I don't think, it is worth to upgrade them to 1.9.5. The still remaining patches are coming with this email: * pmapper-1.9.5-scale.diff: - adaption of minscale and maxscale: p.mapper shows everything in ]maxscale,minscale[ while UMN MapServer works with [maxscale,minscale]. P.mapper has been adapted to UMN MapServer. The problem is visible in the legend where a layer can be grayed even if it is still visible. * pmapper-1.9.5-i18n.diff, de.po - i18n support. The patch is not working completely mainly because the p.mapper.mo is somewhat outdated. I had no time to adapt it fully but thought it could be useful to send it to give an idea how i18n can be included. de.po can be translated into a .mo file by: msgfmt --statistics -o p.mapper.mo de.po p.mapper.mo should be located at incphp/locale/de/LC_MESSAGES/p.mapper.mo to be found by p.mapper * pmapper-1.9.5-vertical.diff: - adding vertical tabular to show results of a layer. This is useful if you many attributes in a tabular but only few results. This patch as well is not working fully because the way, info results are shown has changed a lot (especially by the possibility to sort the attributes). Again I had not time to do the full work but thought someone could be inspirated by this code (otherwise throw it away ;-) Please contact me with any questions, problems etc. Greetings, Silke -- Silke Reimer : www.intevation.de/~silke | GISpatcher: www.gispatcher.de Intevation GmbH: www.intevation.de | Thuban : thuban.intevation.org Georgstr.4 : 49074 Osnabr?ck | FreeGIS : www.freegis.org -------------- next part -------------- diff -ur pmapper/incphp/common.php gwmessnetz/incphp/common.php --- pmapper/incphp/common.php Sun Jun 5 13:26:06 2005 +++ gwmessnetz/incphp/common.php Wed Sep 28 15:01:36 2005 @@ -145,9 +163,9 @@ { if ($qLayer->maxscale == -1 && $qLayer->minscale == -1) { return 1; - } elseif ($scale >= $qLayer->maxscale AND $qLayer->maxscale != -1) { + } elseif ($scale > $qLayer->maxscale AND $qLayer->maxscale != -1) { return 0; - } elseif ($scale <= $qLayer->minscale AND $qLayer->minscale != -1) { + } elseif ($scale < $qLayer->minscale AND $qLayer->minscale != -1) { return 0; } else { return 1; -------------- next part -------------- diff -ur pmapper/incphp/common.php gwmessnetz/incphp/common.php --- pmapper/incphp/common.php Sun Jun 5 13:26:06 2005 +++ gwmessnetz/incphp/common.php Wed Sep 28 15:01:36 2005 @@ -29,16 +29,34 @@ // USING PHP ARRAYS -function _($string) +//function _($string) +//{ +// global $_sl; +// if (isset($_sl[$string])) { +// return $_sl[$string]; +// } else { +// return $string; +// } +//} + +// GNU gettext ... +$PACKAGE="p.mapper"; +$baseDir = $_SESSION["baseDir"]; +$LOCALEDIR=$baseDir."/incphp/locale"; + +switch ($_SESSION["gLanguage"]) { - global $_sl; - if (isset($_sl[$string])) { - return $_sl[$string]; - } else { - return $string; - } + case 1: + $lc = "de_DE"; + break; + default: + $lc = "en"; } +setlocale (LC_MESSAGES, $lc); +bindtextdomain ($PACKAGE, $LOCALEDIR); +textdomain ($PACKAGE); + // USING SQLite DB // Load SQLite extension diff -ur pmapper/incphp/globals.php gwmessnetz/incphp/globals.php --- pmapper/incphp/globals.php Sun Jun 5 13:30:46 2005 +++ gwmessnetz/incphp/globals.php Wed Sep 28 15:12:09 2005 @@ -34,3 +34,3 @@ $gLanguage = $_SESSION["gLanguage"]; -require_once("locale/language_" . $gLanguage . ".php"); +//require_once("locale/language_" . $gLanguage . ".php"); -------------- next part -------------- # German Translation for p.mapper. # Copyright (C) 2005 Armin Burger # This file is distributed under the same license as the p.mapper package. # msgid "" msgstr "" "Project-Id-Version: p.mapper 1.9.3\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=ISO-8859-1\n" "Content-Transfer-Encoding: 8bit\n" # STRINGS FOR NAVIGATION TOOLS AND BUTTONS msgid "Navigation" msgstr "Navigation" msgid "Scale" msgstr "Ma?stab" msgid "Zoom" msgstr "Zoom" msgid "On map click" msgstr "Bei Klick in die Karte" msgid "Zoom in" msgstr "Hineinzoomen" msgid "Zoom out" msgstr "Herauszoomen" msgid "Pan" msgstr "Verschieben" msgid "Recenter" msgstr "Zentrieren" msgid "Select" msgstr "Selektieren" msgid "Identify" msgstr "Information" msgid "Measure" msgstr "Messen" msgid "Refresh Map" msgstr "Karte aktualisieren" msgid "Zoom To Full Extent" msgstr "Übersicht" msgid "Back" msgstr "Zurück" msgid "Forward" msgstr "Vorwärts" msgid "Search" msgstr "Suche" msgid "Print Map" msgstr "Karte drucken" msgid "Hide Legend" msgstr "Legende ausblenden" msgid "Layer" msgstr "Layer" msgid "Legend" msgstr "Legende" msgid "Help" msgstr "Hilfe" msgid "Total" msgstr "Gesamt [km]" msgid "Segment" msgstr "Segment [km]" msgid "Area" msgstr "Fläche [km²|ha]" msgid "Clear" msgstr "Löschen" msgid "Show Layer List" msgstr "Layeransicht einschalten" msgid "Show Legend" msgstr "Legende anzeigen" # STRINGS FOR PRINT DIALOG AND PRINT MAP msgid "Print Settings" msgstr "Druck-Einstellungen" msgid "Set Scale" msgstr "Ma?stab wählen" msgid "Print Format" msgstr "Druckformat" msgid "Orientation" msgstr "Seitenausrichtung" msgid "Portrait" msgstr "Hochformat" msgid "Landscape" msgstr "Querformat" msgid "Create Print Page" msgstr "Seite für den Druck erstellen" msgid "Create PDF Document" msgstr "PDF Dokument erzeugen" msgid "Print Title" msgstr "Drucktitel" msgid "Print View" msgstr "Druckansicht" msgid "Map Resolution for Download" msgstr "Kartenauflösung für das Speichern" msgid "Download" msgstr "Bildansicht speichern" # STRINGS FOR IDENTIFY/SEARCH msgid "No records found" msgstr "Keine Einträge gefunden" msgid "Query Results" msgstr "Abfrageergebnisse" msgid "Zoom to All Features Found" msgstr "Zoom auf alle gefundenen Elemente" msgid "Zoom to Selected Features" msgstr "Zoom auf alle selektierten Elemente" msgid "Select/Search limit of" msgstr "Selektions-/Such-Limit von" msgid "records exceeded" msgstr " Einträgen überschritten. Weitere Einträge wurden nicht dargestellt." msgid "Search results for layer" msgstr "Suchergebnisse für Layer " # -> search combo box msgid "Search for" msgstr "Suche nach..." msgid "Place" msgstr "Ortschaft" msgid "Street" msgstr "Strasse" msgid "Run Search" msgstr "Suche starten" msgid "Selection for Layer" msgstr "Selektieren für Layer" msgid "All visible Layers" msgstr "Sichtbare Layer" # Coordinates Dialog msgid "Coordinates" msgstr "Koordinaten" msgid "Map Coordinates" msgstr "Karten-Koordinaten" -------------- next part -------------- diff -ur pmapper/incphp/group.php gwmessnetz/incphp/group.php --- pmapper/incphp/group.php Thu Nov 4 21:39:48 2004 +++ gwmessnetz/incphp/group.php Mon Sep 26 19:20:01 2005 @@ -141,6 +151,10 @@ $this->skipLegend = $skipLegend; } + function setOrientation($orientation) + { + $this->orientation = $orientation; + } //*** GLOBAL RETURN FUNCTIONS ***// @@ -198,6 +212,11 @@ function getSkipLegend() { return $this->skipLegend; + } + + function getOrientation() + { + return $this->orientation; } } diff -ur pmapper/incphp/initgroups.php gwmessnetz/incphp/initgroups.php --- pmapper/incphp/initgroups.php Tue Jun 7 20:43:34 2005 +++ gwmessnetz/incphp/initgroups.php Mon Sep 26 19:20:33 2005 @@ -154,6 +154,10 @@ $skipLegend = ($skipLegend == "" ? 0 : $skipLegend); $glayer->setSkipLegend($skipLegend); + // Check for Orientation + $orientation = returnMetaData($mapLay, "ORIENTATION"); + $orientation = ($orientation == "" ? "horizontal" : strtolower($orientation)); + $glayer->setOrientation($orientation); // now add layer to group $group->addLayer($glayer); diff -ur pmapper/incphp/query/query.php gwmessnetz/incphp/query/query.php --- pmapper/incphp/query/query.php Mon Jun 6 20:58:28 2005 +++ gwmessnetz/incphp/query/query.php Wed Sep 28 17:59:23 2005 @@ -319,7 +316,11 @@ { if ($this->qLayer->getNumResults() > 0) { - $this->query = &new DQuery($this->map, $this->qLayer, $this->glayer, $this->zoomFull); + $orientation = $this->glayer->orientation; + if ($orientation == 'horizontal') + $this->query = &new DQuery($this->map, $this->qLayer, $this->glayer, $this->zoomFull); + else + $this->query = &new VQuery($this->map, $this->qLayer, $this->glayer, $this->zoomFull, $this->selHeaders); // For Select function (nquery): get indexes of result shapes and max extent of all shapes if ($this->mode == "nquery") { diff -ur pmapper/incphp/query/squery.php gwmessnetz/incphp/query/squery.php --- pmapper/incphp/query/squery.php Sat Jun 4 23:21:10 2005 +++ gwmessnetz/incphp/query/squery.php Sun Sep 4 21:50:27 2005 @@ -628,8 +628,321 @@ } //END CLASS PGQUERY +class VQuery extends Query +{ + function VQuery($map, $qLayer, $glayer, $zoomFull, $selHeaders) + { + //$this->QUERY($map); + $this->map = $map; + $this->qLayer = $qLayer; + $this->qLayerName = $this->qLayer->name; + $this->qLayerType = $this->qLayer->type; + $this->glayer = $glayer; + $this->selHeaders = $selHeaders; + $this->selFields = $glayer->getResFields(); + $this->zoomFull = $zoomFull; + $this->infoWin = $_SESSION["infoWin"]; + + $this->limitResult = $_SESSION["limitResult"]; + + // dump results to resultString + $this->dumpQueryResults(); + } + + + function getResultString() + { + return $this->qStr; + } + + + // Get the number of results for query on the layer + function setNumResults() + { + $this->qLayer->open(); + $this->numResults = $this->qLayer->getNumResults(); + // Apply limit for query results + if ($this->numResults > $this->limitResult) $this->numResults = $this->limitResult; + } -?> \ No newline at end of file + + /* + * DUMP QUERY RESULTS INTO QUERY STRING $qStr + *******************************************************/ + function dumpQueryResults() + { + if ($this->zoomFull) { + // Maximum extents + $this->mExtMinx = 999999999; + $this->mExtMiny = 999999999; + $this->mExtMaxx = -999999999; + $this->mExtMaxy = -999999999; + } + + $this->returnTableJoinProperties(); + + $this->setNumResults(); + for ($iField=0; $iField < count($this->selFields); $iField++) { + $this->qStr .= $this->printResultRow($iField); + } + for ($iRes=0; $iRes < $this->numResults; $iRes++) { + $qRes = $this->qLayer->getResult($iRes); + $qShape = $this->qLayer->getShape($qRes->tileindex,$qRes->shapeindex); + $this->printShapeField($qShape); + } + } + + + function printResultRow($iField) + { + $fldName = $this->selFields[$iField]; + $this->qStr .= "<tr><td><strong>".$this->selHeaders[$iField]."</strong></td>"; + for ($iRes=0; $iRes < $this->numResults; $iRes++) { + $qRes = $this->qLayer->getResult($iRes); + $qShape = $this->qLayer->getShape($qRes->tileindex,$qRes->shapeindex); + $fldValue = $qShape->values[$fldName]; + $this->qStr .= "<td>"; + $this->qStr .= $fldValue; + $this->qStr .= "</td>\n"; + $this->resultindexes[] = $qRes->shapeindex; + $this->resulttileindexes[$qRes->shapeindex] = $qRes->tileindex; + } + $this->qStr .= "</tr>\n"; + } + + + + /* + * Print SHAPEINDEX COLUMN as HTML hyperlink (for zoom-to-feature link) + *************************************************************************/ + function printShapeField($qShape) + { + // Add LINK with shape extent and javascript zoom function as new column // + $layerType = $this->qLayer->type; + $qShpIdx = $qShape->index; + $qShpBounds = $qShape->bounds; + $changeLayProj = $this->checkProjection(); + + //$this->resultindexes[] = $qShpIdx; + + // Change PROJECTION to map projection if necessary + if ($changeLayProj) { + if ($layerType == 0) { + // Apply buffer in order to have a correct re-projection of POINT layers + $pjbuff = 0.0000001; + $sMinx = $qShpBounds->minx - $pjbuff; + $sMiny = $qShpBounds->miny - $pjbuff; + $sMaxx = $qShpBounds->maxx + $pjbuff; + $sMaxy = $qShpBounds->maxy + $pjbuff; + + $qShpBounds = ms_newRectObj(); + $qShpBounds->set("minx", $sMinx); + $qShpBounds->set("miny", $sMiny); + $qShpBounds->set("maxx", $sMaxx); + $qShpBounds->set("maxy", $sMaxy); + } + + $qShpBounds->project($this->qLayerProjObj, $this->mapProjObj); + } + + //Get MIN/MAX values for shape extent rectangle + $shpMinx = $qShpBounds->minx; + $shpMiny = $qShpBounds->miny; + $shpMaxx = $qShpBounds->maxx; + $shpMaxy = $qShpBounds->maxy; + + + // Buffer for points: ADAPT BUFFER VALUE TO SCALE RANGE [ needs to be improved though ] + if ($layerType == 0) { + $buf = 0.01; // set buffer depending on dimensions of your coordinate system + $shpMinx = $shpMinx - (abs($buf * $shpMinx)); + $shpMiny = $shpMiny - (abs($buf * $shpMiny)); + $shpMaxx = $shpMaxx + (abs($buf * $shpMaxx)); + $shpMaxy = $shpMaxy + (abs($buf * $shpMaxy)); + } + + + // Get maximum extents if zoomAll or autoZoom is enabled + if ($this->zoomFull) { + $this->mExtMinx = min($this->mExtMinx, $shpMinx); + $this->mExtMiny = min($this->mExtMiny, $shpMiny); + $this->mExtMaxx = max($this->mExtMaxx, $shpMaxx); + $this->mExtMaxy = max($this->mExtMaxy, $shpMaxy); + } + // Define if for zoom2extent for select and search the single click should change highlight + $jsLink = "zoom2extent(" . ($this->zoomFull ? "0, 0" : "'" . $this->qLayerName ."',".$qShpIdx) .",'". $shpMinx ."+". $shpMiny ."+". $shpMaxx ."+". $shpMaxy ."')"; + $qShpLink = "<td><a href=\"javascript:" . ($this->infoWin == "frame" ? "" : "opener.") . $jsLink . "\"><img src=\"images/zoomto.gif\" border=\"0\"></a></td>"; + + return $qShpLink; + } + + + + + + /* + * Print results for rest of fields (all but shape) + *************************************************/ + function printFields($qShape) + { + + // PRINT RESULT ROW + $loop = 2; // Used for one-to-many joins to break while loop when all DB data printed + $dbloop = 0; // Used for one-to-many joins as index to step through join table + + while($loop > 0) { + + ##$this->qStr .= "pippo anzahl felder:" . sizeof($this->selFields); + // Add shape index to array, used for highlight + //$resultindexes[] = $qShpIdx; + + // Print all OTHER COLUMNS from SHAPE + for ($iField=0; $iField < sizeof($this->selFields); $iField++) { + $fldName = $this->selFields[$iField]; + $fldValue = $qShape->values[$fldName]; + //$this->qStr .= $fldValue; + + $this->qStr .= $this->printFieldValues($fldName, $fldValue); + } + + ##print_r($this->joinList); + // Now add JOIN COLUMNS from DB if defined + if ($this->joinList && $this->dbh) { + $toValue = $qShape->values[$this->toField]; + $joinFieldList = split(',', $this->joinFields); + //echo $this->sql; + // get data only once from DB + if ($dbloop == 0) { + $data = $this->returnData($this->dbh, $this->sql, $toValue, $this->fromFieldType, $this->one2many); + $dbresCount = count($data); + } + + //print_r($data); + //exit; + // + if ($dbresCount > 0) { + $jfldi = 0; + foreach($data[$dbloop] as $val) { + $fldName = trim($joinFieldList[$jfldi]); + $jfldi++; + $this->qStr .= $this->printFieldValues($fldName, $val); + } + $dbloop++; + + // if NO one2many set $dbloop to end value and stop after first record + if (!$one2many) { + $dbloop = $dbresCount; + } + + // if all recors from one2many retrieved (or only one2one) stop loop + if ($dbloop == $dbresCount) $loop = 0; + } else { + $loop = 0; + } + + // NO JOIN field defined, so break while loop and continue with next record + } else { + $loop = 0; + } + + } + + } + + + + /* + * Test if layer has the same projection as map + ***************************************************/ + function checkProjection() + { + $mapProjStr = $this->map->getProjection(); + $qLayerProjStr = $this->qLayer->getProjection(); + + if ($mapProjStr && $qLayerProjStr && $mapProjStr != $qLayerProjStr) { + $this->changeLayProj = 1; + $this->mapProjObj = ms_newprojectionobj($mapProjStr); + $this->qLayerProjObj = ms_newprojectionobj($qLayerProjStr); + //echo "pippo"; + } else { + $this->changeLayProj = 0; + } + return $this->changeLayProj; + } + + + + + + /* + * FUNCTIONS FOR JOINING DB TABLES TO QUERY RESULT + ************************************************************/ + + // Get properties for DB table join + function returnTableJoinProperties() + { + if ($this->glayer->getTableJoin()) { + //$dsn, $fromTable, $fromField, $fromFieldType, $joinFields, $toField, $one2many + require_once ("DB.php"); + $joinList = $this->glayer->getTableJoin(); + + // Join table properties + $fromTable = $joinList["fromTable"]; + $fromField = $joinList["fromField"]; + $this->fromFieldType = $joinList["fromFieldType"]; + $this->joinFields = $joinList["joinFields"]; + + // Layer field to join TO + $this->toField = $joinList["toField"]; + + // Join type: one-to-one (0) or one-to-many (1) + $this->one2many = $joinList["one2many"]; + + // Connnect to DB + $dsn = $joinList["dsn"]; + $dbh = $this->dbConnect($dsn); + + if (!$dbh) error_log ("Could not connect to DB defined for Layer '" + . $this->glayer->getLayerName() . "'. Check map file entry for JOIN definition.", 0); + } + + $this->sql = "SELECT " . $this->joinFields . " FROM $fromTable WHERE $fromField="; + $this->dbh = $dbh; + + $this->joinList = $joinList; + } + + + + // Get data from DB + function returnData($dbh, $sql, $toValue, $fromFieldType) + { + $quote = ($fromFieldType == "1" ? "'" : ""); + $sqlRun = $sql.$quote.$toValue.$quote; + #echo $sqlRun; + $data = $dbh->getAll($sqlRun); // For 1:n Joins + #$data = $dbh->getRow($sqlRun); + return $data; + } + + function getFieldHeaderStr($selHeaders) { + + $pStr = '<td></td>'; + for ($iRes=0; $iRes < $this->numResults; $iRes++) { + $qRes = $this->qLayer->getResult($iRes); + $qShape = $this->qLayer->getShape($qRes->tileindex,$qRes->shapeindex); + $pStr .= ($this->qLayerType != 3 ? $this->printShapeField($qShape) : "<td></td>"); + } + return $pStr; + } + + +} // end CLASS VQUERY + + + + +?> -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Digital signature Url : http://faunalia.it/pipermail/pmapper-users/attachments/20060306/fc826fa6/attachment.pgp