| 1 |
# Example loader for UK Ordnance Survey Mastermap Loader |
| 2 |
# Inspired and functionally equivalent to https://github.com/AstunTechnology/Loader |
| 3 |
# |
| 4 |
|
| 5 |
# Main ETL, also to file (output_file) for test purposes |
| 6 |
[etl] |
| 7 |
chains = input_sql_pre|schema_name_filter|output_postgres, |
| 8 |
input_big_gml_files|osmm_filter|xml_assembler|output_file, |
| 9 |
input_big_gml_files|osmm_filter|xml_assembler|output_ogr2ogr |
| 10 |
|
| 11 |
# Pre SQL file inputs to be executed |
| 12 |
[input_sql_pre] |
| 13 |
class = stetl.inputs.fileinput.StringFileInput |
| 14 |
file_path = postgres/create-schema.sql,postgres/create-tables.sql,postgres/create-indexes.sql |
| 15 |
|
| 16 |
# Generic filter to substitute Python-format string values like {schema} in string |
| 17 |
[schema_name_filter] |
| 18 |
class = stetl.filters.stringfilter.StringSubstitutionFilter |
| 19 |
# format args {schema} is schema name |
| 20 |
format_args = schema:{schema} |
| 21 |
|
| 22 |
[output_postgres] |
| 23 |
class = stetl.outputs.dboutput.PostgresDbOutput |
| 24 |
database = {database} |
| 25 |
host = {host} |
| 26 |
port = {port} |
| 27 |
user = {user} |
| 28 |
password = {password} |
| 29 |
schema = {schema} |
| 30 |
|
| 31 |
# The source input file(s) from dir and produce osmm:*Member elements |
| 32 |
# Namespaces are stripped as prep_osmgml.py uses non-namespaced xpath |
| 33 |
[input_big_gml_files] |
| 34 |
class = stetl.inputs.fileinput.XmlElementStreamerFileInput |
| 35 |
file_path = {gml_files} |
| 36 |
element_tags = topographicMember,boundaryMember,cartographicMember |
| 37 |
strip_namespaces = True |
| 38 |
|
| 39 |
# modifying filter for OSMM specific element manipulation |
| 40 |
# prep_class is the specific Python class to actually modify single |
| 41 |
# feature elements. Original code from AstunTech in prep_osmgml.py |
| 42 |
[osmm_filter] |
| 43 |
class = python.osmmfilter.OrdSurveyGmlFilter |
| 44 |
prep_class = python.prep_osmgml.prep_osmm_topo |
| 45 |
|
| 46 |
# Assembles etree docs gml:featureMember elements, each with "max_elements" elements |
| 47 |
[xml_assembler] |
| 48 |
class = stetl.filters.xmlassembler.XmlAssembler |
| 49 |
max_elements = {max_features} |
| 50 |
container_doc = <osgb:FeatureCollection |
| 51 |
xmlns:osgb='http://www.ordnancesurvey.co.uk/xml/namespaces/osgb' |
| 52 |
xmlns:gml='http://www.opengis.net/gml' |
| 53 |
xmlns:xlink='http://www.w3.org/1999/xlink' |
| 54 |
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' |
| 55 |
xsi:schemaLocation='http://www.ordnancesurvey.co.uk/xml/namespaces/osgb http://www.ordnancesurvey.co.uk/xml/schema/v7/OSDNFFeatures.xsd' |
| 56 |
fid='GDS-58116-1'> |
| 57 |
<gml:description>Ordnance Survey, (c) Crown Copyright. All rights reserved, 2009-07-30</gml:description> |
| 58 |
<gml:boundedBy> |
| 59 |
<gml:null>unknown</gml:null> |
| 60 |
</gml:boundedBy> |
| 61 |
<osgb:queryTime>2009-07-30T02:35:17</osgb:queryTime> |
| 62 |
<osgb:queryExtent> |
| 63 |
<osgb:Rectangle srsName='osgb:BNG'> |
| 64 |
<gml:coordinates>291000.000,92000.000 293000.000,94000.000</gml:coordinates> |
| 65 |
</osgb:Rectangle> |
| 66 |
</osgb:queryExtent> |
| 67 |
</osgb:FeatureCollection > |
| 68 |
element_container_tag = FeatureCollection |
| 69 |
|
| 70 |
# The ogr2ogr command-line, may use any output here, as long as |
| 71 |
# the input is a GML file. The "temp_file" is where etree-docs |
| 72 |
# are saved. It has to be the same file as in the ogr2ogr command. |
| 73 |
# TODO: find a way to use a GML-stream through stdin to ogr2ogr |
| 74 |
[output_ogr2ogr] |
| 75 |
class = stetl.outputs.ogroutput.Ogr2OgrOutput |
| 76 |
temp_file = {temp_dir}/osmm-tmp.gml |
| 77 |
gfs_file = gfs/osmm_topo_postgres.gfs |
| 78 |
# lco will only be added to ogr2ogr on first run |
| 79 |
# lco = -lco LAUNDER=YES -lco PRECISION=NO |
| 80 |
ogr2ogr_cmd = ogr2ogr |
| 81 |
-append -skipfailures |
| 82 |
-t_srs EPSG:27700 |
| 83 |
-f PostgreSQL |
| 84 |
"PG:dbname={database} host={host} port={port} user={user} password={password} active_schema={schema}" |
| 85 |
{temp_dir}/osmm-tmp.gml |
| 86 |
--config GML_EXPOSE_FID NO |
| 87 |
--config PG_USE_COPY YES |
| 88 |
|
| 89 |
# Below Alternative outputs for testing |
| 90 |
|
| 91 |
# Send to stdout |
| 92 |
[output_std] |
| 93 |
class = stetl.outputs.standardoutput.StandardXmlOutput |
| 94 |
|
| 95 |
[output_file] |
| 96 |
class = stetl.outputs.fileoutput.FileOutput |
| 97 |
file_path = output/osmm_topo_prepared.gml |
| 98 |
|
| 99 |
|