3 require_once './libraries/common.inc.php';
4 require_once './libraries/header_http.inc.php';
5 require_once './libraries/header_meta_style.inc.php';
6 require_once './libraries/gis/pma_gis_factory.php';
7 require_once './libraries/gis_visualization.lib.php';
9 // Get data if any posted
11 if (PMA_isValid($_REQUEST['gis_data'], 'array')) {
12 $gis_data = $_REQUEST['gis_data'];
26 if (! isset($gis_data['gis_type'])) {
27 if (isset($_REQUEST['value'])) {
28 $gis_data['gis_type'] = substr($_REQUEST['value'], 1, strpos($_REQUEST['value'], "(") - 1);
30 $gis_data['gis_type'] = $gis_types[0];
34 $geom_type = $gis_data['gis_type'];
36 $gis_obj = PMA_GIS_Factory
::factory($geom_type);
37 if (isset($_REQUEST['value'])) {
38 $gis_data = array_merge($gis_data, $gis_obj->generateParams($_REQUEST['value']));
41 $srid = isset($gis_data['srid']) ?
htmlspecialchars($gis_data['srid']) : '';
42 $wkt = $gis_obj->generateWkt($gis_data, 0);
44 $format = (PMA_USR_BROWSER_AGENT
== 'IE' && PMA_USR_BROWSER_VER
<= 8) ?
'svg' : 'png';
45 $visualizationSettings = array('width' => 400, 'height' => 400,);
48 $visualization = PMA_GIS_visualization_results($data, $visualizationSettings, $format);
51 if(isset($_REQUEST['generate']) && $_REQUEST['generate'] == true) {
55 'visualization' => $visualization,
57 PMA_ajaxResponse(null, true, $extra_data);
64 <form action
="gis_data_editor.php" method
="post">
65 <div id
="gis_data_editor_no_js">
66 <h3
><?php
printf(__('Value for the column "%s"'), htmlspecialchars($_REQUEST['field'])); ?
></h3
>
67 <?php
echo('<input type="hidden" name="field" value="' . htmlspecialchars($_REQUEST['field']) . '">');
68 echo PMA_generate_common_hidden_inputs($url_params);
70 <div id
="placeholder">
71 <?php
if (! $no_visual) {echo $visualization;} ?
>
73 <div id
="gis_data_header">
74 <select name
="gis_data[gis_type]">
76 foreach ($gis_types as $gis_type) {
77 echo('<option value="' . $gis_type . '"');
78 if ($geom_type == $gis_type) {
79 echo(' selected="selected"');
81 echo('>' . $gis_type . '</option>');
85 <input type
="submit" name
="gis_data[go]" value
="<?php echo __("Go
")?>" />
86 <label
for="srid"><?php
echo __("SRID"); ?
>: 
;</label
>
87 <input name
="gis_data[srid]" type
="text" value
="<?php echo($srid); ?>" />
92 if ($geom_type == 'GEOMETRYCOLLECTION') {
93 $geom_count = (isset($gis_data[$geom_type]['geom_count'])) ?
$gis_data[$geom_type]['geom_count'] : 1;
94 if (isset($gis_data[$geom_type]['add_geom'])) {
97 echo('<input type="hidden" name="gis_data[GEOMETRYCOLLECTION][geom_count]" value="' . $geom_count . '">');
99 for ($a = 0; $a < $geom_count; $a++
) {
100 if ($geom_type == 'GEOMETRYCOLLECTION') {
101 echo('<br/><br/>'); echo __("Geometry"); echo($a +
1 . ':<br/>');
102 if (isset($gis_data[$a]['gis_type'])) {
103 $type = $gis_data[$a]['gis_type'];
105 $type = $gis_types[0];
107 echo('<select name="gis_data[' . $a . '][gis_type]">');
108 foreach (array_slice($gis_types, 0, 6) as $gis_type) {
109 echo('<option value="' . $gis_type . '"');
110 if ($type == $gis_type) {
111 echo(' selected="selected"');
113 echo('>' . $gis_type . '</option>');
116 echo('<input type="submit" name="gis_data[' . $a . '][go]" value="'); echo __("Go"); echo('">');
121 if ($type == 'POINT') {
122 echo('<br/>'); echo __("Point");
123 ?
> <label
for="x"><?php
echo __("X"); ?
>: 
;</label
>
124 <input name
="gis_data[<?php echo($a); ?>][POINT][x]" type
="text" value
="<?php echo(isset($gis_data[$a]['POINT']['x']) ? htmlspecialchars($gis_data[$a]['POINT']['x']) : ''); ?>" />
125 <label
for="y"><?php
echo __("Y"); ?
>: 
;</label
>
126 <input name
="gis_data[<?php echo($a); ?>][POINT][y]" type
="text" value
="<?php echo(isset($gis_data[$a]['POINT']['y']) ? htmlspecialchars($gis_data[$a]['POINT']['y']) : ''); ?>" />
128 } elseif ($type == 'MULTIPOINT' ||
$type == 'LINESTRING') {
130 $no_of_points = isset($gis_data[$a][$type]['no_of_points']) ?
$gis_data[$a][$type]['no_of_points'] : 1;
131 if ($type == 'LINESTRING' && $no_of_points < 2) {
134 if ($type == 'MULTIPOINT' && $no_of_points < 1) {
138 if (isset($gis_data[$a][$type]['add_point'])) {
141 echo('<input type="hidden" name="gis_data[' . $a . '][' . $type . '][no_of_points]" value="' . $no_of_points . '">');
143 for ($i = 0; $i < $no_of_points; $i++
) {
144 echo('<br/>'); echo __("Point"); echo($i +
1 . ':');
145 ?
> <label
for="x"><?php
echo __("X"); ?
></label
>
146 <input type
="text" name
="gis_data[<?php echo($a); ?>][<?php echo($type); ?>][<?php echo($i); ?>][x]" value
="<?php echo(isset($gis_data[$a][$type][$i]['x']) ? htmlspecialchars($gis_data[$a][$type][$i]['x']) : ''); ?>" />
147 <label
for="y"><?php
echo __("Y"); ?
></label
>
148 <input type
="text" name
="gis_data[<?php echo($a); ?>][<?php echo($type); ?>][<?php echo($i); ?>][y]" value
="<?php echo(isset($gis_data[$a][$type][$i]['y']) ? htmlspecialchars($gis_data[$a][$type][$i]['y']) : ''); ?>" />
152 <input type
="submit" name
="gis_data[<?php echo($a); ?>][<?php echo($type); ?>][add_point]" value
="<?php echo __("Add a point
"); ?>">
154 } elseif ($type == 'MULTILINESTRING' ||
$type == 'POLYGON') {
156 $no_of_lines = isset($gis_data[$a][$type]['no_of_lines']) ?
$gis_data[$a][$type]['no_of_lines'] : 1;
157 if ($no_of_lines < 1) {
160 if (isset($gis_data[$a][$type]['add_line'])) {
163 echo('<input type="hidden" name="gis_data[' . $a . '][' . $type . '][no_of_lines]" value="' . $no_of_lines . '">');
165 for ($i = 0; $i < $no_of_lines; $i++
) {
167 if ($type == 'MULTILINESTRING') {
168 echo __("Linestring"); echo($i +
1 . ':');
171 echo __("Outer Ring:");
173 echo __("Inner Ring"); echo($i . ':');
177 $no_of_points = isset($gis_data[$a][$type][$i]['no_of_points']) ?
$gis_data[$a][$type][$i]['no_of_points'] : 2;
178 if ($type == 'MULTILINESTRING' && $no_of_points < 2) {
181 if ($type == 'POLYGON' && $no_of_points < 4) {
184 if (isset($gis_data[$a][$type][$i]['add_point'])) {
187 echo('<input type="hidden" name="gis_data[' . $a . '][' . $type . '][' . $i . '][no_of_points]" value="' . $no_of_points . '">');
189 for ($j = 0; $j < $no_of_points; $j++
) {
190 echo('<br/>'); echo __("Point"); echo($j +
1 . ':');
191 ?
> <label
for="x"><?php
echo __("X"); ?
></label
>
192 <input type
="text" name
="gis_data[<?php echo($a); ?>][<?php echo($type); ?>][<?php echo($i); ?>][<?php echo($j); ?>][x]" value
="<?php echo(isset($gis_data[$a][$type][$i][$j]['x']) ? htmlspecialchars($gis_data[$a][$type][$i][$j]['x']) : ''); ?>" />
193 <label
for="y"><?php
echo __("Y"); ?
></label
>
194 <input type
="text" name
="gis_data[<?php echo($a); ?>][<?php echo($type); ?>][<?php echo($i); ?>][<?php echo($j); ?>][y]" value
="<?php echo(isset($gis_data[$a][$type][$i][$j]['x']) ? htmlspecialchars($gis_data[$a][$type][$i][$j]['y']) : ''); ?>" />
196 ?
> <input type
="submit" name
="gis_data[<?php echo($a); ?>][<?php echo($type); ?>][<?php echo($i); ?>][add_point]" value
="<?php echo __("Add a point
"); ?>">
198 $caption = ($type == 'MULTILINESTRING') ?
__('Add a linestring') : __('Add an inner ring');
199 ?
> <br
/><input type
="submit" name
="gis_data[<?php echo($a); ?>][<?php echo($type); ?>][add_line]" value
="<?php echo($caption); ?>">
201 } elseif ($type == 'MULTIPOLYGON') {
202 $no_of_polygons = isset($gis_data[$a][$type]['no_of_polygons']) ?
$gis_data[$a][$type]['no_of_polygons'] : 1;
203 if ($no_of_polygons < 1) {
206 if (isset($gis_data[$a][$type]['add_polygon'])) {
209 echo('<input type="hidden" name="gis_data[' . $a . '][' . $type . '][no_of_polygons]" value="' . $no_of_polygons . '">');
211 for ($k = 0; $k < $no_of_polygons; $k++
) {
212 echo('<br/>'); echo __("Polygon"); echo($k +
1 . ':');
213 $no_of_lines = isset($gis_data[$a][$type][$k]['no_of_lines']) ?
$gis_data[$a][$type][$k]['no_of_lines'] : 1;
214 if ($no_of_lines < 1) {
217 if (isset($gis_data[$a][$type][$k]['add_line'])) {
220 echo('<input type="hidden" name="gis_data[' . $a . '][' . $type . '][' . $k . '][no_of_lines]" value="' . $no_of_lines . '">');
222 for ($i = 0; $i < $no_of_lines; $i++
) {
225 echo __("Outer Ring:");
227 echo __("Inner Ring"); echo($i . ':');
230 $no_of_points = isset($gis_data[$a][$type][$k][$i]['no_of_points']) ?
$gis_data[$a][$type][$k][$i]['no_of_points'] : 3;
231 if ($no_of_points < 3) {
234 if (isset($gis_data[$a][$type][$k][$i]['add_point'])) {
237 echo('<input type="hidden" name="gis_data[' . $a . '][' . $type . '][' . $k . '][' . $i . '][no_of_points]" value="' . $no_of_points . '">');
239 for ($j = 0; $j < $no_of_points; $j++
) {
240 echo('<br/>'); echo __("Point"); echo($j +
1 . ':');
241 ?
> <label
for="x"><?php
echo __("X"); ?
></label
>
242 <input type
="text" name
="<?php echo("gis_data
[" . $a . "][" . $type . "][" . $k . "][" . $i . "][" . $j . "][x
]"); ?>" value
="<?php echo(isset($gis_data[$a][$type][$k][$i][$j]['x']) ? htmlspecialchars($gis_data[$a][$type][$k][$i][$j]['x']) : ''); ?>" />
243 <label
for="y"><?php
echo __("Y"); ?
></label
>
244 <input type
="text" name
="<?php echo("gis_data
[" . $a . "][" . $type . "][" . $k . "][" . $i . "][" . $j . "][y
]"); ?>" value
="<?php echo(isset($gis_data[$a][$type][$k][$i][$j]['y']) ? htmlspecialchars($gis_data[$a][$type][$k][$i][$j]['y']) : ''); ?>" />
246 ?
> <input type
="submit" name
="<?php echo("gis_data
[" . $a . "][" . $type . "][" . $k . "][" . $i . "][add_point
]"); ?>" value
="<?php echo __("Add a point
"); ?>">
248 ?
> <br
/><input type
="submit" name
="<?php echo("gis_data
[" . $a . "][" . $type . "][" . $k . "][add_line
]"); ?>" value
="<?php echo __('Add an inner ring') ?>">
250 ?
> <br
/><br
/><input type
="submit" name
="<?php echo("gis_data
[" . $a . "][" . $type . "][add_polygon
]"); ?>" value
="<?php echo __('Add a polygon') ?>">
253 if ($geom_type == 'GEOMETRYCOLLECTION') {
254 ?
> <br
/><br
/><input type
="submit" name
="gis_data[GEOMETRYCOLLECTION][add_geom]" value
="<?php echo __("Add geometry
"); ?>" />
258 <br
/><input type
="submit" name
="gis_data[save]" value
="<?php echo __('Go') ?>">
259 <div id
="gis_data_output">
260 <h3
><?php
echo __('Output'); ?
></h3
>
261 <p
><?php
echo __('Chose "GeomFromText" from the "Function" column and paste the below string into the "Value" field'); ?
></p
>
262 <textarea id
="gis_data_textarea" cols
="95" rows
="5">
263 <?php
echo("'" . $wkt . "'");
274 * Displays the footer
276 require './libraries/footer.inc.php';