1 <form id="gis_data_editor_form" action="{{ url('/gis-data-editor') }}" method="post">
2 <input type="hidden" id="themeImagePath" value="{{ theme_image_path }}">
3 <div id="gis_data_editor">
4 <h3>{{ 'Value for the column "%s"'|trans|format(field) }}</h3>
6 <input type="hidden" name="field" value="{{ field }}">
7 {# The input field to which the final result should be added and corresponding null checkbox #}
8 {% if input_name is not null %}
9 <input type="hidden" name="input_name" value="{{ input_name }}">
11 {{ get_hidden_inputs() }}
13 {# Visualization section #}
14 <div id="placeholder"{{ srid != 0 ? ' class="hide"' }}>
15 {{ visualization|raw }}
18 <div id="openlayersmap" style="width: {{width}}px; height: {{height}}px;"{{ srid == 0 ? ' class="hide"' }}></div>
20 <div class="choice floatright">
21 <input type="checkbox" id="choice" value="useBaseLayer"{{ srid != 0 ? ' checked="checked"' }}>
22 <label for="choice">{% trans "Use OpenStreetMaps as Base Layer" %}</label>
25 <script language="javascript" type="text/javascript">{{ open_layers|raw }}</script>
26 {# End of visualization section #}
28 {# Header section - Inclueds GIS type selector and input field for SRID #}
29 <div id="gis_data_header">
30 <select name="gis_data[gis_type]" class="gis_type">
31 {% for gis_type in gis_types %}
32 <option value="{{ gis_type }}"{{ geom_type == gis_type ? ' selected="selected"' }}>
38 <label for="srid">{% trans %}SRID:{% context %}Spatial Reference System Identifier{% endtrans %}</label>
39 <input name="gis_data[srid]" type="text" value="{{ srid }}">
41 {# End of header section #}
45 {% if geom_type == 'GEOMETRYCOLLECTION' %}
46 <input type="hidden" name="gis_data[GEOMETRYCOLLECTION][geom_count]" value="{{ geom_count }}">
49 {% for a in 0..geom_count - 1 %}
50 {% if gis_data[a] is not null %}
51 {% if geom_type == 'GEOMETRYCOLLECTION' %}
53 {{ 'Geometry %d:'|trans|format(a + 1) }}
55 {% if gis_data[a]['gis_type'] is not null %}
56 {% set type = gis_data[a]['gis_type'] %}
58 {% set type = gis_types[0] %}
60 <select name="gis_data[{{ a }}][gis_type]" class="gis_type">
61 {% for gis_type in gis_types|slice(0, 6) %}
62 <option value="{{ gis_type }}"{{ type == gis_type ? ' selected="selected"' }}>
68 {% set type = geom_type %}
71 {% if type == 'POINT' %}
74 <label for="x">{% trans 'X' %}</label>
75 <input name="gis_data[{{ a }}][POINT][x]" type="text" value="{{ gis_data[a]['POINT']['x'] }}">
76 <label for="y">{% trans 'Y' %}</label>
77 <input name="gis_data[{{ a }}][POINT][y]" type="text" value="{{ gis_data[a]['POINT']['y'] }}">
78 {% elseif type == 'MULTIPOINT' or type == 'LINESTRING' %}
79 {% set no_of_points = gis_data[a][type]['no_of_points'] ?? 1 %}
80 {% if type == 'LINESTRING' and no_of_points < 2 %}
81 {% set no_of_points = 2 %}
83 {% if type == 'MULTIPOINT' and no_of_points < 1 %}
84 {% set no_of_points = 1 %}
86 {% if gis_data[a][type]['add_point'] is not null %}
87 {% set no_of_points = no_of_points + 1 %}
89 <input type="hidden" value="{{ no_of_points }}" name="gis_data[{{ a }}][{{ type }}][no_of_points]">
91 {% for i in 0..no_of_points - 1 %}
93 {{ 'Point %d:'|trans|format(i + 1) }}
94 <label for="x">{% trans 'X' %}</label>
95 <input type="text" name="gis_data[{{ a }}][{{ type }}][{{ i }}][x]" value="{{ gis_data[a][type][i]['x'] }}">
96 <label for="y">{% trans 'Y' %}</label>
97 <input type="text" name="gis_data[{{ a }}][{{ type }}][{{ i }}][y]" value="{{ gis_data[a][type][i]['y'] }}">
99 <input type="submit" name="gis_data[{{ a }}][{{ type }}][add_point]" class="btn btn-secondary add addPoint" value="{% trans 'Add a point' %}">
100 {% elseif type == 'MULTILINESTRING' or type == 'POLYGON' %}
101 {% set no_of_lines = gis_data[a][type]['no_of_lines'] ?? 1 %}
102 {% if no_of_lines < 1 %}
103 {% set no_of_lines = 1 %}
105 {% if gis_data[a][type]['add_line'] is not null %}
106 {% set no_of_lines = no_of_lines + 1 %}
108 <input type="hidden" value="{{ no_of_lines }}" name="gis_data[{{ a }}][{{ type }}][no_of_lines]">
110 {% for i in 0..no_of_lines - 1 %}
112 {% if type == 'MULTILINESTRING' %}
113 {{ 'Linestring %d:'|trans|format(i + 1) }}
115 {% trans 'Outer ring:' %}
117 {{ 'Inner ring %d:'|trans|format(i) }}
120 {% set no_of_points = gis_data[a][type][i]['no_of_points'] ?? 2 %}
121 {% if type == 'MULTILINESTRING' and no_of_points < 2 %}
122 {% set no_of_points = 2 %}
124 {% if type == 'POLYGON' and no_of_points < 4 %}
125 {% set no_of_points = 4 %}
127 {% if gis_data[a][type][i]['add_point'] is not null %}
128 {% set no_of_points = no_of_points + 1 %}
130 <input type="hidden" value="{{ no_of_points }}" name="gis_data[{{ a }}][{{ type }}][{{ i }}][no_of_points]">
132 {% for j in 0..no_of_points - 1 %}
134 {{ 'Point %d:'|trans|format(j + 1) }}
135 <label for="x">{% trans 'X' %}</label>
136 <input type="text" name="gis_data[{{ a }}][{{ type }}][{{ i }}][{{ j }}][x]" value="{{ gis_data[a][type][i][j]['x'] }}">
137 <label for="y">{% trans 'Y' %}</label>
138 <input type="text" name="gis_data[{{ a }}][{{ type }}][{{ i }}][{{ j }}][y]" value="{{ gis_data[a][type][i][j]['y'] }}">
140 <input type="submit" name="gis_data[{{ a }}][{{ type }}][{{ i }}][add_point]" class="btn btn-secondary add addPoint" value="{% trans 'Add a point' %}">
143 <input type="submit" name="gis_data[{{ a }}][{{ type }}][add_line]" class="btn btn-secondary add addLine" value="
144 {{- type == 'MULTILINESTRING' ? 'Add a linestring'|trans : 'Add an inner ring'|trans }}">
145 {% elseif type == 'MULTIPOLYGON' %}
146 {% set no_of_polygons = gis_data[a][type]['no_of_polygons'] ?? 1 %}
147 {% if no_of_polygons < 1 %}
148 {% set no_of_polygons = 1 %}
150 {% if gis_data[a][type]['add_polygon'] is not null %}
151 {% set no_of_polygons = no_of_polygons + 1 %}
153 <input type="hidden" name="gis_data[{{ a }}][{{ type }}][no_of_polygons]" value="{{ no_of_polygons }}">
155 {% for k in 0..no_of_polygons - 1 %}
157 {{ 'Polygon %d:'|trans|format(k + 1) }}
158 {% set no_of_lines = gis_data[a][type][k]['no_of_lines'] ?? 1 %}
159 {% if no_of_lines < 1 %}
160 {% set no_of_lines = 1 %}
162 {% if gis_data[a][type][k]['add_line'] is not null %}
163 {% set no_of_lines = no_of_lines + 1 %}
165 <input type="hidden" name="gis_data[{{ a }}][{{ type }}][{{ k }}][no_of_lines]" value="{{ no_of_lines }}">
167 {% for i in 0..no_of_lines - 1 %}
170 {% trans 'Outer ring:' %}
172 {{ 'Inner ring %d:'|trans|format(i) }}
175 {% set no_of_points = gis_data[a][type][k][i]['no_of_points'] ?? 4 %}
176 {% if no_of_points < 4 %}
177 {% set no_of_points = 4 %}
179 {% if gis_data[a][type][k][i]['add_point'] is not null %}
180 {% set no_of_points = no_of_points + 1 %}
182 <input type="hidden" name="gis_data[{{ a }}][{{ type }}][{{ k }}][{{ i }}][no_of_points]" value="{{ no_of_points }}">
184 {% for j in 0..no_of_points - 1 %}
186 {{ 'Point %d:'|trans|format(j + 1) }}
187 <label for="x">{% trans 'X' %}</label>
188 <input type="text" name="gis_data[{{ a }}][{{ type }}][{{ k }}][{{ i }}][{{ j }}][x]" value="{{ gis_data[a][type][k][i][j]['x'] }}">
189 <label for="y">{% trans 'Y' %}</label>
190 <input type="text" name="gis_data[{{ a }}][{{ type }}][{{ k }}][{{ i }}][{{ j }}][y]" value="{{ gis_data[a][type][k][i][j]['y'] }}">
192 <input type="submit" name="gis_data[{{ a }}][{{ type }}][{{ k }}][{{ i }}][add_point]" class="btn btn-secondary add addPoint" value="{% trans 'Add a point' %}">
195 <input type="submit" name="gis_data[{{ a }}][{{ type }}][{{ k }}][add_line]" class="btn btn-secondary add addLine" value="{% trans 'Add an inner ring' %}">
199 <input type="submit" name="gis_data[{{ a }}][{{ type }}][add_polygon]" class="btn btn-secondary add addPolygon" value="{% trans 'Add a polygon' %}">
203 {% if geom_type == 'GEOMETRYCOLLECTION' %}
205 <input type="submit" name="gis_data[GEOMETRYCOLLECTION][add_geom]" class="btn btn-secondary add addGeom" value="{% trans 'Add geometry' %}">
208 {# End of data section #}
211 <input class="btn btn-primary" type="submit" name="gis_data[save]" value="{% trans 'Go' %}">
213 <div id="gis_data_output">
214 <h3>{% trans 'Output' %}</h3>
216 {% trans 'Choose "GeomFromText" from the "Function" column and paste the string below into the "Value" field.' %}
218 <textarea id="gis_data_textarea" cols="95" rows="5">{{ result }}</textarea>