Set namespaces on GIS classes.

Signed-off-by: Hugues Peccatte <hugues.peccatte@gmail.com>
This commit is contained in:
Hugues Peccatte 2015-09-12 22:33:15 +02:00
parent 330c92ddf7
commit e23bbdf2a6
23 changed files with 1314 additions and 722 deletions

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
use PMA\libraries\gis\GISFactory;
use PMA\libraries\gis\GISVisualization;
use PMA\libraries\String;
/**
@ -21,8 +23,6 @@ function escape($variable)
}
require_once 'libraries/common.inc.php';
require_once 'libraries/gis/GIS_Factory.class.php';
require_once 'libraries/gis/GIS_Visualization.class.php';
// Get data if any posted
$gis_data = array();
@ -66,7 +66,7 @@ if (! isset($gis_data['gis_type'])) {
$geom_type = $gis_data['gis_type'];
// Generate parameters from value passed.
$gis_obj = PMA_GIS_Factory::factory($geom_type);
$gis_obj = GISFactory::factory($geom_type);
if (isset($_REQUEST['value'])) {
$gis_data = array_merge(
$gis_data, $gis_obj->generateParams($_REQUEST['value'])
@ -89,10 +89,10 @@ $visualizationSettings = array(
'spatialColumn' => 'wkt'
);
$data = array(array('wkt' => $wkt_with_zero, 'srid' => $srid));
$visualization = PMA_GIS_Visualization::getByData($data, $visualizationSettings)
$visualization = GISVisualization::getByData($data, $visualizationSettings)
->toImage($format);
$open_layers = PMA_GIS_Visualization::getByData($data, $visualizationSettings)
$open_layers = GISVisualization::getByData($data, $visualizationSettings)
->asOl();
// If the call is to update the WKT and visualization make an AJAX response

View File

@ -12,12 +12,10 @@ namespace PMA\libraries\controllers\table;
use PMA\libraries\controllers\TableController;
use PMA\libraries\Message;
use PMA\libraries\Template;
use PMA_GIS_Visualization;
use PMA\libraries\gis\GISVisualization;
require_once 'libraries/common.inc.php';
require_once 'libraries/db_common.inc.php';
require_once 'libraries/gis/GIS_Visualization.class.php';
require_once 'libraries/gis/GIS_Factory.class.php';
/**
* Class TableGisVisualizationController
@ -43,7 +41,7 @@ class TableGisVisualizationController extends TableController
protected $visualizationSettings;
/**
* @var PMA_GIS_Visualization $visualization
* @var \PMA\libraries\gis\GISVisualization $visualization
*/
protected $visualization;
@ -145,7 +143,7 @@ class TableGisVisualizationController extends TableController
$rows = $GLOBALS['cfg']['MaxRows'];
}
}
$this->visualization = PMA_GIS_Visualization::get(
$this->visualization = GISVisualization::get(
$this->sql_query,
$this->visualizationSettings,
$rows,

View File

@ -6,7 +6,11 @@
* @package PhpMyAdmin-GIS
*/
if (! defined('PHPMYADMIN')) {
namespace PMA\libraries\gis;
use PMA;
if (!defined('PHPMYADMIN')) {
exit;
}
@ -15,14 +19,14 @@ if (! defined('PHPMYADMIN')) {
*
* @package PhpMyAdmin-GIS
*/
class PMA_GIS_Factory
class GISFactory
{
/**
* Returns the singleton instance of geometric class of the given type.
*
* @param string $type type of the geometric object
*
* @return PMA_GIS_Geometry the singleton instance of geometric class
* @return GISGeometry the singleton instance of geometric class
* of the given type
*
* @access public
@ -30,31 +34,29 @@ class PMA_GIS_Factory
*/
public static function factory($type)
{
include_once './libraries/gis/GIS_Geometry.class.php';
$type_lower = strtolower($type);
$file = './libraries/gis/GIS_' . ucfirst($type_lower) . '.class.php';
if (! PMA_isValid($type_lower, PMA\libraries\Util::getGISDatatypes())
|| ! file_exists($file)
$file = './libraries/gis/GIS' . ucfirst($type_lower) . '.php';
if (!PMA_isValid($type_lower, PMA\libraries\Util::getGISDatatypes())
|| !file_exists($file)
) {
return false;
}
if (include_once $file) {
switch(strtoupper($type)) {
switch (strtoupper($type)) {
case 'MULTIPOLYGON' :
return PMA_GIS_Multipolygon::singleton();
return GISMultipolygon::singleton();
case 'POLYGON' :
return PMA_GIS_Polygon::singleton();
return GISPolygon::singleton();
case 'MULTIPOINT' :
return PMA_GIS_Multipoint::singleton();
return GISMultipoint::singleton();
case 'POINT' :
return PMA_GIS_Point::singleton();
return GISPoint::singleton();
case 'MULTILINESTRING' :
return PMA_GIS_Multilinestring::singleton();
return GISMultilinestring::singleton();
case 'LINESTRING' :
return PMA_GIS_Linestring::singleton();
return GISLinestring::singleton();
case 'GEOMETRYCOLLECTION' :
return PMA_GIS_Geometrycollection::singleton();
return GISGeometrycollection::singleton();
default :
return false;
}

View File

@ -6,7 +6,11 @@
* @package PhpMyAdmin-GIS
*/
if (! defined('PHPMYADMIN')) {
namespace PMA\libraries\gis;
use TCPDF;
if (!defined('PHPMYADMIN')) {
exit;
}
@ -15,7 +19,7 @@ if (! defined('PHPMYADMIN')) {
*
* @package PhpMyAdmin-GIS
*/
abstract class PMA_GIS_Geometry
abstract class GISGeometry
{
/**
* Prepares and returns the code related to a row in the GIS dataset as SVG.
@ -42,8 +46,12 @@ abstract class PMA_GIS_Geometry
* @return object the modified image object
* @access public
*/
public abstract function prepareRowAsPng($spatial, $label, $color,
$scale_data, $image
public abstract function prepareRowAsPng(
$spatial,
$label,
$color,
$scale_data,
$image
);
/**
@ -58,8 +66,12 @@ abstract class PMA_GIS_Geometry
* @return TCPDF the modified TCPDF instance
* @access public
*/
public abstract function prepareRowAsPdf($spatial, $label, $color,
$scale_data, $pdf
public abstract function prepareRowAsPdf(
$spatial,
$label,
$color,
$scale_data,
$pdf
);
/**
@ -75,8 +87,12 @@ abstract class PMA_GIS_Geometry
* @return string the JavaScript related to a row in the GIS dataset
* @access public
*/
public abstract function prepareRowAsOl($spatial, $srid, $label,
$color, $scale_data
public abstract function prepareRowAsOl(
$spatial,
$srid,
$label,
$color,
$scale_data
);
/**
@ -114,14 +130,14 @@ abstract class PMA_GIS_Geometry
protected function getBoundsForOl($srid, $scale_data)
{
return 'bound = new OpenLayers.Bounds(); '
. 'bound.extend(new OpenLayers.LonLat('
. $scale_data['minX'] . ', ' . $scale_data['minY']
. ').transform(new OpenLayers.Projection("EPSG:'
. $srid . '"), map.getProjectionObject())); '
. 'bound.extend(new OpenLayers.LonLat('
. $scale_data['maxX'] . ', ' . $scale_data['maxY']
. ').transform(new OpenLayers.Projection("EPSG:'
. $srid . '"), map.getProjectionObject()));';
. 'bound.extend(new OpenLayers.LonLat('
. $scale_data['minX'] . ', ' . $scale_data['minY']
. ').transform(new OpenLayers.Projection("EPSG:'
. $srid . '"), map.getProjectionObject())); '
. 'bound.extend(new OpenLayers.LonLat('
. $scale_data['maxX'] . ', ' . $scale_data['maxY']
. ').transform(new OpenLayers.Projection("EPSG:'
. $srid . '"), map.getProjectionObject()));';
}
/**
@ -142,21 +158,22 @@ abstract class PMA_GIS_Geometry
// Extract coordinates of the point
$cordinates = explode(" ", $point);
$x = (float) $cordinates[0];
if (! isset($min_max['maxX']) || $x > $min_max['maxX']) {
$x = (float)$cordinates[0];
if (!isset($min_max['maxX']) || $x > $min_max['maxX']) {
$min_max['maxX'] = $x;
}
if (! isset($min_max['minX']) || $x < $min_max['minX']) {
if (!isset($min_max['minX']) || $x < $min_max['minX']) {
$min_max['minX'] = $x;
}
$y = (float) $cordinates[1];
if (! isset($min_max['maxY']) || $y > $min_max['maxY']) {
$y = (float)$cordinates[1];
if (!isset($min_max['maxY']) || $y > $min_max['maxY']) {
$min_max['maxY'] = $y;
}
if (! isset($min_max['minY']) || $y < $min_max['minY']) {
if (!isset($min_max['minY']) || $y < $min_max['minY']) {
$min_max['minY'] = $y;
}
}
return $min_max;
}
@ -178,12 +195,19 @@ abstract class PMA_GIS_Geometry
$wkt = '';
if (preg_match("/^'" . $geom_types . "\(.*\)',[0-9]*$/i", $value)) {
$last_comma = /*overload*/mb_strripos($value, ",");
$srid = trim(/*overload*/mb_substr($value, $last_comma + 1));
$wkt = trim(/*overload*/mb_substr($value, 1, $last_comma - 2));
$last_comma
= /*overload*/
mb_strripos($value, ",");
$srid = trim(/*overload*/
mb_substr($value, $last_comma + 1)
);
$wkt = trim(/*overload*/
mb_substr($value, 1, $last_comma - 2)
);
} elseif (preg_match("/^" . $geom_types . "\(.*\)$/i", $value)) {
$wkt = $value;
}
return array('srid' => $srid, 'wkt' => $wkt);
}
@ -209,7 +233,8 @@ abstract class PMA_GIS_Geometry
$cordinates = explode(" ", $point);
if (isset($cordinates[0]) && trim($cordinates[0]) != ''
&& isset($cordinates[1]) && trim($cordinates[1]) != ''
&& isset($cordinates[1])
&& trim($cordinates[1]) != ''
) {
if ($scale_data != null) {
$x = ($cordinates[0] - $scale_data['x']) * $scale_data['scale'];
@ -224,7 +249,7 @@ abstract class PMA_GIS_Geometry
$y = '';
}
if (! $linear) {
if (!$linear) {
$points_arr[] = array($x, $y);
} else {
$points_arr[] = $x;
@ -252,11 +277,14 @@ abstract class PMA_GIS_Geometry
$ol_array .= $this->getPolygonForOpenLayers($rings, $srid) . ', ';
}
$ol_array = /*overload*/mb_substr(
$ol_array,
0,
/*overload*/mb_strlen($ol_array) - 2
);
$ol_array
= /*overload*/
mb_substr(
$ol_array,
0,
/*overload*/
mb_strlen($ol_array) - 2
);
$ol_array .= ')';
return $ol_array;
@ -274,8 +302,8 @@ abstract class PMA_GIS_Geometry
protected function getPolygonForOpenLayers($polygon, $srid)
{
return 'new OpenLayers.Geometry.Polygon('
. $this->getLineArrayForOpenLayers($polygon, $srid, false)
. ')';
. $this->getLineArrayForOpenLayers($polygon, $srid, false)
. ')';
}
/**
@ -290,23 +318,30 @@ abstract class PMA_GIS_Geometry
* or LineRing to OpenLayers
* @access protected
*/
protected function getLineArrayForOpenLayers($lines, $srid,
protected function getLineArrayForOpenLayers(
$lines,
$srid,
$is_line_string = true
) {
$ol_array = 'new Array(';
foreach ($lines as $line) {
$points_arr = $this->extractPoints($line, null);
$ol_array .= $this->getLineForOpenLayers(
$points_arr, $srid, $is_line_string
$points_arr,
$srid,
$is_line_string
);
$ol_array .= ', ';
}
$ol_array = /*overload*/mb_substr(
$ol_array,
0,
/*overload*/mb_strlen($ol_array) - 2
);
$ol_array
= /*overload*/
mb_substr(
$ol_array,
0,
/*overload*/
mb_strlen($ol_array) - 2
);
$ol_array .= ')';
return $ol_array;
@ -322,13 +357,15 @@ abstract class PMA_GIS_Geometry
* @return string JavaScript for adding a LineString or LineRing to OpenLayers
* @access protected
*/
protected function getLineForOpenLayers($points_arr, $srid,
protected function getLineForOpenLayers(
$points_arr,
$srid,
$is_line_string = true
) {
return 'new OpenLayers.Geometry.'
. ($is_line_string ? 'LineString' : 'LinearRing') . '('
. $this->getPointsArrayForOpenLayers($points_arr, $srid)
. ')';
. ($is_line_string ? 'LineString' : 'LinearRing') . '('
. $this->getPointsArrayForOpenLayers($points_arr, $srid)
. ')';
}
/**
@ -347,11 +384,14 @@ abstract class PMA_GIS_Geometry
$ol_array .= $this->getPointForOpenLayers($point, $srid) . ', ';
}
$ol_array = /*overload*/mb_substr(
$ol_array,
0,
/*overload*/mb_strlen($ol_array) - 2
);
$ol_array
= /*overload*/
mb_substr(
$ol_array,
0,
/*overload*/
mb_strlen($ol_array) - 2
);
$ol_array .= ')';
return $ol_array;
@ -369,7 +409,7 @@ abstract class PMA_GIS_Geometry
protected function getPointForOpenLayers($point, $srid)
{
return '(new OpenLayers.Geometry.Point(' . $point[0] . ',' . $point[1] . '))'
. '.transform(new OpenLayers.Projection("EPSG:'
. $srid . '"), map.getProjectionObject())';
. '.transform(new OpenLayers.Projection("EPSG:'
. $srid . '"), map.getProjectionObject())';
}
}

View File

@ -6,7 +6,11 @@
* @package PhpMyAdmin-GIS
*/
if (! defined('PHPMYADMIN')) {
namespace PMA\libraries\gis;
use TCPDF;
if (!defined('PHPMYADMIN')) {
exit;
}
@ -15,7 +19,7 @@ if (! defined('PHPMYADMIN')) {
*
* @package PhpMyAdmin-GIS
*/
class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
class GISGeometrycollection extends GISGeometry
{
// Hold the singleton instance of the class
private static $_instance;
@ -32,7 +36,7 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
/**
* Returns the singleton.
*
* @return PMA_GIS_Geometrycollection the singleton
* @return GISGeometrycollection the singleton
* @access public
*/
public static function singleton()
@ -58,46 +62,54 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
$min_max = array();
// Trim to remove leading 'GEOMETRYCOLLECTION(' and trailing ')'
$goem_col = /*overload*/mb_substr(
$spatial,
19,
/*overload*/mb_strlen($spatial) - 20
);
$goem_col
= /*overload*/
mb_substr(
$spatial,
19,
/*overload*/
mb_strlen($spatial) - 20
);
// Split the geometry collection object to get its constituents.
$sub_parts = $this->_explodeGeomCol($goem_col);
foreach ($sub_parts as $sub_part) {
$type_pos = /*overload*/mb_stripos($sub_part, '(');
$type = /*overload*/mb_substr($sub_part, 0, $type_pos);
$type_pos
= /*overload*/
mb_stripos($sub_part, '(');
$type
= /*overload*/
mb_substr($sub_part, 0, $type_pos);
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {
$gis_obj = GISFactory::factory($type);
if (!$gis_obj) {
continue;
}
$scale_data = $gis_obj->scaleRow($sub_part);
// Update minimum/maximum values for x and y coordinates.
$c_maxX = (float) $scale_data['maxX'];
if (! isset($min_max['maxX']) || $c_maxX > $min_max['maxX']) {
$c_maxX = (float)$scale_data['maxX'];
if (!isset($min_max['maxX']) || $c_maxX > $min_max['maxX']) {
$min_max['maxX'] = $c_maxX;
}
$c_minX = (float) $scale_data['minX'];
if (! isset($min_max['minX']) || $c_minX < $min_max['minX']) {
$c_minX = (float)$scale_data['minX'];
if (!isset($min_max['minX']) || $c_minX < $min_max['minX']) {
$min_max['minX'] = $c_minX;
}
$c_maxY = (float) $scale_data['maxY'];
if (! isset($min_max['maxY']) || $c_maxY > $min_max['maxY']) {
$c_maxY = (float)$scale_data['maxY'];
if (!isset($min_max['maxY']) || $c_maxY > $min_max['maxY']) {
$min_max['maxY'] = $c_maxY;
}
$c_minY = (float) $scale_data['minY'];
if (! isset($min_max['minY']) || $c_minY < $min_max['minY']) {
$c_minY = (float)$scale_data['minY'];
if (!isset($min_max['minY']) || $c_minY < $min_max['minY']) {
$min_max['minY'] = $c_minY;
}
}
return $min_max;
}
@ -116,26 +128,38 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
public function prepareRowAsPng($spatial, $label, $color, $scale_data, $image)
{
// Trim to remove leading 'GEOMETRYCOLLECTION(' and trailing ')'
$goem_col = /*overload*/mb_substr(
$spatial,
19,
/*overload*/mb_strlen($spatial) - 20
);
$goem_col
= /*overload*/
mb_substr(
$spatial,
19,
/*overload*/
mb_strlen($spatial) - 20
);
// Split the geometry collection object to get its constituents.
$sub_parts = $this->_explodeGeomCol($goem_col);
foreach ($sub_parts as $sub_part) {
$type_pos = /*overload*/mb_stripos($sub_part, '(');
$type = /*overload*/mb_substr($sub_part, 0, $type_pos);
$type_pos
= /*overload*/
mb_stripos($sub_part, '(');
$type
= /*overload*/
mb_substr($sub_part, 0, $type_pos);
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {
$gis_obj = GISFactory::factory($type);
if (!$gis_obj) {
continue;
}
$image = $gis_obj->prepareRowAsPng(
$sub_part, $label, $color, $scale_data, $image
$sub_part,
$label,
$color,
$scale_data,
$image
);
}
return $image;
}
@ -154,26 +178,38 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
public function prepareRowAsPdf($spatial, $label, $color, $scale_data, $pdf)
{
// Trim to remove leading 'GEOMETRYCOLLECTION(' and trailing ')'
$goem_col = /*overload*/mb_substr(
$spatial,
19,
/*overload*/mb_strlen($spatial) - 20
);
$goem_col
= /*overload*/
mb_substr(
$spatial,
19,
/*overload*/
mb_strlen($spatial) - 20
);
// Split the geometry collection object to get its constituents.
$sub_parts = $this->_explodeGeomCol($goem_col);
foreach ($sub_parts as $sub_part) {
$type_pos = /*overload*/mb_stripos($sub_part, '(');
$type = /*overload*/mb_substr($sub_part, 0, $type_pos);
$type_pos
= /*overload*/
mb_stripos($sub_part, '(');
$type
= /*overload*/
mb_substr($sub_part, 0, $type_pos);
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {
$gis_obj = GISFactory::factory($type);
if (!$gis_obj) {
continue;
}
$pdf = $gis_obj->prepareRowAsPdf(
$sub_part, $label, $color, $scale_data, $pdf
$sub_part,
$label,
$color,
$scale_data,
$pdf
);
}
return $pdf;
}
@ -193,26 +229,37 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
$row = '';
// Trim to remove leading 'GEOMETRYCOLLECTION(' and trailing ')'
$goem_col = /*overload*/mb_substr(
$spatial,
19,
/*overload*/mb_strlen($spatial) - 20
);
$goem_col
= /*overload*/
mb_substr(
$spatial,
19,
/*overload*/
mb_strlen($spatial) - 20
);
// Split the geometry collection object to get its constituents.
$sub_parts = $this->_explodeGeomCol($goem_col);
foreach ($sub_parts as $sub_part) {
$type_pos = /*overload*/mb_stripos($sub_part, '(');
$type = /*overload*/mb_substr($sub_part, 0, $type_pos);
$type_pos
= /*overload*/
mb_stripos($sub_part, '(');
$type
= /*overload*/
mb_substr($sub_part, 0, $type_pos);
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {
$gis_obj = GISFactory::factory($type);
if (!$gis_obj) {
continue;
}
$row .= $gis_obj->prepareRowAsSvg(
$sub_part, $label, $color, $scale_data
$sub_part,
$label,
$color,
$scale_data
);
}
return $row;
}
@ -234,26 +281,38 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
$row = '';
// Trim to remove leading 'GEOMETRYCOLLECTION(' and trailing ')'
$goem_col = /*overload*/mb_substr(
$spatial,
19,
/*overload*/mb_strlen($spatial) - 20
);
$goem_col
= /*overload*/
mb_substr(
$spatial,
19,
/*overload*/
mb_strlen($spatial) - 20
);
// Split the geometry collection object to get its constituents.
$sub_parts = $this->_explodeGeomCol($goem_col);
foreach ($sub_parts as $sub_part) {
$type_pos = /*overload*/mb_stripos($sub_part, '(');
$type = /*overload*/mb_substr($sub_part, 0, $type_pos);
$type_pos
= /*overload*/
mb_stripos($sub_part, '(');
$type
= /*overload*/
mb_substr($sub_part, 0, $type_pos);
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {
$gis_obj = GISFactory::factory($type);
if (!$gis_obj) {
continue;
}
$row .= $gis_obj->prepareRowAsOl(
$sub_part, $srid, $label, $color, $scale_data
$sub_part,
$srid,
$label,
$color,
$scale_data
);
}
return $row;
}
@ -277,16 +336,19 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
} elseif ($char == ')') {
$br_count--;
if ($br_count == 0) {
$sub_parts[] = /*overload*/mb_substr(
$geom_col,
$start,
($count + 1 - $start)
);
$sub_parts[]
= /*overload*/
mb_substr(
$geom_col,
$start,
($count + 1 - $start)
);
$start = $count + 2;
}
}
$count++;
}
return $sub_parts;
}
@ -308,17 +370,24 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
for ($i = 0; $i < $geom_count; $i++) {
if (isset($gis_data[$i]['gis_type'])) {
$type = $gis_data[$i]['gis_type'];
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {
$gis_obj = GISFactory::factory($type);
if (!$gis_obj) {
continue;
}
$wkt .= $gis_obj->generateWkt($gis_data, $i, $empty) . ',';
}
}
if (isset($gis_data[0]['gis_type'])) {
$wkt = /*overload*/mb_substr($wkt, 0, /*overload*/mb_strlen($wkt) - 1);
$wkt
= /*overload*/
mb_substr(
$wkt,
0, /*overload*/
mb_strlen($wkt) - 1
);
}
$wkt .= ')';
return $wkt;
}
@ -333,31 +402,39 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
public function generateParams($value)
{
$params = array();
$data = PMA_GIS_Geometry::generateParams($value);
$data = GISGeometry::generateParams($value);
$params['srid'] = $data['srid'];
$wkt = $data['wkt'];
// Trim to remove leading 'GEOMETRYCOLLECTION(' and trailing ')'
$goem_col = /*overload*/mb_substr(
$wkt,
19,
/*overload*/mb_strlen($wkt) - 20
);
$goem_col
= /*overload*/
mb_substr(
$wkt,
19,
/*overload*/
mb_strlen($wkt) - 20
);
// Split the geometry collection object to get its constituents.
$sub_parts = $this->_explodeGeomCol($goem_col);
$params['GEOMETRYCOLLECTION']['geom_count'] = count($sub_parts);
$i = 0;
foreach ($sub_parts as $sub_part) {
$type_pos = /*overload*/mb_stripos($sub_part, '(');
$type = /*overload*/mb_substr($sub_part, 0, $type_pos);
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {
$type_pos
= /*overload*/
mb_stripos($sub_part, '(');
$type
= /*overload*/
mb_substr($sub_part, 0, $type_pos);
$gis_obj = GISFactory::factory($type);
if (!$gis_obj) {
continue;
}
$params = array_merge($params, $gis_obj->generateParams($sub_part, $i));
$i++;
}
return $params;
}
}

View File

@ -6,7 +6,11 @@
* @package PhpMyAdmin-GIS
*/
if (! defined('PHPMYADMIN')) {
namespace PMA\libraries\gis;
use TCPDF;
if (!defined('PHPMYADMIN')) {
exit;
}
@ -15,7 +19,7 @@ if (! defined('PHPMYADMIN')) {
*
* @package PhpMyAdmin-GIS
*/
class PMA_GIS_Linestring extends PMA_GIS_Geometry
class GISLinestring extends GISGeometry
{
// Hold the singleton instance of the class
private static $_instance;
@ -32,7 +36,7 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
/**
* Returns the singleton.
*
* @return PMA_GIS_Linestring the singleton
* @return GISLinestring the singleton
* @access public
*/
public static function singleton()
@ -56,11 +60,15 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
public function scaleRow($spatial)
{
// Trim to remove leading 'LINESTRING(' and trailing ')'
$linestring = /*overload*/mb_substr(
$spatial,
11,
/*overload*/mb_strlen($spatial) - 12
);
$linestring
= /*overload*/
mb_substr(
$spatial,
11,
/*overload*/
mb_strlen($spatial) - 12
);
return $this->setMinMax($linestring, array());
}
@ -76,32 +84,49 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
* @return resource the modified image object
* @access public
*/
public function prepareRowAsPng($spatial, $label, $line_color,
$scale_data, $image
public function prepareRowAsPng(
$spatial,
$label,
$line_color,
$scale_data,
$image
) {
// allocate colors
$black = imagecolorallocate($image, 0, 0, 0);
$red = hexdec(/*overload*/mb_substr($line_color, 1, 2));
$green = hexdec(/*overload*/mb_substr($line_color, 3, 2));
$blue = hexdec(/*overload*/mb_substr($line_color, 4, 2));
$red = hexdec(/*overload*/
mb_substr($line_color, 1, 2)
);
$green = hexdec(/*overload*/
mb_substr($line_color, 3, 2)
);
$blue = hexdec(/*overload*/
mb_substr($line_color, 4, 2)
);
$color = imagecolorallocate($image, $red, $green, $blue);
// Trim to remove leading 'LINESTRING(' and trailing ')'
$linesrting = /*overload*/mb_substr(
$spatial,
11,
/*overload*/mb_strlen($spatial) - 12
);
$linesrting
= /*overload*/
mb_substr(
$spatial,
11,
/*overload*/
mb_strlen($spatial) - 12
);
$points_arr = $this->extractPoints($linesrting, $scale_data);
foreach ($points_arr as $point) {
if (! isset($temp_point)) {
if (!isset($temp_point)) {
$temp_point = $point;
} else {
// draw line section
imageline(
$image, $temp_point[0], $temp_point[1],
$point[0], $point[1], $color
$image,
$temp_point[0],
$temp_point[1],
$point[0],
$point[1],
$color
);
$temp_point = $point;
}
@ -109,10 +134,15 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
// print label if applicable
if (isset($label) && trim($label) != '') {
imagestring(
$image, 1, $points_arr[1][0],
$points_arr[1][1], trim($label), $black
$image,
1,
$points_arr[1][0],
$points_arr[1][1],
trim($label),
$black
);
}
return $image;
}
@ -131,27 +161,39 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
public function prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf)
{
// allocate colors
$red = hexdec(/*overload*/mb_substr($line_color, 1, 2));
$green = hexdec(/*overload*/mb_substr($line_color, 3, 2));
$blue = hexdec(/*overload*/mb_substr($line_color, 4, 2));
$line = array('width' => 1.5, 'color' => array($red, $green, $blue));
$red = hexdec(/*overload*/
mb_substr($line_color, 1, 2)
);
$green = hexdec(/*overload*/
mb_substr($line_color, 3, 2)
);
$blue = hexdec(/*overload*/
mb_substr($line_color, 4, 2)
);
$line = array('width' => 1.5, 'color' => array($red, $green, $blue));
// Trim to remove leading 'LINESTRING(' and trailing ')'
$linesrting = /*overload*/mb_substr(
$spatial,
11,
/*overload*/mb_strlen($spatial) - 12
);
$linesrting
= /*overload*/
mb_substr(
$spatial,
11,
/*overload*/
mb_strlen($spatial) - 12
);
$points_arr = $this->extractPoints($linesrting, $scale_data);
foreach ($points_arr as $point) {
if (! isset($temp_point)) {
if (!isset($temp_point)) {
$temp_point = $point;
} else {
// draw line section
$pdf->Line(
$temp_point[0], $temp_point[1],
$point[0], $point[1], $line
$temp_point[0],
$temp_point[1],
$point[0],
$point[1],
$line
);
$temp_point = $point;
}
@ -162,6 +204,7 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
$pdf->SetFontSize(5);
$pdf->Cell(0, 0, trim($label));
}
return $pdf;
}
@ -179,20 +222,23 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
public function prepareRowAsSvg($spatial, $label, $line_color, $scale_data)
{
$line_options = array(
'name' => $label,
'id' => $label . rand(),
'class' => 'linestring vector',
'fill' => 'none',
'stroke' => $line_color,
'stroke-width'=> 2,
'name' => $label,
'id' => $label . rand(),
'class' => 'linestring vector',
'fill' => 'none',
'stroke' => $line_color,
'stroke-width' => 2,
);
// Trim to remove leading 'LINESTRING(' and trailing ')'
$linesrting = /*overload*/mb_substr(
$spatial,
11,
/*overload*/mb_strlen($spatial) - 12
);
$linesrting
= /*overload*/
mb_substr(
$spatial,
11,
/*overload*/
mb_strlen($spatial) - 12
);
$points_arr = $this->extractPoints($linesrting, $scale_data);
$row = '<polyline points="';
@ -235,16 +281,20 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
$result = $this->getBoundsForOl($srid, $scale_data);
// Trim to remove leading 'LINESTRING(' and trailing ')'
$linesrting = /*overload*/mb_substr(
$spatial,
11,
/*overload*/mb_strlen($spatial) - 12
);
$linesrting
= /*overload*/
mb_substr(
$spatial,
11,
/*overload*/
mb_strlen($spatial) - 12
);
$points_arr = $this->extractPoints($linesrting, null);
$result .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
. $this->getLineForOpenLayers($points_arr, $srid)
. ', null, ' . json_encode($style_options) . '));';
return $result;
}
@ -268,15 +318,22 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
$wkt = 'LINESTRING(';
for ($i = 0; $i < $no_of_points; $i++) {
$wkt .= ((isset($gis_data[$index]['LINESTRING'][$i]['x'])
&& trim($gis_data[$index]['LINESTRING'][$i]['x']) != '')
? $gis_data[$index]['LINESTRING'][$i]['x'] : $empty)
&& trim($gis_data[$index]['LINESTRING'][$i]['x']) != '')
? $gis_data[$index]['LINESTRING'][$i]['x'] : $empty)
. ' ' . ((isset($gis_data[$index]['LINESTRING'][$i]['y'])
&& trim($gis_data[$index]['LINESTRING'][$i]['y']) != '')
? $gis_data[$index]['LINESTRING'][$i]['y'] : $empty) . ',';
&& trim($gis_data[$index]['LINESTRING'][$i]['y']) != '')
? $gis_data[$index]['LINESTRING'][$i]['y'] : $empty) . ',';
}
$wkt = /*overload*/mb_substr($wkt, 0, /*overload*/mb_strlen($wkt) - 1);
$wkt
= /*overload*/
mb_substr(
$wkt,
0, /*overload*/
mb_strlen($wkt) - 1
);
$wkt .= ')';
return $wkt;
}
@ -294,7 +351,7 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
$params = array();
if ($index == -1) {
$index = 0;
$data = PMA_GIS_Geometry::generateParams($value);
$data = GISGeometry::generateParams($value);
$params['srid'] = $data['srid'];
$wkt = $data['wkt'];
} else {
@ -303,11 +360,14 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
}
// Trim to remove leading 'LINESTRING(' and trailing ')'
$linestring = /*overload*/mb_substr(
$wkt,
11,
/*overload*/mb_strlen($wkt) - 12
);
$linestring
= /*overload*/
mb_substr(
$wkt,
11,
/*overload*/
mb_strlen($wkt) - 12
);
$points_arr = $this->extractPoints($linestring, null);
$no_of_points = count($points_arr);

View File

@ -6,7 +6,11 @@
* @package PhpMyAdmin-GIS
*/
if (! defined('PHPMYADMIN')) {
namespace PMA\libraries\gis;
use TCPDF;
if (!defined('PHPMYADMIN')) {
exit;
}
@ -15,7 +19,7 @@ if (! defined('PHPMYADMIN')) {
*
* @package PhpMyAdmin-GIS
*/
class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
class GISMultilinestring extends GISGeometry
{
// Hold the singleton instance of the class
private static $_instance;
@ -32,7 +36,7 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
/**
* Returns the singleton.
*
* @return PMA_GIS_Multilinestring the singleton
* @return GISMultilinestring the singleton
* @access public
*/
public static function singleton()
@ -58,11 +62,14 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
$min_max = array();
// Trim to remove leading 'MULTILINESTRING((' and trailing '))'
$multilinestirng = /*overload*/mb_substr(
$spatial,
17,
/*overload*/mb_strlen($spatial) - 19
);
$multilinestirng
= /*overload*/
mb_substr(
$spatial,
17,
/*overload*/
mb_strlen($spatial) - 19
);
// Separate each linestring
$linestirngs = explode("),(", $multilinestirng);
@ -85,22 +92,35 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
* @return object the modified image object
* @access public
*/
public function prepareRowAsPng($spatial, $label, $line_color,
$scale_data, $image
public function prepareRowAsPng(
$spatial,
$label,
$line_color,
$scale_data,
$image
) {
// allocate colors
$black = imagecolorallocate($image, 0, 0, 0);
$red = hexdec(/*overload*/mb_substr($line_color, 1, 2));
$green = hexdec(/*overload*/mb_substr($line_color, 3, 2));
$blue = hexdec(/*overload*/mb_substr($line_color, 4, 2));
$red = hexdec(/*overload*/
mb_substr($line_color, 1, 2)
);
$green = hexdec(/*overload*/
mb_substr($line_color, 3, 2)
);
$blue = hexdec(/*overload*/
mb_substr($line_color, 4, 2)
);
$color = imagecolorallocate($image, $red, $green, $blue);
// Trim to remove leading 'MULTILINESTRING((' and trailing '))'
$multilinestirng = /*overload*/mb_substr(
$spatial,
17,
/*overload*/mb_strlen($spatial) - 19
);
$multilinestirng
= /*overload*/
mb_substr(
$spatial,
17,
/*overload*/
mb_strlen($spatial) - 19
);
// Separate each linestring
$linestirngs = explode("),(", $multilinestirng);
@ -108,13 +128,17 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
foreach ($linestirngs as $linestring) {
$points_arr = $this->extractPoints($linestring, $scale_data);
foreach ($points_arr as $point) {
if (! isset($temp_point)) {
if (!isset($temp_point)) {
$temp_point = $point;
} else {
// draw line section
imageline(
$image, $temp_point[0], $temp_point[1],
$point[0], $point[1], $color
$image,
$temp_point[0],
$temp_point[1],
$point[0],
$point[1],
$color
);
$temp_point = $point;
}
@ -123,12 +147,17 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
// print label if applicable
if (isset($label) && trim($label) != '' && $first_line) {
imagestring(
$image, 1, $points_arr[1][0],
$points_arr[1][1], trim($label), $black
$image,
1,
$points_arr[1][0],
$points_arr[1][1],
trim($label),
$black
);
}
$first_line = false;
}
return $image;
}
@ -147,16 +176,25 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
public function prepareRowAsPdf($spatial, $label, $line_color, $scale_data, $pdf)
{
// allocate colors
$red = hexdec(/*overload*/mb_substr($line_color, 1, 2));
$green = hexdec(/*overload*/mb_substr($line_color, 3, 2));
$blue = hexdec(/*overload*/mb_substr($line_color, 4, 2));
$line = array('width' => 1.5, 'color' => array($red, $green, $blue));
$red = hexdec(/*overload*/
mb_substr($line_color, 1, 2)
);
$green = hexdec(/*overload*/
mb_substr($line_color, 3, 2)
);
$blue = hexdec(/*overload*/
mb_substr($line_color, 4, 2)
);
$line = array('width' => 1.5, 'color' => array($red, $green, $blue));
// Trim to remove leading 'MULTILINESTRING((' and trailing '))'
$multilinestirng = /*overload*/mb_substr(
$spatial,
17, /*overload*/mb_strlen($spatial) - 19
);
$multilinestirng
= /*overload*/
mb_substr(
$spatial,
17, /*overload*/
mb_strlen($spatial) - 19
);
// Separate each linestring
$linestirngs = explode("),(", $multilinestirng);
@ -164,12 +202,16 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
foreach ($linestirngs as $linestring) {
$points_arr = $this->extractPoints($linestring, $scale_data);
foreach ($points_arr as $point) {
if (! isset($temp_point)) {
if (!isset($temp_point)) {
$temp_point = $point;
} else {
// draw line section
$pdf->Line(
$temp_point[0], $temp_point[1], $point[0], $point[1], $line
$temp_point[0],
$temp_point[1],
$point[0],
$point[1],
$line
);
$temp_point = $point;
}
@ -183,6 +225,7 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
}
$first_line = false;
}
return $pdf;
}
@ -200,19 +243,22 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
public function prepareRowAsSvg($spatial, $label, $line_color, $scale_data)
{
$line_options = array(
'name' => $label,
'class' => 'linestring vector',
'fill' => 'none',
'stroke' => $line_color,
'stroke-width'=> 2,
'name' => $label,
'class' => 'linestring vector',
'fill' => 'none',
'stroke' => $line_color,
'stroke-width' => 2,
);
// Trim to remove leading 'MULTILINESTRING((' and trailing '))'
$multilinestirng = /*overload*/mb_substr(
$spatial,
17,
/*overload*/mb_strlen($spatial) - 19
);
$multilinestirng
= /*overload*/
mb_substr(
$spatial,
17,
/*overload*/
mb_strlen($spatial) - 19
);
// Separate each linestring
$linestirngs = explode("),(", $multilinestirng);
@ -262,11 +308,14 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
$row = $this->getBoundsForOl($srid, $scale_data);
// Trim to remove leading 'MULTILINESTRING((' and trailing '))'
$multilinestirng = /*overload*/mb_substr(
$spatial,
17,
/*overload*/mb_strlen($spatial) - 19
);
$multilinestirng
= /*overload*/
mb_substr(
$spatial,
17,
/*overload*/
mb_strlen($spatial) - 19
);
// Separate each linestring
$linestirngs = explode("),(", $multilinestirng);
@ -274,6 +323,7 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
. 'new OpenLayers.Geometry.MultiLineString('
. $this->getLineArrayForOpenLayers($linestirngs, $srid)
. '), null, ' . json_encode($style_options) . '));';
return $row;
}
@ -307,17 +357,30 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
$wkt .= '(';
for ($j = 0; $j < $no_of_points; $j++) {
$wkt .= ((isset($data_row[$i][$j]['x'])
&& trim($data_row[$i][$j]['x']) != '')
? $data_row[$i][$j]['x'] : $empty)
&& trim($data_row[$i][$j]['x']) != '')
? $data_row[$i][$j]['x'] : $empty)
. ' ' . ((isset($data_row[$i][$j]['y'])
&& trim($data_row[$i][$j]['y']) != '')
? $data_row[$i][$j]['y'] : $empty) . ',';
&& trim($data_row[$i][$j]['y']) != '')
? $data_row[$i][$j]['y'] : $empty) . ',';
}
$wkt = /*overload*/mb_substr($wkt, 0, /*overload*/mb_strlen($wkt) - 1);
$wkt
= /*overload*/
mb_substr(
$wkt,
0, /*overload*/
mb_strlen($wkt) - 1
);
$wkt .= '),';
}
$wkt = /*overload*/mb_substr($wkt, 0, /*overload*/mb_strlen($wkt) - 1);
$wkt
= /*overload*/
mb_substr(
$wkt,
0, /*overload*/
mb_strlen($wkt) - 1
);
$wkt .= ')';
return $wkt;
}
@ -337,11 +400,24 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
foreach ($row_data['parts'][$i]['points'] as $point) {
$wkt .= $point['x'] . ' ' . $point['y'] . ',';
}
$wkt = /*overload*/mb_substr($wkt, 0, /*overload*/mb_strlen($wkt) - 1);
$wkt
= /*overload*/
mb_substr(
$wkt,
0, /*overload*/
mb_strlen($wkt) - 1
);
$wkt .= '),';
}
$wkt = /*overload*/mb_substr($wkt, 0, /*overload*/mb_strlen($wkt) - 1);
$wkt
= /*overload*/
mb_substr(
$wkt,
0, /*overload*/
mb_strlen($wkt) - 1
);
$wkt .= ')';
return $wkt;
}
@ -359,7 +435,7 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
$params = array();
if ($index == -1) {
$index = 0;
$data = PMA_GIS_Geometry::generateParams($value);
$data = GISGeometry::generateParams($value);
$params['srid'] = $data['srid'];
$wkt = $data['wkt'];
} else {
@ -368,11 +444,14 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
}
// Trim to remove leading 'MULTILINESTRING((' and trailing '))'
$multilinestirng = /*overload*/mb_substr(
$wkt,
17,
/*overload*/mb_strlen($wkt) - 19
);
$multilinestirng
= /*overload*/
mb_substr(
$wkt,
17,
/*overload*/
mb_strlen($wkt) - 19
);
// Separate each linestring
$linestirngs = explode("),(", $multilinestirng);
$params[$index]['MULTILINESTRING']['no_of_lines'] = count($linestirngs);
@ -388,6 +467,7 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
}
$j++;
}
return $params;
}
}

View File

@ -6,7 +6,11 @@
* @package PhpMyAdmin-GIS
*/
if (! defined('PHPMYADMIN')) {
namespace PMA\libraries\gis;
use TCPDF;
if (!defined('PHPMYADMIN')) {
exit;
}
@ -15,7 +19,7 @@ if (! defined('PHPMYADMIN')) {
*
* @package PhpMyAdmin-GIS
*/
class PMA_GIS_Multipoint extends PMA_GIS_Geometry
class GISMultipoint extends GISGeometry
{
// Hold the singleton instance of the class
private static $_instance;
@ -32,7 +36,7 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
/**
* Returns the singleton.
*
* @return PMA_GIS_Multipoint the singleton
* @return GISMultipoint the singleton
* @access public
*/
public static function singleton()
@ -56,11 +60,15 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
public function scaleRow($spatial)
{
// Trim to remove leading 'MULTIPOINT(' and trailing ')'
$multipoint = /*overload*/mb_substr(
$spatial,
11,
/*overload*/mb_strlen($spatial) - 12
);
$multipoint
= /*overload*/
mb_substr(
$spatial,
11,
/*overload*/
mb_strlen($spatial) - 12
);
return $this->setMinMax($multipoint, array());
}
@ -76,22 +84,35 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
* @return object the modified image object
* @access public
*/
public function prepareRowAsPng($spatial, $label, $point_color,
$scale_data, $image
public function prepareRowAsPng(
$spatial,
$label,
$point_color,
$scale_data,
$image
) {
// allocate colors
$black = imagecolorallocate($image, 0, 0, 0);
$red = hexdec(/*overload*/mb_substr($point_color, 1, 2));
$green = hexdec(/*overload*/mb_substr($point_color, 3, 2));
$blue = hexdec(/*overload*/mb_substr($point_color, 4, 2));
$red = hexdec(/*overload*/
mb_substr($point_color, 1, 2)
);
$green = hexdec(/*overload*/
mb_substr($point_color, 3, 2)
);
$blue = hexdec(/*overload*/
mb_substr($point_color, 4, 2)
);
$color = imagecolorallocate($image, $red, $green, $blue);
// Trim to remove leading 'MULTIPOINT(' and trailing ')'
$multipoint = /*overload*/mb_substr(
$spatial,
11,
/*overload*/mb_strlen($spatial) - 12
);
$multipoint
= /*overload*/
mb_substr(
$spatial,
11,
/*overload*/
mb_strlen($spatial) - 12
);
$points_arr = $this->extractPoints($multipoint, $scale_data);
foreach ($points_arr as $point) {
@ -105,9 +126,15 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
&& ($points_arr[0][0] != '' && $points_arr[0][1] != '')
) {
imagestring(
$image, 1, $points_arr[0][0], $points_arr[0][1], trim($label), $black
$image,
1,
$points_arr[0][0],
$points_arr[0][1],
trim($label),
$black
);
}
return $image;
}
@ -123,21 +150,34 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
* @return TCPDF the modified TCPDF instance
* @access public
*/
public function prepareRowAsPdf($spatial, $label, $point_color,
$scale_data, $pdf
public function prepareRowAsPdf(
$spatial,
$label,
$point_color,
$scale_data,
$pdf
) {
// allocate colors
$red = hexdec(/*overload*/mb_substr($point_color, 1, 2));
$green = hexdec(/*overload*/mb_substr($point_color, 3, 2));
$blue = hexdec(/*overload*/mb_substr($point_color, 4, 2));
$line = array('width' => 1.25, 'color' => array($red, $green, $blue));
$red = hexdec(/*overload*/
mb_substr($point_color, 1, 2)
);
$green = hexdec(/*overload*/
mb_substr($point_color, 3, 2)
);
$blue = hexdec(/*overload*/
mb_substr($point_color, 4, 2)
);
$line = array('width' => 1.25, 'color' => array($red, $green, $blue));
// Trim to remove leading 'MULTIPOINT(' and trailing ')'
$multipoint = /*overload*/mb_substr(
$spatial,
11,
/*overload*/mb_strlen($spatial) - 12
);
$multipoint
= /*overload*/
mb_substr(
$spatial,
11,
/*overload*/
mb_strlen($spatial) - 12
);
$points_arr = $this->extractPoints($multipoint, $scale_data);
foreach ($points_arr as $point) {
@ -154,6 +194,7 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
$pdf->SetFontSize(5);
$pdf->Cell(0, 0, trim($label));
}
return $pdf;
}
@ -171,19 +212,22 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
public function prepareRowAsSvg($spatial, $label, $point_color, $scale_data)
{
$point_options = array(
'name' => $label,
'class' => 'multipoint vector',
'fill' => 'white',
'stroke' => $point_color,
'stroke-width'=> 2,
'name' => $label,
'class' => 'multipoint vector',
'fill' => 'white',
'stroke' => $point_color,
'stroke-width' => 2,
);
// Trim to remove leading 'MULTIPOINT(' and trailing ')'
$multipoint = /*overload*/mb_substr(
$spatial,
11,
/*overload*/mb_strlen($spatial) - 12
);
$multipoint
= /*overload*/
mb_substr(
$spatial,
11,
/*overload*/
mb_strlen($spatial) - 12
);
$points_arr = $this->extractPoints($multipoint, $scale_data);
$row = '';
@ -215,8 +259,12 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
* @return string JavaScript related to a row in the GIS dataset
* @access public
*/
public function prepareRowAsOl($spatial, $srid, $label,
$point_color, $scale_data
public function prepareRowAsOl(
$spatial,
$srid,
$label,
$point_color,
$scale_data
) {
$style_options = array(
'pointRadius' => 3,
@ -233,17 +281,21 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
$result = $this->getBoundsForOl($srid, $scale_data);
// Trim to remove leading 'MULTIPOINT(' and trailing ')'
$multipoint = /*overload*/mb_substr(
$spatial,
11,
/*overload*/mb_strlen($spatial) - 12
);
$multipoint
= /*overload*/
mb_substr(
$spatial,
11,
/*overload*/
mb_strlen($spatial) - 12
);
$points_arr = $this->extractPoints($multipoint, null);
$result .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
. 'new OpenLayers.Geometry.MultiPoint('
. $this->getPointsArrayForOpenLayers($points_arr, $srid)
. '), null, ' . json_encode($style_options) . '));';
return $result;
}
@ -267,15 +319,22 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
$wkt = 'MULTIPOINT(';
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'] : '')
&& trim($gis_data[$index]['MULTIPOINT'][$i]['x']) != '')
? $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'] : '') . ',';
&& trim($gis_data[$index]['MULTIPOINT'][$i]['y']) != '')
? $gis_data[$index]['MULTIPOINT'][$i]['y'] : '') . ',';
}
$wkt = /*overload*/mb_substr($wkt, 0, /*overload*/mb_strlen($wkt) - 1);
$wkt
= /*overload*/
mb_substr(
$wkt,
0, /*overload*/
mb_strlen($wkt) - 1
);
$wkt .= ')';
return $wkt;
}
@ -295,8 +354,15 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
. $row_data['points'][$i]['y'] . ',';
}
$wkt = /*overload*/mb_substr($wkt, 0, /*overload*/mb_strlen($wkt) - 1);
$wkt
= /*overload*/
mb_substr(
$wkt,
0, /*overload*/
mb_strlen($wkt) - 1
);
$wkt .= ')';
return $wkt;
}
@ -314,7 +380,7 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
$params = array();
if ($index == -1) {
$index = 0;
$data = PMA_GIS_Geometry::generateParams($value);
$data = GISGeometry::generateParams($value);
$params['srid'] = $data['srid'];
$wkt = $data['wkt'];
} else {
@ -323,7 +389,13 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
}
// Trim to remove leading 'MULTIPOINT(' and trailing ')'
$points = /*overload*/mb_substr($wkt, 11, /*overload*/mb_strlen($wkt) - 12);
$points
= /*overload*/
mb_substr(
$wkt,
11, /*overload*/
mb_strlen($wkt) - 12
);
$points_arr = $this->extractPoints($points, null);
$no_of_points = count($points_arr);
@ -355,9 +427,15 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
}
}
$olArrayLength = /*overload*/mb_strlen($ol_array);
if (/*overload*/mb_substr($ol_array, $olArrayLength - 2) == ', ') {
$ol_array = /*overload*/mb_substr($ol_array, 0, $olArrayLength - 2);
$olArrayLength
= /*overload*/
mb_strlen($ol_array);
if (/*overload*/
mb_substr($ol_array, $olArrayLength - 2) == ', '
) {
$ol_array
= /*overload*/
mb_substr($ol_array, 0, $olArrayLength - 2);
}
$ol_array .= ')';

View File

@ -6,7 +6,11 @@
* @package PhpMyAdmin-GIS
*/
if (! defined('PHPMYADMIN')) {
namespace PMA\libraries\gis;
use TCPDF;
if (!defined('PHPMYADMIN')) {
exit;
}
@ -15,7 +19,7 @@ if (! defined('PHPMYADMIN')) {
*
* @package PhpMyAdmin-GIS
*/
class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
class GISMultipolygon extends GISGeometry
{
// Hold the singleton instance of the class
private static $_instance;
@ -32,7 +36,7 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
/**
* Returns the singleton.
*
* @return PMA_GIS_Multipolygon the singleton
* @return GISMultipolygon the singleton
* @access public
*/
public static function singleton()
@ -58,17 +62,22 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
$min_max = array();
// Trim to remove leading 'MULTIPOLYGON(((' and trailing ')))'
$multipolygon = /*overload*/mb_substr(
$spatial,
15,
/*overload*/mb_strlen($spatial) - 18
);
$multipolygon
= /*overload*/
mb_substr(
$spatial,
15,
/*overload*/
mb_strlen($spatial) - 18
);
// Separate each polygon
$polygons = explode(")),((", $multipolygon);
foreach ($polygons as $polygon) {
// If the polygon doesn't have an inner ring, use polygon itself
if (/*overload*/mb_strpos($polygon, "),(") === false) {
if (/*overload*/
mb_strpos($polygon, "),(") === false
) {
$ring = $polygon;
} else {
// Separate outer ring and use it to determine min-max
@ -93,29 +102,44 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
* @return object the modified image object
* @access public
*/
public function prepareRowAsPng($spatial, $label, $fill_color,
$scale_data, $image
public function prepareRowAsPng(
$spatial,
$label,
$fill_color,
$scale_data,
$image
) {
// allocate colors
$black = imagecolorallocate($image, 0, 0, 0);
$red = hexdec(/*overload*/mb_substr($fill_color, 1, 2));
$green = hexdec(/*overload*/mb_substr($fill_color, 3, 2));
$blue = hexdec(/*overload*/mb_substr($fill_color, 4, 2));
$red = hexdec(/*overload*/
mb_substr($fill_color, 1, 2)
);
$green = hexdec(/*overload*/
mb_substr($fill_color, 3, 2)
);
$blue = hexdec(/*overload*/
mb_substr($fill_color, 4, 2)
);
$color = imagecolorallocate($image, $red, $green, $blue);
// Trim to remove leading 'MULTIPOLYGON(((' and trailing ')))'
$multipolygon = /*overload*/mb_substr(
$spatial,
15,
/*overload*/mb_strlen($spatial) - 18
);
$multipolygon
= /*overload*/
mb_substr(
$spatial,
15,
/*overload*/
mb_strlen($spatial) - 18
);
// Separate each polygon
$polygons = explode(")),((", $multipolygon);
$first_poly = true;
foreach ($polygons as $polygon) {
// If the polygon doesn't have an inner polygon
if (/*overload*/mb_strpos($polygon, "),(") === false) {
if (/*overload*/
mb_strpos($polygon, "),(") === false
) {
$points_arr = $this->extractPoints($polygon, $scale_data, true);
} else {
// Separate outer and inner polygons
@ -143,9 +167,15 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
// print label if applicable
if (isset($label_point)) {
imagestring(
$image, 1, $points_arr[2], $points_arr[3], trim($label), $black
$image,
1,
$points_arr[2],
$points_arr[3],
trim($label),
$black
);
}
return $image;
}
@ -164,24 +194,35 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
public function prepareRowAsPdf($spatial, $label, $fill_color, $scale_data, $pdf)
{
// allocate colors
$red = hexdec(/*overload*/mb_substr($fill_color, 1, 2));
$green = hexdec(/*overload*/mb_substr($fill_color, 3, 2));
$blue = hexdec(/*overload*/mb_substr($fill_color, 4, 2));
$red = hexdec(/*overload*/
mb_substr($fill_color, 1, 2)
);
$green = hexdec(/*overload*/
mb_substr($fill_color, 3, 2)
);
$blue = hexdec(/*overload*/
mb_substr($fill_color, 4, 2)
);
$color = array($red, $green, $blue);
// Trim to remove leading 'MULTIPOLYGON(((' and trailing ')))'
$multipolygon = /*overload*/mb_substr(
$spatial,
15,
/*overload*/mb_strlen($spatial) - 18
);
$multipolygon
= /*overload*/
mb_substr(
$spatial,
15,
/*overload*/
mb_strlen($spatial) - 18
);
// Separate each polygon
$polygons = explode(")),((", $multipolygon);
$first_poly = true;
foreach ($polygons as $polygon) {
// If the polygon doesn't have an inner polygon
if (/*overload*/mb_strpos($polygon, "),(") === false) {
if (/*overload*/
mb_strpos($polygon, "),(") === false
) {
$points_arr = $this->extractPoints($polygon, $scale_data, true);
} else {
// Separate outer and inner polygons
@ -213,6 +254,7 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
$pdf->SetFontSize(5);
$pdf->Cell(0, 0, trim($label));
}
return $pdf;
}
@ -230,23 +272,26 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
public function prepareRowAsSvg($spatial, $label, $fill_color, $scale_data)
{
$polygon_options = array(
'name' => $label,
'class' => 'multipolygon vector',
'stroke' => 'black',
'stroke-width'=> 0.5,
'fill' => $fill_color,
'fill-rule' => 'evenodd',
'fill-opacity'=> 0.8,
'name' => $label,
'class' => 'multipolygon vector',
'stroke' => 'black',
'stroke-width' => 0.5,
'fill' => $fill_color,
'fill-rule' => 'evenodd',
'fill-opacity' => 0.8,
);
$row = '';
// Trim to remove leading 'MULTIPOLYGON(((' and trailing ')))'
$multipolygon = /*overload*/mb_substr(
$spatial,
15,
/*overload*/mb_strlen($spatial) - 18
);
$multipolygon
= /*overload*/
mb_substr(
$spatial,
15,
/*overload*/
mb_strlen($spatial) - 18
);
// Separate each polygon
$polygons = explode(")),((", $multipolygon);
@ -254,7 +299,9 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
$row .= '<path d="';
// If the polygon doesn't have an inner polygon
if (/*overload*/mb_strpos($polygon, "),(") === false) {
if (/*overload*/
mb_strpos($polygon, "),(") === false
) {
$row .= $this->_drawPath($polygon, $scale_data);
} else {
// Separate outer and inner polygons
@ -308,11 +355,14 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
$row = $this->getBoundsForOl($srid, $scale_data);
// Trim to remove leading 'MULTIPOLYGON(((' and trailing ')))'
$multipolygon = /*overload*/mb_substr(
$spatial,
15,
/*overload*/mb_strlen($spatial) - 18
);
$multipolygon
= /*overload*/
mb_substr(
$spatial,
15,
/*overload*/
mb_strlen($spatial) - 18
);
// Separate each polygon
$polygons = explode(")),((", $multipolygon);
@ -320,6 +370,7 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
. 'new OpenLayers.Geometry.MultiPolygon('
. $this->getPolygonArrayForOpenLayers($polygons, $srid)
. '), null, ' . json_encode($style_options) . '));';
return $row;
}
@ -383,24 +434,40 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
$wkt .= '(';
for ($j = 0; $j < $no_of_points; $j++) {
$wkt .= ((isset($data_row[$k][$i][$j]['x'])
&& trim($data_row[$k][$i][$j]['x']) != '')
? $data_row[$k][$i][$j]['x'] : $empty)
&& trim($data_row[$k][$i][$j]['x']) != '')
? $data_row[$k][$i][$j]['x'] : $empty)
. ' ' . ((isset($data_row[$k][$i][$j]['y'])
&& trim($data_row[$k][$i][$j]['y']) != '')
? $data_row[$k][$i][$j]['y'] : $empty) . ',';
&& trim($data_row[$k][$i][$j]['y']) != '')
? $data_row[$k][$i][$j]['y'] : $empty) . ',';
}
$wkt = /*overload*/mb_substr(
$wkt,
0,
/*overload*/mb_strlen($wkt) - 1
);
$wkt
= /*overload*/
mb_substr(
$wkt,
0,
/*overload*/
mb_strlen($wkt) - 1
);
$wkt .= '),';
}
$wkt = /*overload*/mb_substr($wkt, 0, /*overload*/mb_strlen($wkt) - 1);
$wkt
= /*overload*/
mb_substr(
$wkt,
0, /*overload*/
mb_strlen($wkt) - 1
);
$wkt .= '),';
}
$wkt = /*overload*/mb_substr($wkt, 0, /*overload*/mb_strlen($wkt) - 1);
$wkt
= /*overload*/
mb_substr(
$wkt,
0, /*overload*/
mb_strlen($wkt) - 1
);
$wkt .= ')';
return $wkt;
}
@ -417,17 +484,16 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
// Determines whether each line ring is an inner ring or an outer ring.
// If it's an inner ring get a point on the surface which can be used to
// correctly classify inner rings to their respective outer rings.
include_once './libraries/gis/GIS_Polygon.class.php';
foreach ($row_data['parts'] as $i => $ring) {
$row_data['parts'][$i]['isOuter']
= PMA_GIS_Polygon::isOuterRing($ring['points']);
= GISPolygon::isOuterRing($ring['points']);
}
// Find points on surface for inner rings
foreach ($row_data['parts'] as $i => $ring) {
if (! $ring['isOuter']) {
if (!$ring['isOuter']) {
$row_data['parts'][$i]['pointOnSurface']
= PMA_GIS_Polygon::getPointOnSurface($ring['points']);
= GISPolygon::getPointOnSurface($ring['points']);
}
}
@ -443,10 +509,12 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
// If the pointOnSurface of the inner ring
// is also inside the outer ring
if (PMA_GIS_Polygon::isPointInsidePolygon(
$ring1['pointOnSurface'], $ring2['points']
)) {
if (! isset($ring2['inner'])) {
if (GISPolygon::isPointInsidePolygon(
$ring1['pointOnSurface'],
$ring2['points']
)
) {
if (!isset($ring2['inner'])) {
$row_data['parts'][$k]['inner'] = array();
}
$row_data['parts'][$k]['inner'][] = $j;
@ -467,7 +535,13 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
foreach ($ring['points'] as $point) {
$wkt .= $point['x'] . ' ' . $point['y'] . ',';
}
$wkt = /*overload*/mb_substr($wkt, 0, /*overload*/mb_strlen($wkt) - 1);
$wkt
= /*overload*/
mb_substr(
$wkt,
0, /*overload*/
mb_strlen($wkt) - 1
);
$wkt .= ')'; // end of outer ring
// inner rings if any
@ -477,18 +551,27 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
foreach ($row_data['parts'][$j]['points'] as $innerPoint) {
$wkt .= $innerPoint['x'] . ' ' . $innerPoint['y'] . ',';
}
$wkt = /*overload*/mb_substr(
$wkt,
0,
/*overload*/mb_strlen($wkt) - 1
);
$wkt
= /*overload*/
mb_substr(
$wkt,
0,
/*overload*/
mb_strlen($wkt) - 1
);
$wkt .= ')'; // end of inner ring
}
}
$wkt .= '),'; // end of polygon
}
$wkt = /*overload*/mb_substr($wkt, 0, /*overload*/mb_strlen($wkt) - 1);
$wkt
= /*overload*/
mb_substr(
$wkt,
0, /*overload*/
mb_strlen($wkt) - 1
);
$wkt .= ')'; // end of multipolygon
return $wkt;
@ -508,7 +591,7 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
$params = array();
if ($index == -1) {
$index = 0;
$data = PMA_GIS_Geometry::generateParams($value);
$data = GISGeometry::generateParams($value);
$params['srid'] = $data['srid'];
$wkt = $data['wkt'];
} else {
@ -517,11 +600,14 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
}
// Trim to remove leading 'MULTIPOLYGON(((' and trailing ')))'
$multipolygon = /*overload*/mb_substr(
$wkt,
15,
/*overload*/mb_strlen($wkt) - 18
);
$multipolygon
= /*overload*/
mb_substr(
$wkt,
15,
/*overload*/
mb_strlen($wkt) - 18
);
// Separate each polygon
$polygons = explode(")),((", $multipolygon);
@ -531,7 +617,9 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
$k = 0;
foreach ($polygons as $polygon) {
// If the polygon doesn't have an inner polygon
if (/*overload*/mb_strpos($polygon, "),(") === false) {
if (/*overload*/
mb_strpos($polygon, "),(") === false
) {
$param_row[$k]['no_of_lines'] = 1;
$points_arr = $this->extractPoints($polygon, null);
$no_of_points = count($points_arr);
@ -558,6 +646,7 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
}
$k++;
}
return $params;
}
}

View File

@ -6,7 +6,11 @@
* @package PhpMyAdmin-GIS
*/
if (! defined('PHPMYADMIN')) {
namespace PMA\libraries\gis;
use TCPDF;
if (!defined('PHPMYADMIN')) {
exit;
}
@ -15,7 +19,7 @@ if (! defined('PHPMYADMIN')) {
*
* @package PhpMyAdmin-GIS
*/
class PMA_GIS_Point extends PMA_GIS_Geometry
class GISPoint extends GISGeometry
{
// Hold the singleton instance of the class
private static $_instance;
@ -32,7 +36,7 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
/**
* Returns the singleton.
*
* @return PMA_GIS_Point the singleton
* @return GISPoint the singleton
* @access public
*/
public static function singleton()
@ -56,11 +60,15 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
public function scaleRow($spatial)
{
// Trim to remove leading 'POINT(' and trailing ')'
$point = /*overload*/mb_substr(
$spatial,
6,
/*overload*/mb_strlen($spatial) - 7
);
$point
= /*overload*/
mb_substr(
$spatial,
6,
/*overload*/
mb_strlen($spatial) - 7
);
return $this->setMinMax($point, array());
}
@ -76,37 +84,62 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
* @return object the modified image object
* @access public
*/
public function prepareRowAsPng($spatial, $label, $point_color,
$scale_data, $image
public function prepareRowAsPng(
$spatial,
$label,
$point_color,
$scale_data,
$image
) {
// allocate colors
$black = imagecolorallocate($image, 0, 0, 0);
$red = hexdec(/*overload*/mb_substr($point_color, 1, 2));
$green = hexdec(/*overload*/mb_substr($point_color, 3, 2));
$blue = hexdec(/*overload*/mb_substr($point_color, 4, 2));
$red = hexdec(/*overload*/
mb_substr($point_color, 1, 2)
);
$green = hexdec(/*overload*/
mb_substr($point_color, 3, 2)
);
$blue = hexdec(/*overload*/
mb_substr($point_color, 4, 2)
);
$color = imagecolorallocate($image, $red, $green, $blue);
// Trim to remove leading 'POINT(' and trailing ')'
$point = /*overload*/mb_substr(
$spatial,
6,
/*overload*/mb_strlen($spatial) - 7
);
$point
= /*overload*/
mb_substr(
$spatial,
6,
/*overload*/
mb_strlen($spatial) - 7
);
$points_arr = $this->extractPoints($point, $scale_data);
// draw a small circle to mark the point
if ($points_arr[0][0] != '' && $points_arr[0][1] != '') {
imagearc(
$image, $points_arr[0][0], $points_arr[0][1], 7, 7, 0, 360, $color
$image,
$points_arr[0][0],
$points_arr[0][1],
7,
7,
0,
360,
$color
);
// print label if applicable
if (isset($label) && trim($label) != '') {
imagestring(
$image, 1, $points_arr[0][0],
$points_arr[0][1], trim($label), $black
$image,
1,
$points_arr[0][0],
$points_arr[0][1],
trim($label),
$black
);
}
}
return $image;
}
@ -122,27 +155,46 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
* @return TCPDF the modified TCPDF instance
* @access public
*/
public function prepareRowAsPdf($spatial, $label, $point_color,
$scale_data, $pdf
public function prepareRowAsPdf(
$spatial,
$label,
$point_color,
$scale_data,
$pdf
) {
// allocate colors
$red = hexdec(/*overload*/mb_substr($point_color, 1, 2));
$green = hexdec(/*overload*/mb_substr($point_color, 3, 2));
$blue = hexdec(/*overload*/mb_substr($point_color, 4, 2));
$line = array('width' => 1.25, 'color' => array($red, $green, $blue));
$red = hexdec(/*overload*/
mb_substr($point_color, 1, 2)
);
$green = hexdec(/*overload*/
mb_substr($point_color, 3, 2)
);
$blue = hexdec(/*overload*/
mb_substr($point_color, 4, 2)
);
$line = array('width' => 1.25, 'color' => array($red, $green, $blue));
// Trim to remove leading 'POINT(' and trailing ')'
$point = /*overload*/mb_substr(
$spatial,
6,
/*overload*/mb_strlen($spatial) - 7
);
$point
= /*overload*/
mb_substr(
$spatial,
6,
/*overload*/
mb_strlen($spatial) - 7
);
$points_arr = $this->extractPoints($point, $scale_data);
// draw a small circle to mark the point
if ($points_arr[0][0] != '' && $points_arr[0][1] != '') {
$pdf->Circle(
$points_arr[0][0], $points_arr[0][1], 2, 0, 360, 'D', $line
$points_arr[0][0],
$points_arr[0][1],
2,
0,
360,
'D',
$line
);
// print label if applicable
if (isset($label) && trim($label) != '') {
@ -151,6 +203,7 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
$pdf->Cell(0, 0, trim($label));
}
}
return $pdf;
}
@ -168,20 +221,23 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
public function prepareRowAsSvg($spatial, $label, $point_color, $scale_data)
{
$point_options = array(
'name' => $label,
'id' => $label . rand(),
'class' => 'point vector',
'fill' => 'white',
'stroke' => $point_color,
'stroke-width'=> 2,
'name' => $label,
'id' => $label . rand(),
'class' => 'point vector',
'fill' => 'white',
'stroke' => $point_color,
'stroke-width' => 2,
);
// Trim to remove leading 'POINT(' and trailing ')'
$point = /*overload*/mb_substr(
$spatial,
6,
/*overload*/mb_strlen($spatial) - 7
);
$point
= /*overload*/
mb_substr(
$spatial,
6,
/*overload*/
mb_strlen($spatial) - 7
);
$points_arr = $this->extractPoints($point, $scale_data);
$row = '';
@ -210,8 +266,12 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
* @return string JavaScript related to a row in the GIS dataset
* @access public
*/
public function prepareRowAsOl($spatial, $srid, $label,
$point_color, $scale_data
public function prepareRowAsOl(
$spatial,
$srid,
$label,
$point_color,
$scale_data
) {
$style_options = array(
'pointRadius' => 3,
@ -228,11 +288,14 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
$result = $this->getBoundsForOl($srid, $scale_data);
// Trim to remove leading 'POINT(' and trailing ')'
$point = /*overload*/mb_substr(
$spatial,
6,
/*overload*/mb_strlen($spatial) - 7
);
$point
= /*overload*/
mb_substr(
$spatial,
6,
/*overload*/
mb_strlen($spatial) - 7
);
$points_arr = $this->extractPoints($point, null);
if ($points_arr[0][0] != '' && $points_arr[0][1] != '') {
@ -240,6 +303,7 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
. $this->getPointForOpenLayers($points_arr[0], $srid) . ', null, '
. json_encode($style_options) . '));';
}
return $result;
}
@ -255,14 +319,14 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
*/
public function generateWkt($gis_data, $index, $empty = '')
{
return 'POINT('
. ((isset($gis_data[$index]['POINT']['x'])
&& trim($gis_data[$index]['POINT']['x']) != '')
? $gis_data[$index]['POINT']['x'] : '')
. ' '
. ((isset($gis_data[$index]['POINT']['y'])
&& trim($gis_data[$index]['POINT']['y']) != '')
? $gis_data[$index]['POINT']['y'] : '') . ')';
return 'POINT('
. ((isset($gis_data[$index]['POINT']['x'])
&& trim($gis_data[$index]['POINT']['x']) != '')
? $gis_data[$index]['POINT']['x'] : '')
. ' '
. ((isset($gis_data[$index]['POINT']['y'])
&& trim($gis_data[$index]['POINT']['y']) != '')
? $gis_data[$index]['POINT']['y'] : '') . ')';
}
/**
@ -276,7 +340,7 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
public function getShape($row_data)
{
return 'POINT(' . (isset($row_data['x']) ? $row_data['x'] : '')
. ' ' . (isset($row_data['y']) ? $row_data['y'] : '') . ')';
. ' ' . (isset($row_data['y']) ? $row_data['y'] : '') . ')';
}
/**
@ -293,7 +357,7 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
$params = array();
if ($index == -1) {
$index = 0;
$data = PMA_GIS_Geometry::generateParams($value);
$data = GISGeometry::generateParams($value);
$params['srid'] = $data['srid'];
$wkt = $data['wkt'];
} else {
@ -302,7 +366,13 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
}
// Trim to remove leading 'POINT(' and trailing ')'
$point = /*overload*/mb_substr($wkt, 6, /*overload*/mb_strlen($wkt) - 7);
$point
= /*overload*/
mb_substr(
$wkt,
6, /*overload*/
mb_strlen($wkt) - 7
);
$points_arr = $this->extractPoints($point, null);
$params[$index]['POINT']['x'] = $points_arr[0][0];

View File

@ -6,7 +6,12 @@
* @package PhpMyAdmin-GIS
*/
if (! defined('PHPMYADMIN')) {
namespace PMA\libraries\gis;
use PMA;
use TCPDF;
if (!defined('PHPMYADMIN')) {
exit;
}
@ -15,7 +20,7 @@ if (! defined('PHPMYADMIN')) {
*
* @package PhpMyAdmin-GIS
*/
class PMA_GIS_Polygon extends PMA_GIS_Geometry
class GISPolygon extends GISGeometry
{
// Hold the singleton instance of the class
private static $_instance;
@ -32,7 +37,7 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
/**
* Returns the singleton.
*
* @return PMA_GIS_Polygon the singleton
* @return GISPolygon the singleton
* @access public
*/
public static function singleton()
@ -56,20 +61,26 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
public function scaleRow($spatial)
{
// Trim to remove leading 'POLYGON((' and trailing '))'
$polygon = /*overload*/mb_substr(
$spatial,
9,
/*overload*/mb_strlen($spatial) - 11
);
$polygon
= /*overload*/
mb_substr(
$spatial,
9,
/*overload*/
mb_strlen($spatial) - 11
);
// If the polygon doesn't have an inner ring, use polygon itself
if (/*overload*/mb_strpos($polygon, "),(") === false) {
if (/*overload*/
mb_strpos($polygon, "),(") === false
) {
$ring = $polygon;
} else {
// Separate outer ring and use it to determine min-max
$parts = explode("),(", $polygon);
$ring = $parts[0];
}
return $this->setMinMax($ring, array());
}
@ -85,25 +96,40 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
* @return object the modified image object
* @access public
*/
public function prepareRowAsPng($spatial, $label, $fill_color,
$scale_data, $image
public function prepareRowAsPng(
$spatial,
$label,
$fill_color,
$scale_data,
$image
) {
// allocate colors
$black = imagecolorallocate($image, 0, 0, 0);
$red = hexdec(/*overload*/mb_substr($fill_color, 1, 2));
$green = hexdec(/*overload*/mb_substr($fill_color, 3, 2));
$blue = hexdec(/*overload*/mb_substr($fill_color, 4, 2));
$red = hexdec(/*overload*/
mb_substr($fill_color, 1, 2)
);
$green = hexdec(/*overload*/
mb_substr($fill_color, 3, 2)
);
$blue = hexdec(/*overload*/
mb_substr($fill_color, 4, 2)
);
$color = imagecolorallocate($image, $red, $green, $blue);
// Trim to remove leading 'POLYGON((' and trailing '))'
$polygon = /*overload*/mb_substr(
$spatial,
9,
/*overload*/mb_strlen($spatial) - 11
);
$polygon
= /*overload*/
mb_substr(
$spatial,
9,
/*overload*/
mb_strlen($spatial) - 11
);
// If the polygon doesn't have an inner polygon
if (/*overload*/mb_strpos($polygon, "),(") === false) {
if (/*overload*/
mb_strpos($polygon, "),(") === false
) {
$points_arr = $this->extractPoints($polygon, $scale_data, true);
} else {
// Separate outer and inner polygons
@ -115,7 +141,8 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
foreach ($inner as $inner_poly) {
$points_arr = array_merge(
$points_arr, $this->extractPoints($inner_poly, $scale_data, true)
$points_arr,
$this->extractPoints($inner_poly, $scale_data, true)
);
}
}
@ -125,9 +152,15 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
// print label if applicable
if (isset($label) && trim($label) != '') {
imagestring(
$image, 1, $points_arr[2], $points_arr[3], trim($label), $black
$image,
1,
$points_arr[2],
$points_arr[3],
trim($label),
$black
);
}
return $image;
}
@ -146,20 +179,31 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
public function prepareRowAsPdf($spatial, $label, $fill_color, $scale_data, $pdf)
{
// allocate colors
$red = hexdec(/*overload*/mb_substr($fill_color, 1, 2));
$green = hexdec(/*overload*/mb_substr($fill_color, 3, 2));
$blue = hexdec(/*overload*/mb_substr($fill_color, 4, 2));
$red = hexdec(/*overload*/
mb_substr($fill_color, 1, 2)
);
$green = hexdec(/*overload*/
mb_substr($fill_color, 3, 2)
);
$blue = hexdec(/*overload*/
mb_substr($fill_color, 4, 2)
);
$color = array($red, $green, $blue);
// Trim to remove leading 'POLYGON((' and trailing '))'
$polygon = /*overload*/mb_substr(
$spatial,
9,
/*overload*/mb_strlen($spatial) - 11
);
$polygon
= /*overload*/
mb_substr(
$spatial,
9,
/*overload*/
mb_strlen($spatial) - 11
);
// If the polygon doesn't have an inner polygon
if (/*overload*/mb_strpos($polygon, "),(") === false) {
if (/*overload*/
mb_strpos($polygon, "),(") === false
) {
$points_arr = $this->extractPoints($polygon, $scale_data, true);
} else {
// Separate outer and inner polygons
@ -171,7 +215,8 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
foreach ($inner as $inner_poly) {
$points_arr = array_merge(
$points_arr, $this->extractPoints($inner_poly, $scale_data, true)
$points_arr,
$this->extractPoints($inner_poly, $scale_data, true)
);
}
}
@ -184,6 +229,7 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
$pdf->SetFontSize(5);
$pdf->Cell(0, 0, trim($label));
}
return $pdf;
}
@ -201,27 +247,32 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
public function prepareRowAsSvg($spatial, $label, $fill_color, $scale_data)
{
$polygon_options = array(
'name' => $label,
'id' => $label . rand(),
'class' => 'polygon vector',
'stroke' => 'black',
'stroke-width'=> 0.5,
'fill' => $fill_color,
'fill-rule' => 'evenodd',
'fill-opacity'=> 0.8,
'name' => $label,
'id' => $label . rand(),
'class' => 'polygon vector',
'stroke' => 'black',
'stroke-width' => 0.5,
'fill' => $fill_color,
'fill-rule' => 'evenodd',
'fill-opacity' => 0.8,
);
// Trim to remove leading 'POLYGON((' and trailing '))'
$polygon = /*overload*/mb_substr(
$spatial,
9,
/*overload*/mb_strlen($spatial) - 11
);
$polygon
= /*overload*/
mb_substr(
$spatial,
9,
/*overload*/
mb_strlen($spatial) - 11
);
$row = '<path d="';
// If the polygon doesn't have an inner polygon
if (/*overload*/mb_strpos($polygon, "),(") === false) {
if (/*overload*/
mb_strpos($polygon, "),(") === false
) {
$row .= $this->_drawPath($polygon, $scale_data);
} else {
// Separate outer and inner polygons
@ -241,6 +292,7 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
$row .= ' ' . $option . '="' . trim($val) . '"';
}
$row .= '/>';
return $row;
}
@ -273,17 +325,21 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
$row = $this->getBoundsForOl($srid, $scale_data);
// Trim to remove leading 'POLYGON((' and trailing '))'
$polygon = /*overload*/mb_substr(
$spatial,
9,
/*overload*/mb_strlen($spatial) - 11
);
$polygon
= /*overload*/
mb_substr(
$spatial,
9,
/*overload*/
mb_strlen($spatial) - 11
);
// Separate outer and inner polygons
$parts = explode("),(", $polygon);
$row .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
. $this->getPolygonForOpenLayers($parts, $srid)
. ', null, ' . json_encode($style_options) . '));';
return $row;
}
@ -338,17 +394,30 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
$wkt .= '(';
for ($j = 0; $j < $no_of_points; $j++) {
$wkt .= ((isset($gis_data[$index]['POLYGON'][$i][$j]['x'])
&& trim($gis_data[$index]['POLYGON'][$i][$j]['x']) != '')
? $gis_data[$index]['POLYGON'][$i][$j]['x'] : $empty)
&& trim($gis_data[$index]['POLYGON'][$i][$j]['x']) != '')
? $gis_data[$index]['POLYGON'][$i][$j]['x'] : $empty)
. ' ' . ((isset($gis_data[$index]['POLYGON'][$i][$j]['y'])
&& trim($gis_data[$index]['POLYGON'][$i][$j]['y']) != '')
? $gis_data[$index]['POLYGON'][$i][$j]['y'] : $empty) . ',';
&& trim($gis_data[$index]['POLYGON'][$i][$j]['y']) != '')
? $gis_data[$index]['POLYGON'][$i][$j]['y'] : $empty) . ',';
}
$wkt = /*overload*/mb_substr($wkt, 0, /*overload*/mb_strlen($wkt) - 1);
$wkt
= /*overload*/
mb_substr(
$wkt,
0, /*overload*/
mb_strlen($wkt) - 1
);
$wkt .= '),';
}
$wkt = /*overload*/mb_substr($wkt, 0, /*overload*/mb_strlen($wkt) - 1);
$wkt
= /*overload*/
mb_substr(
$wkt,
0, /*overload*/
mb_strlen($wkt) - 1
);
$wkt .= ')';
return $wkt;
}
@ -403,9 +472,10 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
{
// If area is negative then it's in clockwise orientation,
// i.e. it's an outer ring
if (PMA_GIS_Polygon::area($ring) < 0) {
if (GISPolygon::area($ring) < 0) {
return true;
}
return false;
}
@ -464,7 +534,7 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
}
if ($counter % 2 == 0) {
return false;
return false;
} else {
return true;
}
@ -493,7 +563,7 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
}
}
if (! isset($x0)) {
if (!isset($x0)) {
return false;
}
@ -507,7 +577,8 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
PMA\libraries\Util::pow(($y1 - $y0), 2)
+ PMA\libraries\Util::pow(($x0 - $x1), 2)
);
$pointA = array(); $pointB = array();
$pointA = array();
$pointB = array();
while (true) {
// Get the points on either sides of the line
@ -520,11 +591,11 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
// One of the points should be inside the polygon,
// unless epsilon chosen is too large
if (PMA_GIS_Polygon::isPointInsidePolygon($pointA, $ring)) {
if (GISPolygon::isPointInsidePolygon($pointA, $ring)) {
return $pointA;
}
if (PMA_GIS_Polygon::isPointInsidePolygon($pointB, $ring)) {
if (GISPolygon::isPointInsidePolygon($pointB, $ring)) {
return $pointB;
}
@ -550,7 +621,7 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
$params = array();
if ($index == -1) {
$index = 0;
$data = PMA_GIS_Geometry::generateParams($value);
$data = GISGeometry::generateParams($value);
$params['srid'] = $data['srid'];
$wkt = $data['wkt'];
} else {
@ -559,7 +630,13 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
}
// Trim to remove leading 'POLYGON((' and trailing '))'
$polygon = /*overload*/mb_substr($wkt, 9, /*overload*/mb_strlen($wkt) - 11);
$polygon
= /*overload*/
mb_substr(
$wkt,
9, /*overload*/
mb_strlen($wkt) - 11
);
// Separate each linestring
$linerings = explode("),(", $polygon);
$params[$index]['POLYGON']['no_of_lines'] = count($linerings);
@ -575,6 +652,7 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
}
$j++;
}
return $params;
}
}

View File

@ -6,7 +6,12 @@
* @package PhpMyAdmin-GIS
*/
if (! defined('PHPMYADMIN')) {
namespace PMA\libraries\gis;
use PMA;
use TCPDF;
if (!defined('PHPMYADMIN')) {
exit;
}
@ -17,48 +22,44 @@ require_once 'libraries/sql.lib.php';
*
* @package PhpMyAdmin-GIS
*/
class PMA_GIS_Visualization
class GISVisualization
{
/**
* @var array Raw data for the visualization
*/
private $_data;
private $_modified_sql;
/**
* @var array Set of default settings values are here.
*/
private $_settings = array(
// Array of colors to be used for GIS visualizations.
'colors' => array(
'#B02EE0',
'#E0642E',
'#E0D62E',
'#2E97E0',
'#BCE02E',
'#E02E75',
'#5CE02E',
'#E0B02E',
'#0022E0',
'#726CB1',
'#481A36',
'#BAC658',
'#127224',
'#825119',
'#238C74',
'#4C489B',
'#87C9BF',
),
// The width of the GIS visualization.
'width' => 600,
// The height of the GIS visualization.
'height' => 450,
);
private $_settings
= array(
// Array of colors to be used for GIS visualizations.
'colors' => array(
'#B02EE0',
'#E0642E',
'#E0D62E',
'#2E97E0',
'#BCE02E',
'#E02E75',
'#5CE02E',
'#E0B02E',
'#0022E0',
'#726CB1',
'#481A36',
'#BAC658',
'#127224',
'#825119',
'#238C74',
'#4C489B',
'#87C9BF',
),
// The width of the GIS visualization.
'width' => 600,
// The height of the GIS visualization.
'height' => 450,
);
/**
* @var array Options that the user has specified.
*/
@ -83,13 +84,13 @@ class PMA_GIS_Visualization
* @param integer $row number of rows
* @param integer $pos start position
*
* @return PMA_GIS_Visualization
* @return GISVisualization
*
* @access public
*/
public static function get($sql_query, $options, $row, $pos)
{
return new PMA_GIS_Visualization($sql_query, $options, $row, $pos);
return new GISVisualization($sql_query, $options, $row, $pos);
}
/**
@ -99,11 +100,11 @@ class PMA_GIS_Visualization
* ignored
* @param array $options Users specified options
*
* @return PMA_GIS_Visualization
* @return GISVisualization
*/
public static function getByData($data, $options)
{
return new PMA_GIS_Visualization(null, $options, null, null, $data);
return new GISVisualization(null, $options, null, null, $data);
}
/**
@ -118,6 +119,7 @@ class PMA_GIS_Visualization
return true;
}
}
return false;
}
@ -142,7 +144,6 @@ class PMA_GIS_Visualization
$this->_modified_sql = $this->_modifySqlQuery($sql_query, $row, $pos);
$this->_data = $this->_fetchRawData();
}
}
/**
@ -169,15 +170,17 @@ class PMA_GIS_Visualization
{
$modified_query = 'SELECT ';
// If label column is chosen add it to the query
if (! empty($this->_userSpecifiedSettings['labelColumn'])) {
if (!empty($this->_userSpecifiedSettings['labelColumn'])) {
$modified_query .= PMA\libraries\Util::backquote(
$this->_userSpecifiedSettings['labelColumn']
)
. ', ';
$this->_userSpecifiedSettings['labelColumn']
)
. ', ';
}
// Wrap the spatial column with 'ASTEXT()' function and add it
$modified_query .= 'ASTEXT('
. PMA\libraries\Util::backquote($this->_userSpecifiedSettings['spatialColumn'])
. PMA\libraries\Util::backquote(
$this->_userSpecifiedSettings['spatialColumn']
)
. ') AS ' . PMA\libraries\Util::backquote(
$this->_userSpecifiedSettings['spatialColumn']
)
@ -185,7 +188,9 @@ class PMA_GIS_Visualization
// Get the SRID
$modified_query .= 'SRID('
. PMA\libraries\Util::backquote($this->_userSpecifiedSettings['spatialColumn'])
. PMA\libraries\Util::backquote(
$this->_userSpecifiedSettings['spatialColumn']
)
. ') AS ' . PMA\libraries\Util::backquote('srid') . ' ';
// Append the original query as the inner query
@ -231,7 +236,7 @@ class PMA_GIS_Visualization
*/
private function _handleOptions()
{
if (! is_null($this->_userSpecifiedSettings)) {
if (!is_null($this->_userSpecifiedSettings)) {
$this->_settings = array_merge(
$this->_settings,
$this->_userSpecifiedSettings
@ -254,15 +259,25 @@ class PMA_GIS_Visualization
// Check if the user already added extension;
// get the substring where the extension would be if it was included
$extension_start_pos = /*overload*/mb_strlen($file_name)
- /*overload*/mb_strlen($ext) - 1;
$user_extension = /*overload*/mb_substr(
$file_name, $extension_start_pos, /*overload*/mb_strlen($file_name)
);
$extension_start_pos
= /*overload*/
mb_strlen($file_name)
- /*overload*/
mb_strlen($ext) - 1;
$user_extension
= /*overload*/
mb_substr(
$file_name,
$extension_start_pos, /*overload*/
mb_strlen($file_name)
);
$required_extension = "." . $ext;
if (/*overload*/mb_strtolower($user_extension) != $required_extension) {
$file_name .= $required_extension;
if (/*overload*/
mb_strtolower($user_extension) != $required_extension
) {
$file_name .= $required_extension;
}
return $file_name;
}
@ -292,8 +307,8 @@ class PMA_GIS_Visualization
{
$this->init();
$output = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . "\n";
$output .= '<svg version="1.1" xmlns:svg="http://www.w3.org/2000/svg"'
$output = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' . "\n";
$output .= '<svg version="1.1" xmlns:svg="http://www.w3.org/2000/svg"'
. ' xmlns="http://www.w3.org/2000/svg"'
. ' width="' . $this->_settings['width'] . '"'
. ' height="' . $this->_settings['height'] . '">';
@ -317,6 +332,7 @@ class PMA_GIS_Visualization
public function asSVG()
{
$output = $this->_svg();
return $output;
}
@ -354,8 +370,12 @@ class PMA_GIS_Visualization
// fill the background
$bg = imagecolorallocate($image, 229, 229, 229);
imagefilledrectangle(
$image, 0, 0, $this->_settings['width'] - 1,
$this->_settings['height'] - 1, $bg
$image,
0,
0,
$this->_settings['width'] - 1,
$this->_settings['height'] - 1,
$bg
);
$scale_data = $this->_scaleDataSet($this->_data);
@ -383,6 +403,7 @@ class PMA_GIS_Visualization
// base64 encode
$encoded = base64_encode($output);
return '<img src="data:image/png;base64,' . $encoded . '" />';
}
@ -414,15 +435,15 @@ class PMA_GIS_Visualization
$scale_data = $this->_scaleDataSet($this->_data);
$output
= 'var options = {'
. 'projection: new OpenLayers.Projection("EPSG:900913"),'
. 'displayProjection: new OpenLayers.Projection("EPSG:4326"),'
. 'units: "m",'
. 'numZoomLevels: 18,'
. 'maxResolution: 156543.0339,'
. 'maxExtent: new OpenLayers.Bounds('
. '-20037508, -20037508, 20037508, 20037508),'
. 'restrictedExtent: new OpenLayers.Bounds('
. '-20037508, -20037508, 20037508, 20037508)'
. 'projection: new OpenLayers.Projection("EPSG:900913"),'
. 'displayProjection: new OpenLayers.Projection("EPSG:4326"),'
. 'units: "m",'
. 'numZoomLevels: 18,'
. 'maxResolution: 156543.0339,'
. 'maxExtent: new OpenLayers.Bounds('
. '-20037508, -20037508, 20037508, 20037508),'
. 'restrictedExtent: new OpenLayers.Bounds('
. '-20037508, -20037508, 20037508, 20037508)'
. '};'
. 'var map = new OpenLayers.Map("openlayersmap", options);'
. 'var layerNone = new OpenLayers.Layer.Boxes('
@ -433,14 +454,14 @@ class PMA_GIS_Visualization
. 'var vectorLayer = new OpenLayers.Layer.Vector("Data");'
. 'var bound;';
$output .= $this->_prepareDataSet($this->_data, $scale_data, 'ol', '');
$output .=
'map.addLayer(vectorLayer);'
$output .= 'map.addLayer(vectorLayer);'
. 'map.zoomToExtent(bound);'
. 'if (map.getZoom() < 2) {'
. 'map.zoomTo(2);'
. 'map.zoomTo(2);'
. '}'
. 'map.addControl(new OpenLayers.Control.LayerSwitcher());'
. 'map.addControl(new OpenLayers.Control.MousePosition());';
return $output;
}
@ -538,11 +559,15 @@ class PMA_GIS_Visualization
// Figure out the data type
$ref_data = $row[$this->_settings['spatialColumn']];
$type_pos = /*overload*/mb_stripos($ref_data, '(');
$type = /*overload*/mb_substr($ref_data, 0, $type_pos);
$type_pos
= /*overload*/
mb_stripos($ref_data, '(');
$type
= /*overload*/
mb_substr($ref_data, 0, $type_pos);
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {
$gis_obj = GISFactory::factory($type);
if (!$gis_obj) {
continue;
}
$scale_data = $gis_obj->scaleRow(
@ -550,23 +575,23 @@ class PMA_GIS_Visualization
);
// Update minimum/maximum values for x and y coordinates.
$c_maxX = (float) $scale_data['maxX'];
if (! isset($min_max['maxX']) || $c_maxX > $min_max['maxX']) {
$c_maxX = (float)$scale_data['maxX'];
if (!isset($min_max['maxX']) || $c_maxX > $min_max['maxX']) {
$min_max['maxX'] = $c_maxX;
}
$c_minX = (float) $scale_data['minX'];
if (! isset($min_max['minX']) || $c_minX < $min_max['minX']) {
$c_minX = (float)$scale_data['minX'];
if (!isset($min_max['minX']) || $c_minX < $min_max['minX']) {
$min_max['minX'] = $c_minX;
}
$c_maxY = (float) $scale_data['maxY'];
if (! isset($min_max['maxY']) || $c_maxY > $min_max['maxY']) {
$c_maxY = (float)$scale_data['maxY'];
if (!isset($min_max['maxY']) || $c_maxY > $min_max['maxY']) {
$min_max['maxY'] = $c_maxY;
}
$c_minY = (float) $scale_data['minY'];
if (! isset($min_max['minY']) || $c_minY < $min_max['minY']) {
$c_minY = (float)$scale_data['minY'];
if (!isset($min_max['minY']) || $c_minY < $min_max['minY']) {
$min_max['minY'] = $c_minY;
}
}
@ -587,7 +612,7 @@ class PMA_GIS_Visualization
// fit horizontally
$x = $min_max['minX'] - ($border / $scale);
// center vertically
$y =($min_max['maxY'] + $min_max['minY'] - $plot_height / $scale) / 2;
$y = ($min_max['maxY'] + $min_max['minY'] - $plot_height / $scale) / 2;
}
return array(
@ -624,11 +649,15 @@ class PMA_GIS_Visualization
// Figure out the data type
$ref_data = $row[$this->_settings['spatialColumn']];
$type_pos = /*overload*/mb_stripos($ref_data, '(');
$type = /*overload*/mb_substr($ref_data, 0, $type_pos);
$type_pos
= /*overload*/
mb_stripos($ref_data, '(');
$type
= /*overload*/
mb_substr($ref_data, 0, $type_pos);
$gis_obj = PMA_GIS_Factory::factory($type);
if (! $gis_obj) {
$gis_obj = GISFactory::factory($type);
if (!$gis_obj) {
continue;
}
$label = '';
@ -640,27 +669,39 @@ class PMA_GIS_Visualization
if ($format == 'svg') {
$results .= $gis_obj->prepareRowAsSvg(
$row[$this->_settings['spatialColumn']], $label,
$this->_settings['colors'][$index], $scale_data
$row[$this->_settings['spatialColumn']],
$label,
$this->_settings['colors'][$index],
$scale_data
);
} elseif ($format == 'png') {
$results = $gis_obj->prepareRowAsPng(
$row[$this->_settings['spatialColumn']], $label,
$this->_settings['colors'][$index], $scale_data, $results
$row[$this->_settings['spatialColumn']],
$label,
$this->_settings['colors'][$index],
$scale_data,
$results
);
} elseif ($format == 'pdf') {
$results = $gis_obj->prepareRowAsPdf(
$row[$this->_settings['spatialColumn']], $label,
$this->_settings['colors'][$index], $scale_data, $results
$row[$this->_settings['spatialColumn']],
$label,
$this->_settings['colors'][$index],
$scale_data,
$results
);
} elseif ($format == 'ol') {
$results .= $gis_obj->prepareRowAsOl(
$row[$this->_settings['spatialColumn']], $row['srid'],
$label, $this->_settings['colors'][$index], $scale_data
$row[$this->_settings['spatialColumn']],
$row['srid'],
$label,
$this->_settings['colors'][$index],
$scale_data
);
}
$color_number++;
}
return $results;
}

View File

@ -11,11 +11,11 @@ namespace PMA\libraries\plugins\import;
use PMA\libraries\properties\plugins\ImportPluginProperties;
use PMA;
use PMA\libraries\plugins\ImportPlugin;
use PMA_GIS_Factory;
use PMA_GIS_Multilinestring;
use PMA_GIS_Multipoint;
use PMA_GIS_Point;
use PMA_GIS_Polygon;
use PMA\libraries\gis\GISFactory;
use PMA\libraries\gis\GISMultilinestring;
use PMA\libraries\gis\GISMultipoint;
use PMA\libraries\gis\GISPoint;
use PMA\libraries\gis\GISPolygon;
use PMA\libraries\plugins\import\ShapeFile;
if (!defined('PHPMYADMIN')) {
@ -215,9 +215,8 @@ class ImportShp extends ImportPlugin
}
if (isset($gis_type)) {
include_once './libraries/gis/GIS_Factory.class.php';
/** @var PMA_GIS_Multilinestring|PMA_GIS_Multipoint|PMA_GIS_Point|PMA_GIS_Polygon $gis_obj */
$gis_obj = PMA_GIS_Factory::factory($gis_type);
/** @var GISMultilinestring|\PMA\libraries\gis\GISMultipoint|\PMA\libraries\gis\GISPoint|GISPolygon $gis_obj */
$gis_obj = GISFactory::factory($gis_type);
} else {
$gis_obj = null;
}

View File

@ -1,26 +1,14 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Test for PMA_GIS_Factory
* Test for PMA\libraries\gis\GISFactory
*
* @package PhpMyAdmin-test
*/
require_once 'libraries/gis/GIS_Geometry.class.php';
require_once 'libraries/gis/GIS_Linestring.class.php';
require_once 'libraries/gis/GIS_Multilinestring.class.php';
require_once 'libraries/gis/GIS_Point.class.php';
require_once 'libraries/gis/GIS_Multipoint.class.php';
require_once 'libraries/gis/GIS_Polygon.class.php';
require_once 'libraries/gis/GIS_Multipolygon.class.php';
require_once 'libraries/gis/GIS_Geometrycollection.class.php';
/*
* Include to test
*/
require_once 'libraries/gis/GIS_Factory.class.php';
use PMA\libraries\gis\GISFactory;
/**
* Test class for PMA_GIS_Factory
* Test class for PMA\libraries\gis\GISFactory
*
* @package PhpMyAdmin-test
*/
@ -38,7 +26,7 @@ class PMA_GIS_FactoryTest extends PHPUnit_Framework_TestCase
*/
public function testFactory($type, $geom)
{
$this->assertInstanceOf($geom, PMA_GIS_Factory::factory($type));
$this->assertInstanceOf($geom, GISFactory::factory($type));
}
/**
@ -51,31 +39,31 @@ class PMA_GIS_FactoryTest extends PHPUnit_Framework_TestCase
return array(
array(
'MULTIPOLYGON',
'PMA_GIS_Multipolygon'
'PMA\libraries\gis\GISMultipolygon'
),
array(
'POLYGON',
'PMA_GIS_Polygon'
'PMA\libraries\gis\GISPolygon'
),
array(
'MULTILINESTRING',
'PMA_GIS_Multilinestring'
'PMA\libraries\gis\GISMultilinestring'
),
array(
'LINESTRING',
'PMA_GIS_Linestring'
'PMA\libraries\gis\GISLinestring'
),
array(
'MULTIPOINT',
'PMA_GIS_Multipoint'
'PMA\libraries\gis\GISMultipoint'
),
array(
'POINT',
'PMA_GIS_Point'
'PMA\libraries\gis\GISPoint'
),
array(
'GEOMETRYCOLLECTION',
'PMA_GIS_Geometrycollection'
'PMA\libraries\gis\GISGeometrycollection'
),
);
}

View File

@ -6,8 +6,6 @@
* @package PhpMyAdmin-test
*/
require_once 'libraries/gis/GIS_Geometry.class.php';
/**
* Abstract parent class for all PMA_GIS_<Geom_type> test classes
*

View File

@ -1,15 +1,13 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Test for PMA_GIS_Geometry
* Test for PMA\libraries\gis\GISGeometry
*
* @package PhpMyAdmin-test
*/
require_once 'libraries/gis/GIS_Geometry.class.php';
/**
* Tests for PMA_GIS_Geometry class
* Tests for PMA\libraries\gis\GISGeometry class
*
* @package PhpMyAdmin-test
*/
@ -29,7 +27,7 @@ class PMA_GIS_GeometryTest extends PHPUnit_Framework_TestCase
*/
protected function setUp()
{
$this->object = $this->getMockForAbstractClass('PMA_GIS_Geometry');
$this->object = $this->getMockForAbstractClass('PMA\libraries\gis\GISGeometry');
}
/**
@ -54,7 +52,7 @@ class PMA_GIS_GeometryTest extends PHPUnit_Framework_TestCase
*/
private function _callProtectedFunction($name, $params)
{
$class = new ReflectionClass('PMA_GIS_Geometry');
$class = new ReflectionClass('PMA\libraries\gis\GISGeometry');
$method = $class->getMethod($name);
$method->setAccessible(true);
return $method->invokeArgs($this->object, $params);

View File

@ -2,17 +2,14 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Test for PMA_GIS_Geometry
* Test for PMA\libraries\gis\GISGeometry
*
* @package PhpMyAdmin-test
*/
require_once 'libraries/gis/GIS_Geometry.class.php';
require_once 'libraries/gis/GIS_Geometrycollection.class.php';
require_once 'libraries/gis/GIS_Factory.class.php';
require_once 'libraries/tcpdf/tcpdf.php';
use PMA\libraries\gis\GISGeometrycollection;
/**
* Tests for PMA_GIS_Geometrycollection class
* Tests for PMA\libraries\gis\GISGeometrycollection class
*
* @package PhpMyAdmin-test
*/
@ -33,7 +30,7 @@ class PMA_GIS_GeometryCollectionTest extends PHPUnit_Framework_TestCase
*/
protected function setUp()
{
$this->object = PMA_GIS_Geometrycollection::singleton();
$this->object = GISGeometrycollection::singleton();
}
/**

View File

@ -1,25 +1,25 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Test for PMA_GIS_Linestring
* Test for PMA\libraries\gis\GISLinestring
*
* @package PhpMyAdmin-test
*/
use PMA\libraries\gis\GISLinestring;
require_once 'PMA_GIS_Geom_test.php';
require_once 'libraries/gis/GIS_Geometry.class.php';
require_once 'libraries/gis/GIS_Linestring.class.php';
require_once 'libraries/tcpdf/tcpdf.php';
/**
* Tests for PMA_GIS_Linestring class
* Tests for PMA\libraries\gis\GISLinestring class
*
* @package PhpMyAdmin-test
*/
class PMA_GIS_LinestringTest extends PMA_GIS_GeomTest
{
/**
* @var PMA_GIS_Linestring
* @var GISLinestring
* @access protected
*/
protected $object;
@ -33,7 +33,7 @@ class PMA_GIS_LinestringTest extends PMA_GIS_GeomTest
*/
protected function setUp()
{
$this->object = PMA_GIS_Linestring::singleton();
$this->object = GISLinestring::singleton();
}
/**

View File

@ -1,25 +1,25 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Test for PMA_GIS_Multilinestring
* Test for PMA\libraries\gis\GISMultilinestring
*
* @package PhpMyAdmin-test
*/
use PMA\libraries\gis\GISMultilinestring;
require_once 'PMA_GIS_Geom_test.php';
require_once 'libraries/gis/GIS_Geometry.class.php';
require_once 'libraries/gis/GIS_Multilinestring.class.php';
require_once 'libraries/tcpdf/tcpdf.php';
/**
* Tests for PMA_GIS_Multilinestring class
* Tests for PMA\libraries\gis\GISMultilinestring class
*
* @package PhpMyAdmin-test
*/
class PMA_GIS_MultilinestringTest extends PMA_GIS_GeomTest
{
/**
* @var PMA_GIS_Multilinestring
* @var GISMultilinestring
* @access protected
*/
protected $object;
@ -33,7 +33,7 @@ class PMA_GIS_MultilinestringTest extends PMA_GIS_GeomTest
*/
protected function setUp()
{
$this->object = PMA_GIS_Multilinestring::singleton();
$this->object = GISMultilinestring::singleton();
}
/**

View File

@ -1,25 +1,25 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Test for PMA_GIS_Multipoint
* Test for PMA\libraries\gis\GISMultipoint
*
* @package PhpMyAdmin-test
*/
use PMA\libraries\gis\GISMultipoint;
require_once 'PMA_GIS_Geom_test.php';
require_once 'libraries/gis/GIS_Geometry.class.php';
require_once 'libraries/gis/GIS_Multipoint.class.php';
require_once 'libraries/tcpdf/tcpdf.php';
/**
* Tests for PMA_GIS_Multipoint class
* Tests for PMA\libraries\gis\GISMultipoint class
*
* @package PhpMyAdmin-test
*/
class PMA_GIS_MultipointTest extends PMA_GIS_GeomTest
{
/**
* @var PMA_GIS_Multipoint
* @var GISMultipoint
* @access protected
*/
protected $object;
@ -33,7 +33,7 @@ class PMA_GIS_MultipointTest extends PMA_GIS_GeomTest
*/
protected function setUp()
{
$this->object = PMA_GIS_Multipoint::singleton();
$this->object = GISMultipoint::singleton();
}
/**

View File

@ -1,26 +1,26 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Test for PMA_GIS_Multipolygon
* Test for PMA\libraries\gis\GISMultipolygon
*
* @package PhpMyAdmin-test
*/
use PMA\libraries\gis\GISMultipolygon;
require_once 'PMA_GIS_Geom_test.php';
require_once 'libraries/gis/GIS_Geometry.class.php';
require_once 'libraries/gis/GIS_Multipolygon.class.php';
require_once 'libraries/tcpdf/tcpdf.php';
/**
* Tests for PMA_GIS_Multipolygon class
* Tests for PMA\libraries\gis\GISMultipolygon class
*
* @package PhpMyAdmin-test
*/
class PMA_GIS_MultipolygonTest extends PMA_GIS_GeomTest
{
/**
* @var PMA_GIS_Multipolygon
* @var GISMultipolygon
* @access protected
*/
protected $object;
@ -34,7 +34,7 @@ class PMA_GIS_MultipolygonTest extends PMA_GIS_GeomTest
*/
protected function setUp()
{
$this->object = PMA_GIS_Multipolygon::singleton();
$this->object = GISMultipolygon::singleton();
}
/**

View File

@ -1,25 +1,25 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Test for PMA_GIS_Point
* Test for PMA\libraries\gis\GISPoint
*
* @package PhpMyAdmin-test
*/
use PMA\libraries\gis\GISPoint;
require_once 'PMA_GIS_Geom_test.php';
require_once 'libraries/gis/GIS_Geometry.class.php';
require_once 'libraries/gis/GIS_Point.class.php';
require_once 'libraries/tcpdf/tcpdf.php';
/**
* Tests for PMA_GIS_Point class.
* Tests for PMA\libraries\gis\GISPoint class.
*
* @package PhpMyAdmin-test
*/
class PMA_GIS_PointTest extends PMA_GIS_GeomTest
{
/**
* @var PMA_GIS_Point
* @var GISPoint
* @access protected
*/
protected $object;
@ -33,7 +33,7 @@ class PMA_GIS_PointTest extends PMA_GIS_GeomTest
*/
protected function setUp()
{
$this->object = PMA_GIS_Point::singleton();
$this->object = GISPoint::singleton();
}
/**

View File

@ -1,26 +1,25 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Test for PMA_GIS_Polygon
* Test for PMA\libraries\gis\GISPolygon
*
* @package PhpMyAdmin-test
*/
use PMA\libraries\gis\GISPolygon;
require_once 'PMA_GIS_Geom_test.php';
require_once 'libraries/gis/GIS_Geometry.class.php';
require_once 'libraries/gis/GIS_Polygon.class.php';
require_once 'libraries/tcpdf/tcpdf.php';
/**
* Tests for PMA_GIS_Polygon class
* Tests for PMA\libraries\gis\GISPolygon class
*
* @package PhpMyAdmin-test
*/
class PMA_GIS_PolygonTest extends PMA_GIS_GeomTest
{
/**
* @var PMA_GIS_Polygon
* @var GISPolygon
* @access protected
*/
protected $object;
@ -34,7 +33,7 @@ class PMA_GIS_PolygonTest extends PMA_GIS_GeomTest
*/
protected function setUp()
{
$this->object = PMA_GIS_Polygon::singleton();
$this->object = GISPolygon::singleton();
}
/**