Protection against malformed WKT and null

This commit is contained in:
Madhura Jayaratne 2011-07-11 21:29:48 +05:30
parent 6f3cf75e31
commit 3ca86a3929
3 changed files with 32 additions and 2 deletions

View File

@ -20,6 +20,9 @@ class PMA_GIS_Factory
include_once './libraries/gis/pma_gis_geometry.php';
$type_lower = strtolower($type);
if (! file_exists('./libraries/gis/pma_gis_' . $type_lower . '.php')) {
return false;
}
if (include_once './libraries/gis/pma_gis_' . $type_lower . '.php') {
switch($type) {
case 'MULTIPOLYGON' :
@ -37,10 +40,10 @@ class PMA_GIS_Factory
case 'GEOMETRYCOLLECTION' :
return PMA_GIS_Geometrycollection::singleton();
default :
throw new Exception('Unknown GIS data type');
return false;
}
} else {
throw new Exception('File not found');
return false;
}
}
}

View File

@ -53,6 +53,9 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
$type = substr($sub_part, 0, $type_pos);
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {
continue;
}
$scale_data = $gis_obj->scaleRow($sub_part);
// Upadate minimum/maximum values for x and y cordinates.
@ -102,6 +105,9 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
$type = substr($sub_part, 0, $type_pos);
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {
continue;
}
$image = $gis_obj->prepareRowAsPng($sub_part, $label, $color, $scale_data, $image);
}
return $image;
@ -130,6 +136,9 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
$type = substr($sub_part, 0, $type_pos);
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {
continue;
}
$image = $gis_obj->prepareRowAsPdf($sub_part, $label, $color, $scale_data, $pdf);
}
return $pdf;
@ -159,6 +168,9 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
$type = substr($sub_part, 0, $type_pos);
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {
continue;
}
$row .= $gis_obj->prepareRowAsSvg($sub_part, $label, $color, $scale_data);
}
return $row;
@ -189,6 +201,9 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
$type = substr($sub_part, 0, $type_pos);
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {
continue;
}
$row .= $gis_obj->prepareRowAsOl($sub_part, $srid, $label, $color, $scale_data);
}
return $row;
@ -239,6 +254,9 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
if (isset($gis_data[$i]['gis_type'])) {
$type = $gis_data[$i]['gis_type'];
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {
continue;
}
$wkt .= $gis_obj->generateWkt($gis_data, $i) . ',';
}
}
@ -275,6 +293,9 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
$type = substr($sub_part, 0, $type_pos);
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {
continue;
}
$params = array_merge($params, $gis_obj->generateParams($sub_part, $i));
$i++;
}

View File

@ -313,6 +313,9 @@ class PMA_GIS_Visualization
$type = substr($ref_data, 0, $type_pos);
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {
continue;
}
$scale_data = $gis_obj->scaleRow($row[$this->_settings['spatialColumn']]);
// Upadate minimum/maximum values for x and y cordinates.
@ -392,6 +395,9 @@ class PMA_GIS_Visualization
$type = substr($ref_data, 0, $type_pos);
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {
continue;
}
$label = '';
if (isset($this->_settings['labelColumn'])
&& isset($row[$this->_settings['labelColumn']])