| 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 |
|
| 26 |
|
| 27 |
<!-- bbox present in geojson input --> |
| 28 |
<gml:boundedBy> |
| 29 |
<gml:Box> |
| 30 |
<gml:coord> |
| 31 |
<gml:X>{{ bbox[0] }}</gml:X> |
| 32 |
<gml:Y>{{ bbox[1] }}</gml:Y> |
| 33 |
</gml:coord> |
| 34 |
<gml:coord> |
| 35 |
<gml:X>{{ bbox[2] }}</gml:X> |
| 36 |
<gml:Y>{{ bbox[3] }}</gml:Y> |
| 37 |
</gml:coord> |
| 38 |
</gml:Box> |
| 39 |
</gml:boundedBy> |
| 40 |
|
| 41 |
{% for feature in features %} |
| 42 |
<gml:featureMember> |
| 43 |
<cities:City> |
| 44 |
<cities:name>{{ feature.properties.CITY_NAME }}</cities:name> |
| 45 |
{# get population from reference data in globals struct #} |
| 46 |
<cities:population>{{ refdata.city_population[feature.properties.CITY_NAME] }}</cities:population> |
| 47 |
<cities:geometry> |
| 48 |
{# Generate gml id #} |
| 49 |
{% set gml_id = 'point-%d' % loop.index %} |
| 50 |
{# Generate a Point (or any other) GML geometry from a GeoJSON geometry using the geojson2gml |
| 51 |
Jinja2 custom Filter. |
| 52 |
By specifying a target_crs we can even reproject from the source CRS. |
| 53 |
The gml_format=GML2|GML3 determines the general GML form: e.g. pos/posList or coordinates. gml_longsrs=YES|NO |
| 54 |
determines the srsName format like EPSG:4326 or urn:ogc:def:crs:EPSG::4326 (long). |
| 55 |
#} |
| 56 |
{{ feature.geometry | geojson2gml(source_crs=crs, target_crs=4258, gml_id=gml_id, gml_format='GML3', gml_longsrs='YES') }} |
| 57 |
</cities:geometry> |
| 58 |
</cities:City> |
| 59 |
</gml:featureMember> |
| 60 |
{% endfor %} |
| 61 |
|
| 62 |
</cities:FeatureCollection> |