File: cities-json2gml.jinja2

package info (click to toggle)
python-stetl 2.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 90,156 kB
  • sloc: python: 5,103; xml: 707; sql: 430; makefile: 154; sh: 65
file content (40 lines) | stat: -rw-r--r-- 1,752 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?xml version='1.0' encoding='utf-8'?>
<cities:FeatureCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                       xmlns:cities="http://cities.maptools.org/"
                       xmlns:gml="http://www.opengis.net/gml"
                       xsi:schemaLocation="http://cities.maptools.org/ ../gmlcities.xsd  http://www.opengis.net/gml http://schemas.opengis.net/gml/2.1.2/feature.xsd">

    <!--
    Generated with a Jinja2 template. The 'globs' variables come from the file globals.json containing global
    variables/structures. The actual/dynamic data (cities) comes from the input CSV file cities.json.
    Also a file with macros templates/macros.tpl.xml is imported, allowing reuse for common structures like INSPIRE id's.
    -->


    {#  Show the use of globals, more or less static content. #}
    <gml:description>
       {{ globs.description }}
    </gml:description>

    {#  Show the use of macro's, a very powerful reuse mechanism, e.g. for common elements and structures like INSPIRE id. #}
    {% import 'templates/macros.jinja2' as macros %}

    {# {{ macros.render_element('gml:description', globs.description) }} #}

    {{ macros.render_name(globs.name) }}
    {{ macros.render_bounded_by(cities) }}

    {% for city in cities %}
        <gml:featureMember>
            <cities:City>
                <cities:name>{{ city.name }}</cities:name>
                <cities:geometry>
                    <gml:Point srsName="{{ globs.srs_name }}">
                        <gml:coordinates>{{ city.lon }}, {{ city.lat }}</gml:coordinates>
                    </gml:Point>
                </cities:geometry>
            </cities:City>
        </gml:featureMember>
    {% endfor %}

</cities:FeatureCollection>