Resolves problems with point and multipoint visualizations due to the assumption of empty values as zeros
This commit is contained in:
parent
47fdfad336
commit
1f2ba4e9cc
@ -142,11 +142,16 @@ abstract class PMA_GIS_Geometry
|
||||
$cordinates = explode(" ", $point);
|
||||
|
||||
if ($scale_data != null) {
|
||||
$x = ($cordinates[0] - $scale_data['x']) * $scale_data['scale'];
|
||||
$y = $scale_data['height'] - ($cordinates[1] - $scale_data['y']) * $scale_data['scale'];
|
||||
if (trim($cordinates[0]) != '' && trim($cordinates[1]) != '') {
|
||||
$x = ($cordinates[0] - $scale_data['x']) * $scale_data['scale'];
|
||||
$y = $scale_data['height'] - ($cordinates[1] - $scale_data['y']) * $scale_data['scale'];
|
||||
} else {
|
||||
$x = '';
|
||||
$y = '';
|
||||
}
|
||||
} else {
|
||||
$x = $cordinates[0];
|
||||
$y = $cordinates[1];
|
||||
$x = trim($cordinates[0]);
|
||||
$y = trim($cordinates[1]);
|
||||
}
|
||||
|
||||
if (! $linear) {
|
||||
|
||||
@ -70,7 +70,9 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
|
||||
|
||||
foreach ($points_arr as $point) {
|
||||
// draw a small circle to mark the point
|
||||
imagearc($image, $point[0], $point[1], 7, 7, 0, 360, $color);
|
||||
if ($point[0] != '' && $point[1] != '') {
|
||||
imagearc($image, $point[0], $point[1], 7, 7, 0, 360, $color);
|
||||
}
|
||||
}
|
||||
return $image;
|
||||
}
|
||||
@ -100,7 +102,9 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
|
||||
|
||||
foreach ($points_arr as $point) {
|
||||
// draw a small circle to mark the point
|
||||
$pdf->Circle($point[0], $point[1], 2, 0, 360, 'D', $line);
|
||||
if ($point[0] != '' && $point[1] != '') {
|
||||
$pdf->Circle($point[0], $point[1], 2, 0, 360, 'D', $line);
|
||||
}
|
||||
}
|
||||
return $pdf;
|
||||
}
|
||||
@ -131,12 +135,14 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
|
||||
|
||||
$row = '';
|
||||
foreach ($points_arr as $point) {
|
||||
$row .= '<circle cx="' . $point[0] . '" cy="' . $point[1] . '" r="3"';
|
||||
$point_options['id'] = $label . rand();
|
||||
foreach ($point_options as $option => $val) {
|
||||
$row .= ' ' . $option . '="' . trim($val) . '"';
|
||||
if ($point[0] != '' && $point[1] != '') {
|
||||
$row .= '<circle cx="' . $point[0] . '" cy="' . $point[1] . '" r="3"';
|
||||
$point_options['id'] = $label . rand();
|
||||
foreach ($point_options as $option => $val) {
|
||||
$row .= ' ' . $option . '="' . trim($val) . '"';
|
||||
}
|
||||
$row .= '/>';
|
||||
}
|
||||
$row .= '/>';
|
||||
}
|
||||
|
||||
return $row;
|
||||
@ -176,11 +182,15 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
|
||||
|
||||
$row = 'new Array(';
|
||||
foreach ($points_arr as $point) {
|
||||
$row .= '(new OpenLayers.Geometry.Point(' . $point[0] . ', ' . $point[1]
|
||||
. ')).transform(new OpenLayers.Projection("EPSG:' . $srid
|
||||
. '"), map.getProjectionObject()), ';
|
||||
if ($point[0] != '' && $point[1] != '') {
|
||||
$row .= '(new OpenLayers.Geometry.Point(' . $point[0] . ', ' . $point[1]
|
||||
. ')).transform(new OpenLayers.Projection("EPSG:' . $srid
|
||||
. '"), map.getProjectionObject()), ';
|
||||
}
|
||||
}
|
||||
if (substr($row, strlen($row) - 2) == ', ') {
|
||||
$row = substr($row, 0, strlen($row) - 2);
|
||||
}
|
||||
$row = substr($row, 0, strlen($row) - 2);
|
||||
$row .= ')';
|
||||
|
||||
$result .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
|
||||
@ -194,7 +204,7 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
|
||||
*
|
||||
* @param array $gis_data GIS data
|
||||
* @param int $index Index into the parameter object
|
||||
* @param string $empty Value for empty points
|
||||
* @param string $empty Multipoint does not adhere to this
|
||||
*
|
||||
* @return WKT with the set of parameters passed by the GIS editor
|
||||
*/
|
||||
@ -209,10 +219,10 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
|
||||
for ($i = 0; $i < $no_of_points; $i++) {
|
||||
$wkt .= ((isset($gis_data[$index]['MULTIPOINT'][$i]['x'])
|
||||
&& trim($gis_data[$index]['MULTIPOINT'][$i]['x']) != '')
|
||||
? $gis_data[$index]['MULTIPOINT'][$i]['x'] : $empty)
|
||||
? $gis_data[$index]['MULTIPOINT'][$i]['x'] : '')
|
||||
. ' ' . ((isset($gis_data[$index]['MULTIPOINT'][$i]['y'])
|
||||
&& trim($gis_data[$index]['MULTIPOINT'][$i]['y']) != '')
|
||||
? $gis_data[$index]['MULTIPOINT'][$i]['y'] : $empty) . ',';
|
||||
? $gis_data[$index]['MULTIPOINT'][$i]['y'] : '') . ',';
|
||||
}
|
||||
$wkt = substr($wkt, 0, strlen($wkt) - 1);
|
||||
$wkt .= ')';
|
||||
|
||||
@ -69,7 +69,9 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
|
||||
$points_arr = $this->extractPoints($point, $scale_data);
|
||||
|
||||
// draw a small circle to mark the point
|
||||
imagearc($image, $points_arr[0][0], $points_arr[0][1], 7, 7, 0, 360, $color);
|
||||
if ($points_arr[0][0] != '' && $points_arr[0][1] != '') {
|
||||
imagearc($image, $points_arr[0][0], $points_arr[0][1], 7, 7, 0, 360, $color);
|
||||
}
|
||||
return $image;
|
||||
}
|
||||
|
||||
@ -97,7 +99,9 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
|
||||
$points_arr = $this->extractPoints($point, $scale_data);
|
||||
|
||||
// draw a small circle to mark the point
|
||||
$pdf->Circle($points_arr[0][0], $points_arr[0][1], 2, 0, 360, 'D', $line);
|
||||
if ($points_arr[0][0] != '' && $points_arr[0][1] != '') {
|
||||
$pdf->Circle($points_arr[0][0], $points_arr[0][1], 2, 0, 360, 'D', $line);
|
||||
}
|
||||
return $pdf;
|
||||
}
|
||||
|
||||
@ -126,11 +130,13 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
|
||||
$point = substr($spatial, 6, (strlen($spatial) - 7));
|
||||
$points_arr = $this->extractPoints($point, $scale_data);
|
||||
|
||||
$row = '<circle cx="' . $points_arr[0][0] . '" cy="' . $points_arr[0][1] . '" r="3"';
|
||||
foreach ($point_options as $option => $val) {
|
||||
$row .= ' ' . $option . '="' . trim($val) . '"';
|
||||
if ($points_arr[0][0] != '' && $points_arr[0][1] != '') {
|
||||
$row = '<circle cx="' . $points_arr[0][0] . '" cy="' . $points_arr[0][1] . '" r="3"';
|
||||
foreach ($point_options as $option => $val) {
|
||||
$row .= ' ' . $option . '="' . trim($val) . '"';
|
||||
}
|
||||
$row .= '/>';
|
||||
}
|
||||
$row .= '/>';
|
||||
|
||||
return $row;
|
||||
}
|
||||
@ -167,11 +173,13 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
|
||||
$point = substr($spatial, 6, (strlen($spatial) - 7));
|
||||
$points_arr = $this->extractPoints($point, null);
|
||||
|
||||
$result .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector(('
|
||||
. 'new OpenLayers.Geometry.Point(' . $points_arr[0][0] . ', '
|
||||
. $points_arr[0][1] . ').transform(new OpenLayers.Projection("EPSG:'
|
||||
. $srid . '"), map.getProjectionObject())), null, '
|
||||
. json_encode($style_options) . '));';
|
||||
if ($points_arr[0][0] != '' && $points_arr[0][1] != '') {
|
||||
$result .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector(('
|
||||
. 'new OpenLayers.Geometry.Point(' . $points_arr[0][0] . ', '
|
||||
. $points_arr[0][1] . ').transform(new OpenLayers.Projection("EPSG:'
|
||||
. $srid . '"), map.getProjectionObject())), null, '
|
||||
. json_encode($style_options) . '));';
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -180,7 +188,7 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
|
||||
*
|
||||
* @param array $gis_data GIS data
|
||||
* @param int $index Index into the parameter object
|
||||
* @param string $empty Value for empty points
|
||||
* @param string $empty Point deos not adhere to this parameter
|
||||
*
|
||||
* @return WKT with the set of parameters passed by the GIS editor
|
||||
*/
|
||||
@ -188,9 +196,9 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
|
||||
{
|
||||
return 'POINT('
|
||||
. ((isset($gis_data[$index]['POINT']['x']) && trim($gis_data[$index]['POINT']['x']) != '')
|
||||
? $gis_data[$index]['POINT']['x'] : $empty) . ' '
|
||||
? $gis_data[$index]['POINT']['x'] : '') . ' '
|
||||
. ((isset($gis_data[$index]['POINT']['y']) && trim($gis_data[$index]['POINT']['y']) != '')
|
||||
? $gis_data[$index]['POINT']['y'] : $empty) . ')';
|
||||
? $gis_data[$index]['POINT']['y'] : '') . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user