[pmapper-users] Highlight complex features
Brought to you by:
arminburger
From: Alessandro P. <al...@ti...> - 2006-12-05 09:03:15
|
Hello, sorry for the long post. I'm using pmapper 3. I have a layer which is a result of a M2M relationship, this means that a single feature is a result of multiple segments, and the id of the feature is unique while the id of single segments can be shared among several features. Everything works fine (more or less) but I found (a bug?) that highlight shows only the last segment of the result set. To make it work I had to change the initmap.php so that instead of the last segment, *all* the single segments are added to the session highlight var (see "ABP:" comments in the code). Basically, the for loop checks all results but only the id of the last is stored in the session variable (which is an array anyway). Should I file a bug for this or is it intentional ? /** * FUNCTION TO RETURN URL FOR MAPFRAME * used for starting application with pre-defined extent * extent read from shape features */ function getMapInitURL($map, $zoomLayer, $zoomQuery) { $qLayer = $this->map->getLayerByName($zoomLayer); // Query parameters $queryList = split('@', $zoomQuery); $queryField = $queryList[0]; $queryFieldType = $queryList[1]; //$queryValue = "/^" . $queryList[2] ."$/"; $queryValue = $queryList[2]; $highlFeature = $queryList[3]; $setMaxExtent = $queryList[4]; // Modify filter for PostGIS & Oracle layers if ($qLayer->connectiontype == 6 || $qLayer->connectiontype == 8) { $q = $queryFieldType == 1 ? "'" : ""; #$queryValue = "$queryField = $q$queryValue$q"; //error_log($queryValue); $queryValue = $queryField . ' ~* \'' . $queryValue .'\' '; } else { // Shapefile } // Query layer ABP: fix mapscript 410 // (this is not related with highlight) $qLayer->queryByAttributes($queryField, "\"$queryValue\"", MS_MULTIPLE); $numResults = $qLayer->getNumResults(); $qLayer->open(); // Return query results (SINGLE FEATURE): shape index and feature extent /* $qRes = $qLayer->getResult(0); $qShape = $qLayer->getShape($qRes->tileindex,$qRes->shapeindex); $qShpIdx = $qShape->index; $qShpBounds = $qShape->bounds; */ // Check if layer has different projection than map // if yes, re-project extent from layer to map projection $mapProjStr = $this->map->getProjection(); $qLayerProjStr = $qLayer->getProjection(); if ($mapProjStr && $qLayerProjStr && $mapProjStr != $qLayerProjStr) { $mapProjObj = ms_newprojectionobj($mapProjStr); $qLayerProjObj = ms_newprojectionobj($qLayerProjStr); //$qShpBounds->project($this->qLayerProjObj, $this->mapProjObj); $reprojectShape = 1; } // initial max/min values $mExtMinx = 999999999; $mExtMiny = 999999999; $mExtMaxx = -999999999; $mExtMaxy = -999999999; // ABP: Store all shape indexes $qShpIdxArray = array(); // Return query results: shape index and feature extent for ($iRes=0; $iRes < $numResults; $iRes++) { $qRes = $qLayer->getResult($iRes); $qShape = $qLayer->getShape($qRes->tileindex,$qRes->shapeindex); $qShpIdx = $qShape->index; // ABP: Store all segments $qShpIdxArray[] = $qShpIdx; $qShpBounds = $qShape->bounds; if ($reprojectShape) { $qShpBounds->project($qLayerProjObj, $mapProjObj); } $shpMinx = $qShpBounds->minx; $shpMiny = $qShpBounds->miny; $shpMaxx = $qShpBounds->maxx; $shpMaxy = $qShpBounds->maxy; // Get max/min values of ALL features $mExtMinx = min($mExtMinx, $shpMinx); $mExtMiny = min($mExtMiny, $shpMiny); $mExtMaxx = max($mExtMaxx, $shpMaxx); $mExtMaxy = max($mExtMaxy, $shpMaxy); } //die(); // Apply buffer (in units of features) //$buffer = 20000; // <<<<<<<<<<<<<<<<<<<<<< ADAPT VALUE <<<<<<<<<<<<<<<<< // ABP: set buffer for points // (this is not related with highlight) if ($this->qLayerType == 0) { $buffer = $_SESSION["pointBuffer"]; } else { $buffer = 0.05 * ((($mExtMaxx - $mExtMinx) + ($mExtMaxy - $mExtMiny)) / 2); } // Set buffer for point layers $mExtMinx -= $buffer; $mExtMiny -= $buffer; $mExtMaxx += $buffer; $mExtMaxy += $buffer; $roundFact = ($map->units != 5 ? 0 : 6); $shpMinx = round($mExtMinx, $roundFact); $shpMiny = round($mExtMiny, $roundFact); $shpMaxx = round($mExtMaxx, $roundFact); $shpMaxy = round($mExtMaxy, $roundFact); $ext = array ($shpMinx, $shpMiny, $shpMaxx, $shpMaxy); $_SESSION['zoom_extparams'] = $ext; // Set Max Extent for map if ($setMaxExtent) { $mapMaxExt['minx'] = $shpMinx; $mapMaxExt['miny'] = $shpMiny; $mapMaxExt['maxx'] = $shpMaxx; $mapMaxExt['maxy'] = $shpMaxy; $_SESSION['mapMaxExt'] = $mapMaxExt; } // Add highlight feature if defined in URL parameters if ($highlFeature) { // ABP: add all shapes // $resultlayers[$zoomLayer] = array($qShpIdx); $resultlayers[$zoomLayer] = $qShpIdxArray; $_SESSION["resultlayers"] = $resultlayers; } // Return URL $searchString = "&mode=map&zoom_type=zoomextent&extent=" . $shpMinx ."+". $shpMiny ."+". $shpMaxx ."+". $shpMaxy . ($highlFeature ? "&resultlayer=$zoomLayer+$qShpIdx" : ""); $mapInitURL = "map.phtml?$searchString"; return $mapInitURL; } -- Alessandro Pasotti itOpen - "Open Solutions for the Net Age" w3: www.itopen.it Linux User# 167502 |