gis data editor.php,gis_data_editor.php

/* vim: set expandtab sw=4 ts=4 sts=4: */

/**

* Editor for Geometry data types.

*

* @package PhpMyAdmin

*/

use PMA\libraries\Response;

use PMA\libraries\gis\GISFactory;

use PMA\libraries\gis\GISVisualization;

use PMA\libraries\URL;

/**

* Escapes special characters if the variable is set.

* Returns an empty string otherwise.

*

* @param string $variable variable to be escaped

*

* @return string escaped variable

*/

function escape($variable)

{

return isset($variable) ? htmlspecialchars($variable) : '';

}

require_once 'libraries/common.inc.php';

if (! isset($_REQUEST['field'])) {

PMA\libraries\Util::checkParameters(array('field'));

}

// Get data if any posted

$gis_data = array();

if (PMA_isValid($_REQUEST['gis_data'], 'array')) {

$gis_data = $_REQUEST['gis_data'];

}

$gis_types = array(

'POINT',

'MULTIPOINT',

'LINESTRING',

'MULTILINESTRING',

'POLYGON',

'MULTIPOLYGON',

'GEOMETRYCOLLECTION'

);

// Extract type from the initial call and make sure that it's a valid one.

// Extract from field's values if available, if not use the column type passed.

if (! isset($gis_data['gis_type'])) {

if (isset($_REQUEST['type']) && $_REQUEST['type'] != '') {

$gis_data['gis_type'] = mb_strtoupper($_REQUEST['type']);

}

if (isset($_REQUEST['value']) && trim($_REQUEST['value']) != '') {

$start = (substr($_REQUEST['value'], 0, 1) == "'") ? 1 : 0;

$gis_data['gis_type'] = mb_substr(

$_REQUEST['value'],

$start,

mb_strpos($_REQUEST['value'], "(") - $start

);

}

if ((! isset($gis_data['gis_type']))

|| (! in_array($gis_data['gis_type'], $gis_types))

) {

$gis_data['gis_type'] = $gis_types[0];

}

}

$geom_type = htmlspecialchars($gis_data['gis_type']);

// Generate parameters from value passed.

$gis_obj = GISFactory::factory($geom_type);

if (isset($_REQUEST['value'])) {

$gis_data = array_merge(

$gis_data, $gis_obj->generateParams($_REQUEST['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'

);

$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($_REQUEST['generate']) && $_REQUEST['generate'] == true) {

$extra_data = array(

'result' => $result,

'visualization' => $visualization,

'openLayers' => $open_layers,

);

$response = Response::getInstance();

$response->addJSON($extra_data);

exit;

}

ob_start();

echo '

';

echo '

, ' value="' , $GLOBALS['pmaThemeImage'] , '" />';

echo '

';

echo '

';

printf(

__('Value for the column "%s"'),

htmlspecialchars($_REQUEST['field'])

);

echo '';

echo '';

// The input field to which the final result should be added

// and corresponding null checkbox

if (isset($_REQUEST['input_name'])) {

echo '';

}

echo URL::getHiddenInputs();

echo '';

echo '

';

echo $visualization;

echo '

';

echo '

';

echo '

';

echo '

';

echo '

, ($srid != 0 ? ' checked="checked"' : '') , '/>';

echo '' , __("Use OpenStreetMaps as Base Layer") , '';

echo '

';

echo '

echo $open_layers;

echo '';

echo '';

echo '';

echo '

';

echo '';

foreach ($gis_types as $gis_type) {

echo '

if ($geom_type == $gis_type) {

echo ' selected="selected"';

}

echo '>' , $gis_type , '

';

}

echo '';

echo '    ';

/* l10n: Spatial Reference System Identifier */

echo '' , __('SRID:') , '';

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 '

, ' value="' , $geom_count , '" />';

}

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 '';

foreach (array_slice($gis_types, 0, 6) as $gis_type) {

echo '

if ($type == $gis_type) {

echo ' selected="selected"';

}

echo '>' , $gis_type , '

';

}

echo '';

} else {

$type = $geom_type;

}

if ($type == 'POINT') {

echo '
';

echo __('Point:');

echo '' , __("X") , '';

echo '

, ' value="' , escape($gis_data[$a]['POINT']['x']) , '" />';

echo '' , __("Y") , '';

echo '

, ' value="' , escape($gis_data[$a]['POINT']['y']) , '" />';

} 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 '

, ' name="gis_data[' , $a , '][' , $type , '][no_of_points]" />';

for ($i = 0; $i < $no_of_points; $i++) {

echo '
';

printf(__('Point %d'), $i + 1);

echo ': ';

echo '' , __("X") , '';

echo '

, ' name="gis_data[' , $a , '][' , $type , '][' , $i , '][x]"'

, ' value="' , escape($gis_data[$a][$type][$i]['x']) , '" />';

echo '' , __("Y") , '';

echo '

, ' name="gis_data[' , $a , '][' , $type , '][' , $i , '][y]"'

, ' value="' , escape($gis_data[$a][$type][$i]['y']) , '" />';

}

echo '

