Re: [pmapper-users] Highlight complex features
Brought to you by:
arminburger
From: Armin B. <arm...@gm...> - 2006-12-05 12:47:42
|
I probably forgot to add all indexes into an array when modifying the code to cover the extent of all features with the same search id. I'll put it in the svn. thanks armin PS: with regard to bug reports: please try to use the ticket system at http://svn.pmapper.net/trac/report instead of the tracking system of Sourceforge that drives me crazy when using it. You will have to create an account and log in in order to see the 'Create Ticket' link. If this works fine as expected I will again disable the SF trackers. armin -------- Original-Nachricht -------- Datum: Tue, 5 Dec 2006 10:11:44 +0100 Von: Alessandro Pasotti <al...@ti...> An: pma...@li... Betreff: [pmapper-users] Highlight complex features > 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 > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share > your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > pmapper-users mailing list > pma...@li... > https://lists.sourceforge.net/lists/listinfo/pmapper-users -- Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer |