From acb6656961eb5191e7e3f8cd3ea09638f5d5f3ec Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sat, 6 Aug 2011 10:59:06 +0530 Subject: [PATCH] Labels for each part in the geometry is not a good idea --- libraries/gis/pma_gis_multilinestring.php | 8 +++++-- libraries/gis/pma_gis_multipoint.php | 24 +++++++++++-------- libraries/gis/pma_gis_multipolygon.php | 29 ++++++++++++++++------- 3 files changed, 41 insertions(+), 20 deletions(-) diff --git a/libraries/gis/pma_gis_multilinestring.php b/libraries/gis/pma_gis_multilinestring.php index 32a89403fd..f518869543 100644 --- a/libraries/gis/pma_gis_multilinestring.php +++ b/libraries/gis/pma_gis_multilinestring.php @@ -79,6 +79,7 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry // Seperate each linestring $linestirngs = explode("),(", $multilinestirng); + $first_line = true; foreach ($linestirngs as $linestring) { $points_arr = $this->extractPoints($linestring, $scale_data); foreach ($points_arr as $point) { @@ -92,9 +93,10 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry } unset($temp_point); // print label if applicable - if (isset($label) && trim($label) != '') { + if (isset($label) && trim($label) != '' && $first_line) { imagestring($image, 2, $points_arr[1][0], $points_arr[1][1], trim($label), $black); } + $first_line = false; } return $image; } @@ -123,6 +125,7 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry // Seperate each linestring $linestirngs = explode("),(", $multilinestirng); + $first_line = true; foreach ($linestirngs as $linestring) { $points_arr = $this->extractPoints($linestring, $scale_data); foreach ($points_arr as $point) { @@ -136,11 +139,12 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry } unset($temp_point); // print label - if (isset($label) && trim($label) != '') { + if (isset($label) && trim($label) != '' && $first_line) { $pdf->SetXY($points_arr[1][0], $points_arr[1][1]); $pdf->SetFontSize(7); $pdf->Cell(0, 0, trim($label)); } + $first_line = false; } return $pdf; } diff --git a/libraries/gis/pma_gis_multipoint.php b/libraries/gis/pma_gis_multipoint.php index 411d82ddde..7a8ecef858 100644 --- a/libraries/gis/pma_gis_multipoint.php +++ b/libraries/gis/pma_gis_multipoint.php @@ -73,12 +73,14 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry // draw a small circle to mark the point if ($point[0] != '' && $point[1] != '') { imagearc($image, $point[0], $point[1], 7, 7, 0, 360, $color); - // print label for each point - if (isset($label) && trim($label) != '') { - imagestring($image, 2, $point[0], $point[1], trim($label), $black); - } } } + // print label for each point + if ((isset($label) && trim($label) != '') + && ($points_arr[0][0] != '' && $points_arr[0][1] != '') + ) { + imagestring($image, 2, $points_arr[0][0], $points_arr[0][1], trim($label), $black); + } return $image; } @@ -109,14 +111,16 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry // draw a small circle to mark the point if ($point[0] != '' && $point[1] != '') { $pdf->Circle($point[0], $point[1], 2, 0, 360, 'D', $line); - // print label for each point - if (isset($label) && trim($label) != '') { - $pdf->SetXY($point[0], $point[1]); - $pdf->SetFontSize(7); - $pdf->Cell(0, 0, trim($label)); - } } } + // print label for each point + if ((isset($label) && trim($label) != '') + && ($points_arr[0][0] != '' && $points_arr[0][1] != '') + ) { + $pdf->SetXY($points_arr[0][0], $points_arr[0][1]); + $pdf->SetFontSize(7); + $pdf->Cell(0, 0, trim($label)); + } return $pdf; } diff --git a/libraries/gis/pma_gis_multipolygon.php b/libraries/gis/pma_gis_multipolygon.php index b0c5254df9..ef0fa4d938 100644 --- a/libraries/gis/pma_gis_multipolygon.php +++ b/libraries/gis/pma_gis_multipolygon.php @@ -93,6 +93,7 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry // Seperate each polygon $polygons = explode(")),((", $multipolygon); + $first_poly = true; foreach ($polygons as $polygon) { // If the polygon doesnt have an inner polygon if (strpos($polygon, "),(") === false) { @@ -113,10 +114,15 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry } // draw polygon imagefilledpolygon($image, $points_arr, sizeof($points_arr) / 2, $color); - // print label if applicable - if (isset($label) && trim($label) != '') { - imagestring($image, 2, $points_arr[2], $points_arr[3], trim($label), $black); + // mark label point if applicable + if (isset($label) && trim($label) != '' && $first_poly) { + $label_point = array($points_arr[2], $points_arr[3]); } + $first_poly = false; + } + // print label if applicable + if (isset($label_point)) { + imagestring($image, 2, $points_arr[2], $points_arr[3], trim($label), $black); } return $image; } @@ -145,6 +151,7 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry // Seperate each polygon $polygons = explode(")),((", $multipolygon); + $first_poly = true; foreach ($polygons as $polygon) { // If the polygon doesnt have an inner polygon if (strpos($polygon, "),(") === false) { @@ -166,12 +173,18 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry } // draw polygon $pdf->Polygon($points_arr, 'F*', array(), $color, true); - // print label if applicable - if (isset($label) && trim($label) != '') { - $pdf->SetXY($points_arr[2], $points_arr[3]); - $pdf->SetFontSize(7); - $pdf->Cell(0, 0, trim($label)); + // mark label point if applicable + if (isset($label) && trim($label) != '' && $first_poly) { + $label_point = array($points_arr[2], $points_arr[3]); } + $first_poly = false; + } + + // print label if applicable + if (isset($label_point)) { + $pdf->SetXY($label_point[0], $label_point[1]); + $pdf->SetFontSize(7); + $pdf->Cell(0, 0, trim($label)); } return $pdf; }