Debian Codegraph @

examples/basics/10_jinja2_templating/templates/cities-json2gml.jinja2

raw
1 <?xml version='1.0' encoding='utf-8'?>
2 <cities:FeatureCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 xmlns:cities="http://cities.maptools.org/"
4 xmlns:gml="http://www.opengis.net/gml"
5 xsi:schemaLocation="http://cities.maptools.org/ ../gmlcities.xsd http://www.opengis.net/gml http://schemas.opengis.net/gml/2.1.2/feature.xsd">
6
7 <!--
8 Generated with a Jinja2 template. The 'globs' variables come from the file globals.json containing global
9 variables/structures. The actual/dynamic data (cities) comes from the input CSV file cities.json.
10 Also a file with macros templates/macros.tpl.xml is imported, allowing reuse for common structures like INSPIRE id's.
11 -->
12
13
14 {# Show the use of globals, more or less static content. #}
15 <gml:description>
16 {{ globs.description }}
17 </gml:description>
18
19 {# Show the use of macro's, a very powerful reuse mechanism, e.g. for common elements and structures like INSPIRE id. #}
20 {% import 'templates/macros.jinja2' as macros %}
21
22 {# {{ macros.render_element('gml:description', globs.description) }} #}
23
24 {{ macros.render_name(globs.name) }}
25 {{ macros.render_bounded_by(cities) }}
26
27 {% for city in cities %}
28 <gml:featureMember>
29 <cities:City>
30 <cities:name>{{ city.name }}</cities:name>
31 <cities:geometry>
32 <gml:Point srsName="{{ globs.srs_name }}">
33 <gml:coordinates>{{ city.lon }}, {{ city.lat }}</gml:coordinates>
34 </gml:Point>
35 </cities:geometry>
36 </cities:City>
37 </gml:featureMember>
38 {% endfor %}
39
40 </cities:FeatureCollection>