Merge remote-tracking branch 'origin/master'

This commit is contained in:
Michal Čihař 2012-07-07 19:21:38 +02:00
commit 1d4d351703
4 changed files with 53 additions and 39 deletions

View File

@ -270,26 +270,28 @@ class PMA_GIS_Multilinestring extends PMA_GIS_Geometry
*/
public function generateWkt($gis_data, $index, $empty = '')
{
$no_of_lines = isset($gis_data[$index]['MULTILINESTRING']['no_of_lines'])
? $gis_data[$index]['MULTILINESTRING']['no_of_lines'] : 1;
$data_row = $gis_data[$index]['MULTILINESTRING'];
$no_of_lines = isset($data_row['no_of_lines'])
? $data_row['no_of_lines'] : 1;
if ($no_of_lines < 1) {
$no_of_lines = 1;
}
$wkt = 'MULTILINESTRING(';
for ($i = 0; $i < $no_of_lines; $i++) {
$no_of_points = isset($gis_data[$index]['MULTILINESTRING'][$i]['no_of_points'])
? $gis_data[$index]['MULTILINESTRING'][$i]['no_of_points'] : 2;
$no_of_points = isset($data_row[$i]['no_of_points'])
? $data_row[$i]['no_of_points'] : 2;
if ($no_of_points < 2) {
$no_of_points = 2;
}
$wkt .= '(';
for ($j = 0; $j < $no_of_points; $j++) {
$wkt .= ((isset($gis_data[$index]['MULTILINESTRING'][$i][$j]['x'])
&& trim($gis_data[$index]['MULTILINESTRING'][$i][$j]['x']) != '')
? $gis_data[$index]['MULTILINESTRING'][$i][$j]['x'] : $empty)
. ' ' . ((isset($gis_data[$index]['MULTILINESTRING'][$i][$j]['y'])
&& trim($gis_data[$index]['MULTILINESTRING'][$i][$j]['y']) != '')
? $gis_data[$index]['MULTILINESTRING'][$i][$j]['y'] : $empty) . ',';
$wkt .= ((isset($data_row[$i][$j]['x'])
&& 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) . ',';
}
$wkt = substr($wkt, 0, strlen($wkt) - 1);
$wkt .= '),';

View File

@ -338,33 +338,36 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
*/
public function generateWkt($gis_data, $index, $empty = '')
{
$no_of_polygons = isset($gis_data[$index]['MULTIPOLYGON']['no_of_polygons'])
? $gis_data[$index]['MULTIPOLYGON']['no_of_polygons'] : 1;
$data_row = $gis_data[$index]['MULTIPOLYGON'];
$no_of_polygons = isset($data_row['no_of_polygons'])
? $data_row['no_of_polygons'] : 1;
if ($no_of_polygons < 1) {
$no_of_polygons = 1;
}
$wkt = 'MULTIPOLYGON(';
for ($k = 0; $k < $no_of_polygons; $k++) {
$no_of_lines = isset($gis_data[$index]['MULTIPOLYGON'][$k]['no_of_lines'])
? $gis_data[$index]['MULTIPOLYGON'][$k]['no_of_lines'] : 1;
$no_of_lines = isset($data_row[$k]['no_of_lines'])
? $data_row[$k]['no_of_lines'] : 1;
if ($no_of_lines < 1) {
$no_of_lines = 1;
}
$wkt .= '(';
for ($i = 0; $i < $no_of_lines; $i++) {
$no_of_points = isset($gis_data[$index]['MULTIPOLYGON'][$k][$i]['no_of_points'])
? $gis_data[$index]['MULTIPOLYGON'][$k][$i]['no_of_points'] : 4;
$no_of_points = isset($data_row[$k][$i]['no_of_points'])
? $data_row[$k][$i]['no_of_points'] : 4;
if ($no_of_points < 4) {
$no_of_points = 4;
}
$wkt .= '(';
for ($j = 0; $j < $no_of_points; $j++) {
$wkt .= ((isset($gis_data[$index]['MULTIPOLYGON'][$k][$i][$j]['x'])
&& trim($gis_data[$index]['MULTIPOLYGON'][$k][$i][$j]['x']) != '')
? $gis_data[$index]['MULTIPOLYGON'][$k][$i][$j]['x'] : $empty)
. ' ' . ((isset($gis_data[$index]['MULTIPOLYGON'][$k][$i][$j]['y'])
&& trim($gis_data[$index]['MULTIPOLYGON'][$k][$i][$j]['y']) != '')
? $gis_data[$index]['MULTIPOLYGON'][$k][$i][$j]['y'] : $empty) .',';
$wkt .= ((isset($data_row[$k][$i][$j]['x'])
&& 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) .',';
}
$wkt = substr($wkt, 0, strlen($wkt) - 1);
$wkt .= '),';
@ -484,32 +487,34 @@ class PMA_GIS_Multipolygon extends PMA_GIS_Geometry
$multipolygon = substr($wkt, 15, (strlen($wkt) - 18));
// Seperate each polygon
$polygons = explode(")),((", $multipolygon);
$params[$index]['MULTIPOLYGON']['no_of_polygons'] = count($polygons);
$param_row =& $params[$index]['MULTIPOLYGON'];
$param_row['no_of_polygons'] = count($polygons);
$k = 0;
foreach ($polygons as $polygon) {
// If the polygon doesnt have an inner polygon
if (strpos($polygon, "),(") === false) {
$params[$index]['MULTIPOLYGON'][$k]['no_of_lines'] = 1;
$param_row[$k]['no_of_lines'] = 1;
$points_arr = $this->extractPoints($polygon, null);
$no_of_points = count($points_arr);
$params[$index]['MULTIPOLYGON'][$k][0]['no_of_points'] = $no_of_points;
$param_row[$k][0]['no_of_points'] = $no_of_points;
for ($i = 0; $i < $no_of_points; $i++) {
$params[$index]['MULTIPOLYGON'][$k][0][$i]['x'] = $points_arr[$i][0];
$params[$index]['MULTIPOLYGON'][$k][0][$i]['y'] = $points_arr[$i][1];
$param_row[$k][0][$i]['x'] = $points_arr[$i][0];
$param_row[$k][0][$i]['y'] = $points_arr[$i][1];
}
} else {
// Seperate outer and inner polygons
$parts = explode("),(", $polygon);
$params[$index]['MULTIPOLYGON'][$k]['no_of_lines'] = count($parts);
$param_row[$k]['no_of_lines'] = count($parts);
$j = 0;
foreach ($parts as $ring) {
$points_arr = $this->extractPoints($ring, null);
$no_of_points = count($points_arr);
$params[$index]['MULTIPOLYGON'][$k][$j]['no_of_points'] = $no_of_points;
$param_row[$k][$j]['no_of_points'] = $no_of_points;
for ($i = 0; $i < $no_of_points; $i++) {
$params[$index]['MULTIPOLYGON'][$k][$j][$i]['x'] = $points_arr[$i][0];
$params[$index]['MULTIPOLYGON'][$k][$j][$i]['y'] = $points_arr[$i][1];
$param_row[$k][$j][$i]['x'] = $points_arr[$i][0];
$param_row[$k][$j][$i]['y'] = $points_arr[$i][1];
}
$j++;
}

View File

@ -451,9 +451,9 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
*/
public static function getPointOnSurface($ring)
{
$common_functions = PMA_CommonFunctions::getInstance();
// Find two consecutive distinct points.
for ($i = 0; $i < count($ring) - 1; $i++) {
if ($ring[$i]['y'] != $ring[$i + 1]['y']) {
@ -475,7 +475,10 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
// Always keep $epsilon < 1 to go with the reduction logic down here
$epsilon = 0.1;
$denominator = sqrt($common_functions->pow(($y1 - $y0), 2) + $common_functions->pow(($x0 - $x1), 2));
$denominator = sqrt(
$common_functions->pow(($y1 - $y0), 2)
+ $common_functions->pow(($x0 - $x1), 2)
);
$pointA = array(); $pointB = array();
while (true) {

View File

@ -295,15 +295,19 @@ class PMA_GIS_Visualization
. 'units: "m",'
. 'numZoomLevels: 18,'
. 'maxResolution: 156543.0339,'
. 'maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508),'
. 'restrictedExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508)'
. '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("None", {isBaseLayer: true});'
. 'var layerNone = new OpenLayers.Layer.Boxes('
. '"None", {isBaseLayer: true});'
. 'var layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");'
. 'var layerOsmarender = new OpenLayers.Layer.OSM.Osmarender("Osmarender");'
. 'var layerOsmarender = new OpenLayers.Layer.OSM.Osmarender('
. '"Osmarender");'
. 'var layerCycleMap = new OpenLayers.Layer.OSM.CycleMap("CycleMap");'
. 'map.addLayers([layerMapnik, layerOsmarender, layerCycleMap, layerNone]);'
. 'map.addLayers([layerMapnik,layerOsmarender,layerCycleMap,layerNone]);'
. 'var vectorLayer = new OpenLayers.Layer.Vector("Data");'
. 'var bound;';
$output .= $this->_prepareDataSet($this->_data, $scale_data, 'ol', '');