, ' name="gis_data[' , $a , '][' , $type , '][add_point]"'

, ' class="add addPoint" value="' , __("Add a point") , '" />';

} 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 '

, ' name="gis_data[' , $a , '][' , $type , '][no_of_lines]" />';

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 '

, ' name="gis_data[' , $a , '][' , $type , '][' , $i

, '][no_of_points]" />';

for ($j = 0; $j < $no_of_points; $j++) {

echo('
');

printf(__('Point %d'), $j + 1);

echo ': ';

echo '' , __("X") , '';

echo '';

echo '' , __("Y") , '';

echo '';

}

echo '

, ' class="add addPoint" value="' , __("Add a point") , '" />';

}

$caption = ($type == 'MULTILINESTRING')

? __('Add a linestring')

: __('Add an inner ring');

echo '
';

echo '

, ' name="gis_data[' , $a , '][' , $type , '][add_line]"'

, ' class="add addLine" value="' , $caption , '" />';

} 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 '

, ' name="gis_data[' , $a , '][' , $type , '][no_of_polygons]"'

, ' value="' , $no_of_polygons , '" />';

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 '

, ' name="gis_data[' , $a , '][' , $type , '][' , $k

, '][no_of_lines]"' , ' value="' , $no_of_lines , '" />';

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 '

, ' name="gis_data[' , $a , '][' , $type , '][' , $k , '][' , $i

, '][no_of_points]"' , ' value="' , $no_of_points , '" />';

for ($j = 0; $j < $no_of_points; $j++) {

echo '
';

printf(__('Point %d'), $j + 1);

echo ': ';

echo '' , __("X") , '';

echo '

, ' name="gis_data[' , $a , '][' , $type , '][' , $k , ']['

, $i , '][' , $j , '][x]"'

, ' value="' , escape($gis_data[$a][$type][$k][$i][$j]['x'])

, '" />';

echo '' , __("Y") , '';

echo '

, ' name="gis_data[' , $a , '][' , $type , '][' , $k , ']['

, $i , '][' , $j , '][y]"'

, ' value="' , escape($gis_data[$a][$type][$k][$i][$j]['y'])

, '" />';

}

echo '

, ' name="gis_data[' , $a , '][' , $type , '][' , $k , '][' , $i

, '][add_point]"'

, ' class="add addPoint" value="' , __("Add a point") , '" />';

}

echo '
';

echo '

, ' name="gis_data[' , $a , '][' , $type , '][' , $k , '][add_line]"'

, ' class="add addLine" value="' , __('Add an inner ring') , '" />';

echo '
';

}

echo '
';

echo '

, ' name="gis_data[' , $a , '][' , $type , '][add_polygon]"'

, ' class="add addPolygon" value="' , __('Add a polygon') , '" />';

}

}

if ($geom_type == 'GEOMETRYCOLLECTION') {

echo '
';

echo '

, 'class="add addGeom" value="' , __("Add geometry") , '" />';

}

echo '

';

echo '';

echo '
';

echo '';

echo '

';

echo '

' , __('Output') , '

';

echo '

';

echo __(

'Choose "GeomFromText" from the "Function" column and paste the'

. ' string below into the "Value" field.'

);

echo '

';

echo '';

echo htmlspecialchars($result);

echo '';

echo '

';

echo '

';

echo '

';

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

ob_end_clean();

一键复制

编辑

Web IDE

原始数据

按行查看

历史

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
毕设新项目-基于Java开发的智慧养老院信息管理系统源码+数据库(含vue前端源码).zip 【备注】 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用!有问题请及时沟通交流。 2、适用人群:计算机相关专业(如计科、信息安全、数据科学与大数据技术、人工智能、通信、物联网、自动化、电子信息等)在校学生、专业老师或者企业员工下载使用。 3、用途:项目具有较高的学习借鉴价值,不仅适用于小白学习入门进阶。也可作为毕设项目、课程设计、大作业、初期项目立项演示等。 4、如果基础还行,或热爱钻研,亦可在此项目代码基础上进行修改添加,实现其他不同功能。 欢迎下载!欢迎交流学习!不清楚的可以私信问我! 毕设新项目-基于Java开发的智慧养老院信息管理系统源码+数据库(含vue前端源码).zip毕设新项目-基于Java开发的智慧养老院信息管理系统源码+数据库(含vue前端源码).zip毕设新项目-基于Java开发的智慧养老院信息管理系统源码+数据库(含vue前端源码).zip毕设新项目-基于Java开发的智慧养老院信息管理系统源码+数据库(含vue前端源码).zip毕设新项目-基于Java开发的智慧养老院信息管理系统源码+数据库(含vue前端源码).zip毕设新项目-基于Java开发的智慧养老院信息管理系统源码+数据库(含vue前端源码).zip毕设新项目-基于Java开发的智慧养老院信息管理系统源码+数据库(含vue前端源码).zip毕设新项目-基于Java开发的智慧养老院信息管理系统源码+数据库(含vue前端源码).zip毕设新项目-基于Java开发的智慧养老院信息管理系统源码+数据库(含vue前端源码).zip
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值