You've already forked phpmyadmin
mirror of
https://github.com/phpmyadmin/phpmyadmin.git
synced 2026-10-29 21:24:44 +03:00
OpenStreetMaps now zoom correctly.
This commit is contained in:
@@ -40,6 +40,23 @@ abstract class PMA_GIS_Geometry
|
||||
*/
|
||||
public abstract function scaleRow($spatial);
|
||||
|
||||
/**
|
||||
* Returns OpenLayers.Bounds object that correspond to the bounds of GIS data.
|
||||
*
|
||||
* @param string $srid Spatial reference ID
|
||||
* @param array $scale_data Data related to scaling
|
||||
*
|
||||
* @return OpenLayers.Bounds object that correspond to the bounds of GIS data
|
||||
*/
|
||||
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()));';
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the min, max values with the given point set.
|
||||
*
|
||||
|
||||
@@ -167,14 +167,15 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
|
||||
/**
|
||||
* Prepares the code related to a row in the GIS dataset to visualize it with OpenLayers.
|
||||
*
|
||||
* @param string $spatial GIS GEOMETRYCOLLECTION object
|
||||
* @param int $srid Spatial reference ID
|
||||
* @param string $label Label for the GIS GEOMETRYCOLLECTION object
|
||||
* @param string $color Color for the GIS GEOMETRYCOLLECTION object
|
||||
* @param string $spatial GIS GEOMETRYCOLLECTION object
|
||||
* @param int $srid Spatial reference ID
|
||||
* @param string $label Label for the GIS GEOMETRYCOLLECTION object
|
||||
* @param string $color Color for the GIS GEOMETRYCOLLECTION object
|
||||
* @param array $scale_data Array containing data related to scaling
|
||||
*
|
||||
* @return the code related to a row in the GIS dataset
|
||||
*/
|
||||
public function prepareRowAsOl($spatial, $srid, $label, $color)
|
||||
public function prepareRowAsOl($spatial, $srid, $label, $color, $scale_data)
|
||||
{
|
||||
$row = '';
|
||||
|
||||
@@ -188,7 +189,7 @@ class PMA_GIS_Geometrycollection extends PMA_GIS_Geometry
|
||||
$type = substr($sub_part, 0, $type_pos);
|
||||
|
||||
$gis_obj = PMA_GIS_Factory::factory($type);
|
||||
$row .= $gis_obj->prepareRowAsOl($sub_part, $srid, $label, $color);
|
||||
$row .= $gis_obj->prepareRowAsOl($sub_part, $srid, $label, $color, $scale_data);
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
@@ -160,10 +160,11 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
|
||||
* @param int $srid Spatial reference ID
|
||||
* @param string $label Label for the GIS LINESTRING object
|
||||
* @param string $line_color Color for the GIS LINESTRING object
|
||||
* @param array $scale_data Array containing data related to scaling
|
||||
*
|
||||
* @return the code related to a row in the GIS dataset
|
||||
*/
|
||||
public function prepareRowAsOl($spatial, $srid, $label, $line_color)
|
||||
public function prepareRowAsOl($spatial, $srid, $label, $line_color, $scale_data)
|
||||
{
|
||||
$style_options = array(
|
||||
'strokeColor' => $line_color,
|
||||
@@ -174,6 +175,8 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
|
||||
if ($srid == 0) {
|
||||
$srid = 4326;
|
||||
}
|
||||
$result = $this->getBoundsForOl($srid, $scale_data);
|
||||
|
||||
// Trim to remove leading 'LINESTRING(' and trailing ')'
|
||||
$linesrting = substr($spatial, 11, (strlen($spatial) - 12));
|
||||
$points_arr = $this->extractPoints($linesrting, null);
|
||||
@@ -186,9 +189,10 @@ class PMA_GIS_Linestring extends PMA_GIS_Geometry
|
||||
$row = substr($row, 0, strlen($row) - 2);
|
||||
$row .= ')';
|
||||
|
||||
return 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
|
||||
$result .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
|
||||
. 'new OpenLayers.Geometry.LineString(' . $row . '), null, '
|
||||
. json_encode($style_options) . '));';
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -185,10 +185,11 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
|
||||
* @param int $srid Spatial reference ID
|
||||
* @param string $label Label for the GIS MULTILINESTRING object
|
||||
* @param string $line_color Color for the GIS MULTILINESTRING object
|
||||
* @param array $scale_data Array containing data related to scaling
|
||||
*
|
||||
* @return the code related to a row in the GIS dataset
|
||||
*/
|
||||
public function prepareRowAsOl($spatial, $srid, $label, $line_color)
|
||||
public function prepareRowAsOl($spatial, $srid, $label, $line_color, $scale_data)
|
||||
{
|
||||
$style_options = array(
|
||||
'strokeColor' => $line_color,
|
||||
@@ -199,12 +200,14 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
|
||||
if ($srid == 0) {
|
||||
$srid = 4326;
|
||||
}
|
||||
$row = $this->getBoundsForOl($srid, $scale_data);
|
||||
|
||||
// Trim to remove leading 'MULTILINESTRING((' and trailing '))'
|
||||
$multilinestirng = substr($spatial, 17, (strlen($spatial) - 19));
|
||||
// Seperate each linestring
|
||||
$linestirngs = explode("),(", $multilinestirng);
|
||||
|
||||
$row = 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
|
||||
$row .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
|
||||
. 'new OpenLayers.Geometry.MultiLineString(new Array(';
|
||||
foreach ($linestirngs as $linestring) {
|
||||
$points_arr = $this->extractPoints($linestring, null);
|
||||
|
||||
@@ -149,10 +149,11 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
|
||||
* @param int $srid Spatial reference ID
|
||||
* @param string $label Label for the GIS MULTIPOINT object
|
||||
* @param string $point_color Color for the GIS MULTIPOINT object
|
||||
* @param array $scale_data Array containing data related to scaling
|
||||
*
|
||||
* @return the code related to a row in the GIS dataset
|
||||
*/
|
||||
public function prepareRowAsOl($spatial, $srid, $label, $point_color)
|
||||
public function prepareRowAsOl($spatial, $srid, $label, $point_color, $scale_data)
|
||||
{
|
||||
$style_options = array(
|
||||
'pointRadius' => 3,
|
||||
@@ -166,6 +167,8 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
|
||||
if ($srid == 0) {
|
||||
$srid = 4326;
|
||||
}
|
||||
$result = $this->getBoundsForOl($srid, $scale_data);
|
||||
|
||||
// Trim to remove leading 'MULTIPOINT(' and trailing ')'
|
||||
$multipoint = substr($spatial, 11, (strlen($spatial) - 12));
|
||||
$points_arr = $this->extractPoints($multipoint, null);
|
||||
@@ -178,9 +181,10 @@ class PMA_GIS_Multipoint extends PMA_GIS_Geometry
|
||||
$row = substr($row, 0, strlen($row) - 2);
|
||||
$row .= ')';
|
||||
|
||||
return 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
|
||||
$result .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
|
||||
. 'new OpenLayers.Geometry.MultiPoint(' . $row . '), null, '
|
||||
. json_encode($style_options) . '));';
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -229,10 +229,11 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
|
||||
* @param int $srid Spatial reference ID
|
||||
* @param string $label Label for the GIS MULTIPOLYGON object
|
||||
* @param string $fill_color Color for the GIS MULTIPOLYGON object
|
||||
* @param array $scale_data Array containing data related to scaling
|
||||
*
|
||||
* @return the code related to a row in the GIS dataset
|
||||
*/
|
||||
public function prepareRowAsOl($spatial, $srid, $label, $fill_color)
|
||||
public function prepareRowAsOl($spatial, $srid, $label, $fill_color, $scale_data)
|
||||
{
|
||||
$style_options = array(
|
||||
'strokeColor' => '#000000',
|
||||
@@ -245,12 +246,14 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
|
||||
if ($srid == 0) {
|
||||
$srid = 4326;
|
||||
}
|
||||
$row = $this->getBoundsForOl($srid, $scale_data);
|
||||
|
||||
// Trim to remove leading 'MULTIPOLYGON(((' and trailing ')))'
|
||||
$multipolygon = substr($spatial, 15, (strlen($spatial) - 18));
|
||||
// Seperate each polygon
|
||||
$polygons = explode(")),((", $multipolygon);
|
||||
|
||||
$row = 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
|
||||
$row .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
|
||||
. 'new OpenLayers.Geometry.MultiPolygon(new Array(';
|
||||
|
||||
foreach ($polygons as $polygon) {
|
||||
|
||||
@@ -142,10 +142,11 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
|
||||
* @param int $srid Spatial reference ID
|
||||
* @param string $label Label for the GIS POINT object
|
||||
* @param string $point_color Color for the GIS POINT object
|
||||
* @param array $scale_data Array containing data related to scaling
|
||||
*
|
||||
* @return the code related to a row in the GIS dataset
|
||||
*/
|
||||
public function prepareRowAsOl($spatial, $srid, $label, $point_color)
|
||||
public function prepareRowAsOl($spatial, $srid, $label, $point_color, $scale_data)
|
||||
{
|
||||
$style_options = array(
|
||||
'pointRadius' => 3,
|
||||
@@ -159,14 +160,17 @@ class PMA_GIS_Point extends PMA_GIS_Geometry
|
||||
if ($srid == 0) {
|
||||
$srid = 4326;
|
||||
}
|
||||
$result = $this->getBoundsForOl($srid, $scale_data);
|
||||
|
||||
// Trim to remove leading 'POINT(' and trailing ')'
|
||||
$point = substr($spatial, 6, (strlen($spatial) - 7));
|
||||
$points_arr = $this->extractPoints($point, null);
|
||||
|
||||
return 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector(('
|
||||
$result .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector(('
|
||||
. 'new OpenLayers.Geometry.Point(' . $points_arr[0][0] . ', ' . $points_arr[0][1] . ')'
|
||||
. '.transform(new OpenLayers.Projection("EPSG:' . $srid . '"), map.getProjectionObject())),'
|
||||
. ' null, ' . json_encode($style_options) . '));';
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -212,10 +212,11 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
|
||||
* @param int $srid Spatial reference ID
|
||||
* @param string $label Label for the GIS POLYGON object
|
||||
* @param string $fill_color Color for the GIS POLYGON object
|
||||
* @param array $scale_data Array containing data related to scaling
|
||||
*
|
||||
* @return the code related to a row in the GIS dataset
|
||||
*/
|
||||
public function prepareRowAsOl($spatial, $srid, $label, $fill_color)
|
||||
public function prepareRowAsOl($spatial, $srid, $label, $fill_color, $scale_data)
|
||||
{
|
||||
$style_options = array(
|
||||
'strokeColor' => '#000000',
|
||||
@@ -228,10 +229,12 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
|
||||
if ($srid == 0) {
|
||||
$srid = 4326;
|
||||
}
|
||||
$row = $this->getBoundsForOl($srid, $scale_data);
|
||||
|
||||
// Trim to remove leading 'POLYGON((' and trailing '))'
|
||||
$polygon = substr($spatial, 9, (strlen($spatial) - 11));
|
||||
|
||||
$row = 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
|
||||
$row .= 'vectorLayer.addFeatures(new OpenLayers.Feature.Vector('
|
||||
. 'new OpenLayers.Geometry.Polygon(new Array(';
|
||||
// If the polygon doesnt have an inner polygon
|
||||
if (strpos($polygon, "),(") === false) {
|
||||
|
||||
@@ -251,7 +251,8 @@ class PMA_GIS_Visualization
|
||||
public function asOl()
|
||||
{
|
||||
$this->init();
|
||||
$output = $this->_prepareDataSet($this->_data, 0, null, 'ol', '');
|
||||
$scale_data = $this->_scaleDataSet($this->_data);
|
||||
$output = $this->_prepareDataSet($this->_data, 0, $scale_data, 'ol', '');
|
||||
return $output;
|
||||
}
|
||||
|
||||
@@ -355,6 +356,10 @@ class PMA_GIS_Visualization
|
||||
'scale' => $scale,
|
||||
'x' => $x,
|
||||
'y' => $y,
|
||||
'minX' => $min_max['minX'],
|
||||
'maxX' => $min_max['maxX'],
|
||||
'minY' => $min_max['minY'],
|
||||
'maxY' => $min_max['maxY'],
|
||||
'height' => $this->_settings['height'],
|
||||
);
|
||||
}
|
||||
@@ -408,7 +413,7 @@ class PMA_GIS_Visualization
|
||||
} elseif ($format == 'ol') {
|
||||
$results .= $gis_obj->prepareRowAsOl(
|
||||
$row[$this->_settings['spatialColumn']], $row['srid'],
|
||||
$label, $this->_settings['colors'][$index]
|
||||
$label, $this->_settings['colors'][$index], $scale_data
|
||||
);
|
||||
}
|
||||
$color_number++;
|
||||
|
||||
@@ -52,7 +52,6 @@ if (PMA_isValid($_REQUEST['visualizationSettings'], 'array')) {
|
||||
$visualizationSettings = $_REQUEST['visualizationSettings'];
|
||||
}
|
||||
|
||||
// If label column is not set, use first non-geometric colum as label column
|
||||
if (! isset($visualizationSettings['labelColumn']) && isset($labelCandidates[0])) {
|
||||
$visualizationSettings['labelColumn'] = '';
|
||||
}
|
||||
@@ -144,10 +143,14 @@ if ($format == 'svg') {
|
||||
|
||||
// create a vector layer
|
||||
var vectorLayer = new OpenLayers.Layer.Vector("Data");
|
||||
var bound;
|
||||
<?php echo (PMA_GIS_visualization_results($data, $visualizationSettings, 'ol')); ?>
|
||||
map.addLayer(vectorLayer);
|
||||
|
||||
map.setCenter(new OpenLayers.LonLat(0, 0), 2);
|
||||
map.zoomToExtent(bound);
|
||||
if (map.getZoom() < 2) {
|
||||
map.zoomTo(2);
|
||||
}
|
||||
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||
map.addControl(new OpenLayers.Control.MousePosition());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user