gis_data_editor_form.twig 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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>
  5. <input type="hidden" name="field" value="{{ field }}">
  6. {# The input field to which the final result should be added and corresponding null checkbox #}
  7. {% if input_name is not null %}
  8. <input type="hidden" name="input_name" value="{{ input_name }}">
  9. {% endif %}
  10. {{ get_hidden_inputs() }}
  11. {# Visualization section #}
  12. <div id="placeholder"{{ srid != 0 ? ' class="hide"' }}>
  13. {{ visualization|raw }}
  14. </div>
  15. <div id="openlayersmap" style="width: {{width}}px; height: {{height}}px;"{{ srid == 0 ? ' class="hide"' }}></div>
  16. <div class="choice floatright">
  17. <input type="checkbox" id="choice" value="useBaseLayer"{{ srid != 0 ? ' checked="checked"' }}>
  18. <label for="choice">{% trans "Use OpenStreetMaps as Base Layer" %}</label>
  19. </div>
  20. <script language="javascript" type="text/javascript">{{ open_layers|raw }}</script>
  21. {# End of visualization section #}
  22. {# Header section - Inclueds GIS type selector and input field for SRID #}
  23. <div id="gis_data_header">
  24. <select name="gis_data[gis_type]" class="gis_type">
  25. {% for gis_type in gis_types %}
  26. <option value="{{ gis_type }}"{{ geom_type == gis_type ? ' selected="selected"' }}>
  27. {{ gis_type }}
  28. </option>
  29. {% endfor %}
  30. </select>
  31. <label for="srid">{% trans %}SRID:{% context %}Spatial Reference System Identifier{% endtrans %}</label>
  32. <input name="gis_data[srid]" type="text" value="{{ srid }}">
  33. </div>
  34. {# End of header section #}
  35. {# Data section #}
  36. <div id="gis_data">
  37. {% if geom_type == 'GEOMETRYCOLLECTION' %}
  38. <input type="hidden" name="gis_data[GEOMETRYCOLLECTION][geom_count]" value="{{ geom_count }}">
  39. {% endif %}
  40. {% for a in 0..geom_count - 1 %}
  41. {% if gis_data[a] is not null %}
  42. {% if geom_type == 'GEOMETRYCOLLECTION' %}
  43. <br><br>
  44. {{ 'Geometry %d:'|trans|format(a + 1) }}
  45. <br>
  46. {% if gis_data[a]['gis_type'] is not null %}
  47. {% set type = gis_data[a]['gis_type'] %}
  48. {% else %}
  49. {% set type = gis_types[0] %}
  50. {% endif %}
  51. <select name="gis_data[{{ a }}][gis_type]" class="gis_type">
  52. {% for gis_type in gis_types|slice(0, 6) %}
  53. <option value="{{ gis_type }}"{{ type == gis_type ? ' selected="selected"' }}>
  54. {{ gis_type }}
  55. </option>
  56. {% endfor %}
  57. </select>
  58. {% else %}
  59. {% set type = geom_type %}
  60. {% endif %}
  61. {% if type == 'POINT' %}
  62. <br>
  63. {% trans 'Point:' %}
  64. <label for="x">{% trans 'X' %}</label>
  65. <input name="gis_data[{{ a }}][POINT][x]" type="text" value="{{ gis_data[a]['POINT']['x'] }}">
  66. <label for="y">{% trans 'Y' %}</label>
  67. <input name="gis_data[{{ a }}][POINT][y]" type="text" value="{{ gis_data[a]['POINT']['y'] }}">
  68. {% elseif type == 'MULTIPOINT' or type == 'LINESTRING' %}
  69. {% set no_of_points = gis_data[a][type]['no_of_points'] ?? 1 %}
  70. {% if type == 'LINESTRING' and no_of_points < 2 %}
  71. {% set no_of_points = 2 %}
  72. {% endif %}
  73. {% if type == 'MULTIPOINT' and no_of_points < 1 %}
  74. {% set no_of_points = 1 %}
  75. {% endif %}
  76. {% if gis_data[a][type]['add_point'] is not null %}
  77. {% set no_of_points = no_of_points + 1 %}
  78. {% endif %}
  79. <input type="hidden" value="{{ no_of_points }}" name="gis_data[{{ a }}][{{ type }}][no_of_points]">
  80. {% for i in 0..no_of_points - 1 %}
  81. <br>
  82. {{ 'Point %d:'|trans|format(i + 1) }}
  83. <label for="x">{% trans 'X' %}</label>
  84. <input type="text" name="gis_data[{{ a }}][{{ type }}][{{ i }}][x]" value="{{ gis_data[a][type][i]['x'] }}">
  85. <label for="y">{% trans 'Y' %}</label>
  86. <input type="text" name="gis_data[{{ a }}][{{ type }}][{{ i }}][y]" value="{{ gis_data[a][type][i]['y'] }}">
  87. {% endfor %}
  88. <input type="submit" name="gis_data[{{ a }}][{{ type }}][add_point]" class="btn btn-secondary add addPoint" value="{% trans 'Add a point' %}">
  89. {% elseif type == 'MULTILINESTRING' or type == 'POLYGON' %}
  90. {% set no_of_lines = gis_data[a][type]['no_of_lines'] ?? 1 %}
  91. {% if no_of_lines < 1 %}
  92. {% set no_of_lines = 1 %}
  93. {% endif %}
  94. {% if gis_data[a][type]['add_line'] is not null %}
  95. {% set no_of_lines = no_of_lines + 1 %}
  96. {% endif %}
  97. <input type="hidden" value="{{ no_of_lines }}" name="gis_data[{{ a }}][{{ type }}][no_of_lines]">
  98. {% for i in 0..no_of_lines - 1 %}
  99. <br>
  100. {% if type == 'MULTILINESTRING' %}
  101. {{ 'Linestring %d:'|trans|format(i + 1) }}
  102. {% elseif i == 0 %}
  103. {% trans 'Outer ring:' %}
  104. {% else %}
  105. {{ 'Inner ring %d:'|trans|format(i) }}
  106. {% endif %}
  107. {% set no_of_points = gis_data[a][type][i]['no_of_points'] ?? 2 %}
  108. {% if type == 'MULTILINESTRING' and no_of_points < 2 %}
  109. {% set no_of_points = 2 %}
  110. {% endif %}
  111. {% if type == 'POLYGON' and no_of_points < 4 %}
  112. {% set no_of_points = 4 %}
  113. {% endif %}
  114. {% if gis_data[a][type][i]['add_point'] is not null %}
  115. {% set no_of_points = no_of_points + 1 %}
  116. {% endif %}
  117. <input type="hidden" value="{{ no_of_points }}" name="gis_data[{{ a }}][{{ type }}][{{ i }}][no_of_points]">
  118. {% for j in 0..no_of_points - 1 %}
  119. <br>
  120. {{ 'Point %d:'|trans|format(j + 1) }}
  121. <label for="x">{% trans 'X' %}</label>
  122. <input type="text" name="gis_data[{{ a }}][{{ type }}][{{ i }}][{{ j }}][x]" value="{{ gis_data[a][type][i][j]['x'] }}">
  123. <label for="y">{% trans 'Y' %}</label>
  124. <input type="text" name="gis_data[{{ a }}][{{ type }}][{{ i }}][{{ j }}][y]" value="{{ gis_data[a][type][i][j]['y'] }}">
  125. {% endfor %}
  126. <input type="submit" name="gis_data[{{ a }}][{{ type }}][{{ i }}][add_point]" class="btn btn-secondary add addPoint" value="{% trans 'Add a point' %}">
  127. {% endfor %}
  128. <br>
  129. <input type="submit" name="gis_data[{{ a }}][{{ type }}][add_line]" class="btn btn-secondary add addLine" value="
  130. {{- type == 'MULTILINESTRING' ? 'Add a linestring'|trans : 'Add an inner ring'|trans }}">
  131. {% elseif type == 'MULTIPOLYGON' %}
  132. {% set no_of_polygons = gis_data[a][type]['no_of_polygons'] ?? 1 %}
  133. {% if no_of_polygons < 1 %}
  134. {% set no_of_polygons = 1 %}
  135. {% endif %}
  136. {% if gis_data[a][type]['add_polygon'] is not null %}
  137. {% set no_of_polygons = no_of_polygons + 1 %}
  138. {% endif %}
  139. <input type="hidden" name="gis_data[{{ a }}][{{ type }}][no_of_polygons]" value="{{ no_of_polygons }}">
  140. {% for k in 0..no_of_polygons - 1 %}
  141. <br>
  142. {{ 'Polygon %d:'|trans|format(k + 1) }}
  143. {% set no_of_lines = gis_data[a][type][k]['no_of_lines'] ?? 1 %}
  144. {% if no_of_lines < 1 %}
  145. {% set no_of_lines = 1 %}
  146. {% endif %}
  147. {% if gis_data[a][type][k]['add_line'] is not null %}
  148. {% set no_of_lines = no_of_lines + 1 %}
  149. {% endif %}
  150. <input type="hidden" name="gis_data[{{ a }}][{{ type }}][{{ k }}][no_of_lines]" value="{{ no_of_lines }}">
  151. {% for i in 0..no_of_lines - 1 %}
  152. <br><br>
  153. {% if i == 0 %}
  154. {% trans 'Outer ring:' %}
  155. {% else %}
  156. {{ 'Inner ring %d:'|trans|format(i) }}
  157. {% endif %}
  158. {% set no_of_points = gis_data[a][type][k][i]['no_of_points'] ?? 4 %}
  159. {% if no_of_points < 4 %}
  160. {% set no_of_points = 4 %}
  161. {% endif %}
  162. {% if gis_data[a][type][k][i]['add_point'] is not null %}
  163. {% set no_of_points = no_of_points + 1 %}
  164. {% endif %}
  165. <input type="hidden" name="gis_data[{{ a }}][{{ type }}][{{ k }}][{{ i }}][no_of_points]" value="{{ no_of_points }}">
  166. {% for j in 0..no_of_points - 1 %}
  167. <br>
  168. {{ 'Point %d:'|trans|format(j + 1) }}
  169. <label for="x">{% trans 'X' %}</label>
  170. <input type="text" name="gis_data[{{ a }}][{{ type }}][{{ k }}][{{ i }}][{{ j }}][x]" value="{{ gis_data[a][type][k][i][j]['x'] }}">
  171. <label for="y">{% trans 'Y' %}</label>
  172. <input type="text" name="gis_data[{{ a }}][{{ type }}][{{ k }}][{{ i }}][{{ j }}][y]" value="{{ gis_data[a][type][k][i][j]['y'] }}">
  173. {% endfor %}
  174. <input type="submit" name="gis_data[{{ a }}][{{ type }}][{{ k }}][{{ i }}][add_point]" class="btn btn-secondary add addPoint" value="{% trans 'Add a point' %}">
  175. {% endfor %}
  176. <br>
  177. <input type="submit" name="gis_data[{{ a }}][{{ type }}][{{ k }}][add_line]" class="btn btn-secondary add addLine" value="{% trans 'Add an inner ring' %}">
  178. <br>
  179. {% endfor %}
  180. <br>
  181. <input type="submit" name="gis_data[{{ a }}][{{ type }}][add_polygon]" class="btn btn-secondary add addPolygon" value="{% trans 'Add a polygon' %}">
  182. {% endif %}
  183. {% endif %}
  184. {% endfor %}
  185. {% if geom_type == 'GEOMETRYCOLLECTION' %}
  186. <br><br>
  187. <input type="submit" name="gis_data[GEOMETRYCOLLECTION][add_geom]" class="btn btn-secondary add addGeom" value="{% trans 'Add geometry' %}">
  188. {% endif %}
  189. </div>
  190. {# End of data section #}
  191. <br>
  192. <input class="btn btn-primary" type="submit" name="gis_data[save]" value="{% trans 'Go' %}">
  193. <div id="gis_data_output">
  194. <h3>{% trans 'Output' %}</h3>
  195. <p>
  196. {% trans 'Choose "GeomFromText" from the "Function" column and paste the string below into the "Value" field.' %}
  197. </p>
  198. <textarea id="gis_data_textarea" cols="95" rows="5">{{ result }}</textarea>
  199. </div>
  200. </div>
  201. </form>