generateParams($_POST['value']) ); } // Generate Well Known Text $srid = (isset($gis_data['srid']) && $gis_data['srid'] != '') ? htmlspecialchars($gis_data['srid']) : 0; $wkt = $gis_obj->generateWkt($gis_data, 0); $wkt_with_zero = $gis_obj->generateWkt($gis_data, 0, '0'); $result = "'" . $wkt . "'," . $srid; // Generate SVG based visualization $visualizationSettings = array( 'width' => 450, 'height' => 300, 'spatialColumn' => 'wkt', 'mysqlVersion' => $GLOBALS['dbi']->getVersion() ); $data = array(array('wkt' => $wkt_with_zero, 'srid' => $srid)); $visualization = GisVisualization::getByData($data, $visualizationSettings) ->toImage('svg'); $open_layers = GisVisualization::getByData($data, $visualizationSettings) ->asOl(); // If the call is to update the WKT and visualization make an AJAX response if (isset($_POST['generate']) && $_POST['generate'] == true) { $extra_data = array( 'result' => $result, 'visualization' => $visualization, 'openLayers' => $open_layers, ); $response = Response::getInstance(); $response->addJSON($extra_data); exit; } ob_start(); echo '
'; echo ''; echo '
'; echo '

'; printf( __('Value for the column "%s"'), htmlspecialchars($_POST['field']) ); echo '

'; echo ''; // The input field to which the final result should be added // and corresponding null checkbox if (isset($_POST['input_name'])) { echo ''; } echo Url::getHiddenInputs(); echo ''; echo '
'; echo $visualization; echo '
'; // No not remove inline style or it will cause "Cannot read property 'w' of null" on GIS editor map init echo '
'; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo ''; echo ''; echo ''; echo '
'; echo ''; echo '    '; /* l10n: Spatial Reference System Identifier */ echo ''; echo ''; echo '
'; echo ''; echo ''; echo '
'; $geom_count = 1; if ($geom_type == 'GEOMETRYCOLLECTION') { $geom_count = (isset($gis_data[$geom_type]['geom_count'])) ? intval($gis_data[$geom_type]['geom_count']) : 1; if (isset($gis_data[$geom_type]['add_geom'])) { $geom_count++; } echo ''; } for ($a = 0; $a < $geom_count; $a++) { if (! isset($gis_data[$a])) { continue; } if ($geom_type == 'GEOMETRYCOLLECTION') { echo '

'; printf(__('Geometry %d:'), $a + 1); echo '
'; if (isset($gis_data[$a]['gis_type'])) { $type = htmlspecialchars($gis_data[$a]['gis_type']); } else { $type = $gis_types[0]; } echo ''; } else { $type = $geom_type; } if ($type == 'POINT') { echo '
'; echo __('Point:'); echo ''; echo ''; echo ''; echo ''; } elseif ($type == 'MULTIPOINT' || $type == 'LINESTRING') { $no_of_points = isset($gis_data[$a][$type]['no_of_points']) ? intval($gis_data[$a][$type]['no_of_points']) : 1; if ($type == 'LINESTRING' && $no_of_points < 2) { $no_of_points = 2; } if ($type == 'MULTIPOINT' && $no_of_points < 1) { $no_of_points = 1; } if (isset($gis_data[$a][$type]['add_point'])) { $no_of_points++; } echo ''; for ($i = 0; $i < $no_of_points; $i++) { echo '
'; printf(__('Point %d'), $i + 1); echo ': '; echo ''; echo ''; echo ''; echo ''; } echo ''; } elseif ($type == 'MULTILINESTRING' || $type == 'POLYGON') { $no_of_lines = isset($gis_data[$a][$type]['no_of_lines']) ? intval($gis_data[$a][$type]['no_of_lines']) : 1; if ($no_of_lines < 1) { $no_of_lines = 1; } if (isset($gis_data[$a][$type]['add_line'])) { $no_of_lines++; } echo ''; for ($i = 0; $i < $no_of_lines; $i++) { echo '
'; if ($type == 'MULTILINESTRING') { printf(__('Linestring %d:'), $i + 1); } else { if ($i == 0) { echo __('Outer ring:'); } else { printf(__('Inner ring %d:'), $i); } } $no_of_points = isset($gis_data[$a][$type][$i]['no_of_points']) ? intval($gis_data[$a][$type][$i]['no_of_points']) : 2; if ($type == 'MULTILINESTRING' && $no_of_points < 2) { $no_of_points = 2; } if ($type == 'POLYGON' && $no_of_points < 4) { $no_of_points = 4; } if (isset($gis_data[$a][$type][$i]['add_point'])) { $no_of_points++; } echo ''; for ($j = 0; $j < $no_of_points; $j++) { echo('
'); printf(__('Point %d'), $j + 1); echo ': '; echo ''; echo ''; echo ''; echo ''; } echo ''; } $caption = ($type == 'MULTILINESTRING') ? __('Add a linestring') : __('Add an inner ring'); echo '
'; echo ''; } elseif ($type == 'MULTIPOLYGON') { $no_of_polygons = isset($gis_data[$a][$type]['no_of_polygons']) ? intval($gis_data[$a][$type]['no_of_polygons']) : 1; if ($no_of_polygons < 1) { $no_of_polygons = 1; } if (isset($gis_data[$a][$type]['add_polygon'])) { $no_of_polygons++; } echo ''; for ($k = 0; $k < $no_of_polygons; $k++) { echo '
'; printf(__('Polygon %d:'), $k + 1); $no_of_lines = isset($gis_data[$a][$type][$k]['no_of_lines']) ? intval($gis_data[$a][$type][$k]['no_of_lines']) : 1; if ($no_of_lines < 1) { $no_of_lines = 1; } if (isset($gis_data[$a][$type][$k]['add_line'])) { $no_of_lines++; } echo ''; for ($i = 0; $i < $no_of_lines; $i++) { echo '

'; if ($i == 0) { echo __('Outer ring:'); } else { printf(__('Inner ring %d:'), $i); } $no_of_points = isset($gis_data[$a][$type][$k][$i]['no_of_points']) ? intval($gis_data[$a][$type][$k][$i]['no_of_points']) : 4; if ($no_of_points < 4) { $no_of_points = 4; } if (isset($gis_data[$a][$type][$k][$i]['add_point'])) { $no_of_points++; } echo ''; for ($j = 0; $j < $no_of_points; $j++) { echo '
'; printf(__('Point %d'), $j + 1); echo ': '; echo ''; echo ''; echo ''; echo ''; } echo ''; } echo '
'; echo ''; echo '
'; } echo '
'; echo ''; } } if ($geom_type == 'GEOMETRYCOLLECTION') { echo '

'; echo ''; } echo '
'; echo ''; echo '
'; echo ''; echo '
'; echo '

' , __('Output') , '

'; echo '

'; echo __( 'Choose "ST_GeomFromText" from the "Function" column and paste the' . ' string below into the "Value" field.' ); echo '

'; echo ''; echo '
'; echo '
'; echo '
'; Response::getInstance()->addJSON('gis_editor', ob_get_contents()); ob_end_clean();