├── .gitignore ├── AUTHORS.md ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE.txt ├── docs ├── QGIS.JPG └── readme.md ├── extras └── ordnancesurvey │ ├── addressbase │ ├── plus │ │ ├── addressbase_plus_addresses_geo.sql │ │ └── addressbase_plus_addresses_postal.sql │ ├── premium │ │ ├── addressbase_premium_address_point.sql │ │ ├── addressbase_premium_addresses_geo.sql │ │ ├── addressbase_premium_addresses_postal.sql │ │ └── pgdump │ │ │ ├── create-indexes.sql │ │ │ ├── create-tables.sql │ │ │ ├── loader.config │ │ │ └── readme.md │ └── standard │ │ └── addressbase_standard_addresses_postal.sql │ ├── osmm │ ├── itn │ │ ├── pgdump │ │ │ ├── create-indexes.sql │ │ │ ├── create-tables.sql │ │ │ └── loader.config │ │ └── views.sql │ └── topo │ │ ├── mapserver │ │ ├── mastermap.inc │ │ └── readme.markdown │ │ └── pgdump │ │ ├── create-indexes.sql │ │ ├── create-tables.sql │ │ ├── loader.config │ │ └── readme.md │ ├── osopen │ └── roads │ │ └── routing_prep.sql │ └── vml │ ├── pgdump │ ├── create-indexes.sql │ ├── create-tables.sql │ ├── readme.md │ └── vml_pgdump.config │ └── updates │ ├── apply-update.sql │ ├── create-archive-tables.sql │ └── create-update-tables.sql ├── gfs ├── addressbase_plus.gfs ├── addressbase_plus_postgres.gfs ├── addressbase_premium_postgres.gfs ├── addressbase_premium_postgres_pre_epoch_39.gfs ├── addressbase_premium_pre_epoch_39.gfs ├── addressbase_standard.gfs ├── addressbase_standard_postgres.gfs ├── land_registry_cadastral_parcels.gfs ├── osmm_highways_paths_postgres.gfs ├── osmm_highways_postgres.gfs ├── osmm_highways_postgres_mega.gfs ├── osmm_highways_roads_postgres.gfs ├── osmm_highways_routing_postgres.gfs ├── osmm_itn_postgres.gfs ├── osmm_sites_postgres.gfs ├── osmm_topo.gfs ├── osmm_topo_postgres.gfs ├── osmm_topo_postgres_basemap.gfs ├── osmm_topo_postgres_basemap_minimal.gfs ├── osmm_topo_shape_qgis.gfs ├── osmm_water_postgres.gfs ├── osopenmap.gfs ├── osopenroads.gfs ├── terrain50.gfs ├── vmd_postgres.gfs ├── vml_postgres.gfs └── vml_shape.gfs ├── python ├── loader.config ├── loader.py ├── osmm_topo_style │ ├── __init__.py │ ├── area_style.py │ ├── bnd_style.py │ ├── line_style.py │ ├── pnt_style.py │ ├── sym_style.py │ └── txt_style.py ├── prep_osgml.py ├── prep_policekml.py ├── prepgml4ogr.py └── setup.py └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | tags 3 | 4 | -------------------------------------------------------------------------------- /AUTHORS.md: -------------------------------------------------------------------------------- 1 | Loader is written and maintained by [Astun Technology](http://astuntechnology.com) and various contributors. 2 | 3 | Maintainer: 4 | 5 | * Matt Walker (@walkermatt) 6 | 7 | Contributions: 8 | 9 | * Jo Cook (@archaeogeek) 10 | * Mike Saunt (@mikesaunt) 11 | * Alessandro De Noia (@sdonk) 12 | * Andy Berry (@andynberry) 13 | * Ross McDonald (@mixedbredie) 14 | * Aileen Heal (@aileenheal) 15 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to Loader will be documented in this file. 4 | 5 | ## [1.3.0] - 2023-02-22 6 | 7 | [Replace decomposed unicode characters with precomposed equivalents](https://github.com/AstunTechnology/Loader/pull/72). 8 | 9 | ## [1.2.1] - 2021-12-30 10 | 11 | * Fix issues loading OSMM Topo with Python 3, should support Python 2.7 and 3 12 | 13 | ## [1.2.0] - 2021-12-22 14 | 15 | * Add support for loading OS Terrain - @coastalrocket 16 | * Support `out_dir` as well as existing `output_dir` placeholder in `ogr_cmd` and `post_cmd` 17 | * Set the encoding of the text output by the `prep_cmd` to `UTF-8` 18 | 19 | ## [1.1.0] - 2019-04-05 20 | 21 | * Update VectorMap Local to match new schema - @coastalrocket, @walkermatt 22 | * Add OSMM Highways support - @aileenheal, @archaeogeek, @GeoWill, @coastalrocket, @walkermatt 23 | 24 | ## [1.0.1] - 2017-11-28 25 | 26 | * Update VectorMap District to match new schema - @thomparker 27 | * Add CONTRIBUTING doc - @archaeogeek 28 | 29 | ## [1.0.0] - 2017-07-10 30 | 31 | Loader has been around since 2011 but has been without an official release; lets start now ;-) 32 | 33 | ### Changed 34 | 35 | * Fixes for OS AddressBase preparation and `.gfs` config 36 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Loader 2 | 3 | We welcome contributions to Loader, in the form of issues, bug fixes, or 4 | suggestions for enhancements. This document sets out our guidelines and best 5 | practices for such contributions. 6 | 7 | It's based on the [Contributing to Open Source Projects 8 | Guide](https://contribution-guide-org.readthedocs.io/). 9 | 10 | 11 | ## Submitting bugs 12 | 13 | ### Due diligence 14 | 15 | Before submitting a bug, please do the following: 16 | 17 | * Perform __basic troubleshooting__ steps: 18 | 19 | * __Make sure you're on the latest version.__ If you're not on the most 20 | recent version, your problem may have been solved already! Upgrading is 21 | always the best first step. You should be able to tell which version you 22 | have by comparing the copy of CHANGELOG.md in your version with the 23 | [latest on GitHub](https://github.com/AstunTechnology/Loader/blob/master/CHANGELOG.md). 24 | * [__Search the issue 25 | tracker__](https://github.com/AstunTechnology/Loader/issues?utf8=%E2%9C%93&q=is%3Aissue) 26 | to make sure it's not a known issue. If you 27 | don't find a pre-existing issue, consider [**checking the 28 | wiki**](https://github.com/AstunTechnology/Loader/wiki) in case the 29 | problem is non-bug-related. 30 | 31 | ### What to put in your bug report 32 | 33 | Make sure your report gets the attention it deserves: bug reports with missing 34 | information may be ignored or punted back to you, delaying a fix. The below 35 | constitutes a bare minimum; more info is almost always better: 36 | 37 | * __What version of Python are you using?__ For example, are you using Python 38 | 2.7.3, Python 3.3.1, PyPy 2.0? 39 | * __What operating system are you using?__ Windows (7, 8, 32-bit, 64-bit,), 40 | Mac OS X, (10.7.4, 10.9.0), Linux (which distribution, which version?) 41 | Again, more detail is better. 42 | * __Which version or versions of the software are you using?__ Ideally, you've 43 | followed the advice above and are on the latest version, but please confirm 44 | this. 45 | * __How can the we recreate your problem?__ Imagine that we have never used 46 | Loader before and have downloaded it for the first time. Exactly what steps 47 | do we need to take to reproduce your problem? 48 | * If possible or appropriate, pare down your problem until the simplest 49 | case remains where your problem can be seen. Not only can indicate that 50 | the problem is not a bug, it will help us fix the bug more quickly. 51 | 52 | 53 | ## Contributing changes 54 | 55 | ### Contributor License Agreement 56 | 57 | Your contribution will be under our [license](https://raw.githubusercontent.com/AstunTechnology/Loader/master/LICENSE.txt) as per [GitHub's terms of service](https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license). 58 | 59 | ### Version control branching 60 | 61 | * Always __make a new branch__ for your work, no matter how small. This makes 62 | it easy for others to take just that one set of changes from your repository, 63 | in case you have multiple unrelated changes floating around. 64 | 65 | * __Don't submit unrelated changes in the same branch/pull request!__ If it 66 | is not possible to review your changes quickly and easily, we may reject 67 | your request. 68 | 69 | * __Base your new branch off of the appropriate branch__ on the main repository: 70 | 71 | * In general the released version of Loader is based on the ``master`` 72 | (default) branch whereas development work is done under other non-default 73 | branches. Unless you are sure that your issue affects a non-default 74 | branch, __base your branch off the ``master`` one__. 75 | 76 | * Note that depending on how long it takes for the dev team to merge your 77 | patch, the copy of ``master`` you worked off of may get out of date! 78 | * If you find yourself 'bumping' a pull request that's been sidelined for a 79 | while, __make sure you rebase or merge to latest ``master``__ to ensure a 80 | speedier resolution. 81 | 82 | ### Code formatting 83 | 84 | * __Please follow the coding conventions and style used in the Loader repository.__ 85 | * Loader endeavours to follow the 86 | [PEP-8](http://www.python.org/dev/peps/pep-0008/) guidelines but we don't 87 | mind longer lines ('E501 line too long' can normally be ignored). 88 | 89 | ### Documentation isn't optional 90 | 91 | Pull requests without adequate documentation will be rejected. By 92 | "documentation" we mean: 93 | 94 | * New features should ideally include updates to __prose documentation__, 95 | including useful in-code comments and examples in the wiki. 96 | * All submissions should have a __changelog entry__ crediting the contributor 97 | and/or any individuals instrumental in identifying the problem. 98 | 99 | ## Suggesting Enhancements 100 | 101 | We welcome suggestions for enhancements, but reserve the right to reject them 102 | if they do not follow future plans for Loader. 103 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Astun Technology Ltd. (http://astuntechnology.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /docs/QGIS.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AstunTechnology/Loader/f992f3ff60f408fcd84bf9e3d2d31eadb18189ad/docs/QGIS.JPG -------------------------------------------------------------------------------- /docs/readme.md: -------------------------------------------------------------------------------- 1 | For documention please see the [project wiki](https://github.com/AstunTechnology/Loader/wiki) 2 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/addressbase/plus/addressbase_plus_addresses_geo.sql: -------------------------------------------------------------------------------- 1 | -- Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 2 | -- Licensed under [MIT License](https://git.io/fAxH0). 3 | 4 | -- View: addressbase_plus.addresses_geo 5 | 6 | -- DROP VIEW addressbase_plus.addresses_geo; 7 | 8 | CREATE OR REPLACE VIEW addressbase_plus.addresses_geo AS 9 | SELECT formatted_address.ogc_fid, formatted_address.wkb_geometry, formatted_address.uprn, formatted_address.rm_udprn, ((((ltrim(formatted_address.saon || formatted_address.paon) || formatted_address.street_description) || ', '::text) || formatted_address.localitytown) || ' '::text) || formatted_address.postcode::text AS full_address_caps, (initcap(((ltrim(formatted_address.saon || formatted_address.paon) || formatted_address.street_description) || ', '::text) || formatted_address.localitytown) || ' '::text) || formatted_address.postcode::text AS full_address, formatted_address.postcode 10 | FROM ( SELECT address.ogc_fid, address.wkb_geometry, address.uprn, address.rm_udprn, btrim((((( 11 | CASE 12 | WHEN address.organisation_name IS NOT NULL THEN address.organisation_name::text || ', '::text 13 | ELSE ''::text 14 | END || 15 | CASE 16 | WHEN address.sao_start_number IS NOT NULL THEN address.sao_start_number::text 17 | ELSE ''::text 18 | END) || 19 | CASE 20 | WHEN address.sao_start_suffix IS NOT NULL THEN address.sao_start_suffix::text 21 | ELSE ''::text 22 | END) || 23 | CASE 24 | WHEN address.sao_end_number IS NOT NULL THEN '-'::text || address.sao_end_number::text 25 | ELSE ''::text 26 | END) || 27 | CASE 28 | WHEN address.sao_end_suffix IS NOT NULL THEN address.sao_end_suffix::text 29 | ELSE ''::text 30 | END) || 31 | CASE 32 | WHEN address.sao_text IS NOT NULL THEN (' '::text || address.sao_text::text) || ', '::text 33 | ELSE ''::text 34 | END) || ' '::text AS saon, ltrim(((( 35 | CASE 36 | WHEN address.pao_start_number IS NOT NULL THEN address.pao_start_number::text 37 | ELSE ''::text 38 | END || 39 | CASE 40 | WHEN address.pao_start_suffix IS NOT NULL THEN address.pao_start_suffix::text 41 | ELSE ''::text 42 | END) || 43 | CASE 44 | WHEN address.pao_end_number IS NOT NULL THEN '-'::text || address.pao_end_number::text 45 | ELSE ''::text 46 | END) || 47 | CASE 48 | WHEN address.pao_end_suffix IS NOT NULL THEN address.pao_end_suffix::text 49 | ELSE ''::text 50 | END) || 51 | CASE 52 | WHEN address.pao_text IS NOT NULL THEN (' '::text || address.pao_text::text) || ', '::text 53 | ELSE ' '::text 54 | END) AS paon, 55 | CASE 56 | WHEN address.street_description IS NOT NULL THEN address.street_description::text 57 | ELSE ''::text 58 | END AS street_description, 59 | CASE 60 | WHEN address.locality IS NOT NULL THEN address.locality::text || ', '::text 61 | ELSE ''::text 62 | END || 63 | CASE 64 | WHEN address.town_name IS NOT NULL THEN address.town_name::text 65 | ELSE ''::text 66 | END AS localitytown, address.postcode_locator AS postcode 67 | FROM addressbase_plus.address 68 | WHERE address.class::text <> 'PP'::text AND address.class::text <> 'PS'::text) formatted_address; 69 | 70 | ALTER TABLE addressbase_plus.addresses_geo 71 | OWNER TO postgres; 72 | COMMENT ON VIEW addressbase_plus.addresses_geo 73 | IS 'Simple, nicely formatted view of AddressBase (plus) geographic addresses in PostgreSQL that has been imported with Loader! 74 | 75 | Author: Mike Saunt, Astun Technology Ltd 76 | Version 0.1 - 15th November 2013 77 | 78 | https://github.com/AstunTechnology/Loader 79 | '; 80 | 81 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/addressbase/plus/addressbase_plus_addresses_postal.sql: -------------------------------------------------------------------------------- 1 | -- Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 2 | -- Licensed under [MIT License](https://git.io/fAxH0). 3 | 4 | -- View: addressbase_plus.addresses_postal 5 | 6 | -- DROP VIEW addressbase_plus.addresses_postal; 7 | 8 | CREATE OR REPLACE VIEW addressbase_plus.addresses_postal AS 9 | SELECT formatted_address.ogc_fid, formatted_address.wkb_geometry, formatted_address.uprn, formatted_address.rm_udprn, ((((ltrim(formatted_address.saon || formatted_address.paon) || formatted_address.street_description) || ', '::text) || formatted_address.localitytown) || ' '::text) || formatted_address.postcode::text AS full_address_caps, (initcap(((ltrim(formatted_address.saon || formatted_address.paon) || formatted_address.street_description) || ', '::text) || formatted_address.localitytown) || ' '::text) || formatted_address.postcode::text AS full_address, formatted_address.postcode 10 | FROM ( SELECT address.ogc_fid, address.wkb_geometry, address.uprn, address.rm_udprn, btrim(( 11 | CASE 12 | WHEN address.organisation_name IS NOT NULL THEN address.organisation_name::text || ', '::text 13 | ELSE ''::text 14 | END || 15 | CASE 16 | WHEN address.sub_building_name IS NOT NULL THEN address.sub_building_name::text || ', '::text 17 | ELSE ''::text 18 | END) || 19 | CASE 20 | WHEN address.building_name IS NOT NULL THEN address.building_name::text 21 | ELSE ''::text 22 | END) || ' '::text AS saon, ltrim(((( 23 | CASE 24 | WHEN address.pao_start_number IS NOT NULL THEN address.pao_start_number::text 25 | ELSE ''::text 26 | END || 27 | CASE 28 | WHEN address.pao_start_suffix IS NOT NULL THEN address.pao_start_suffix::text 29 | ELSE ''::text 30 | END) || 31 | CASE 32 | WHEN address.pao_end_number IS NOT NULL THEN '-'::text || address.pao_end_number::text 33 | ELSE ''::text 34 | END) || 35 | CASE 36 | WHEN address.pao_end_suffix IS NOT NULL THEN address.pao_end_suffix::text 37 | ELSE ''::text 38 | END) || 39 | CASE 40 | WHEN address.dependent_thoroughfare IS NOT NULL THEN (' '::text || address.dependent_thoroughfare::text) || ', '::text 41 | ELSE ' '::text 42 | END) AS paon, 43 | CASE 44 | WHEN address.thoroughfare IS NOT NULL THEN address.thoroughfare::text 45 | ELSE ''::text 46 | END AS street_description, 47 | CASE 48 | WHEN address.dependent_locality IS NOT NULL THEN address.dependent_locality::text || ', '::text 49 | ELSE ''::text 50 | END || 51 | CASE 52 | WHEN address.post_town IS NOT NULL THEN address.post_town::text 53 | ELSE ''::text 54 | END AS localitytown, address.postcode 55 | FROM addressbase_plus.address 56 | WHERE address.class::text <> 'PP'::text AND address.class::text <> 'PS'::text) formatted_address; 57 | 58 | ALTER TABLE addressbase_plus.addresses_postal 59 | OWNER TO postgres; 60 | COMMENT ON VIEW addressbase_plus.addresses_postal 61 | IS 'Simple, nicely formatted view of AddressBase (plus) postal addresses in PostgreSQL that has been imported with Loader! 62 | 63 | Author: Mike Saunt, Astun Technology Ltd 64 | Version 0.1 - 15th November 2013 65 | 66 | https://github.com/AstunTechnology/Loader 67 | '; 68 | 69 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/addressbase/premium/addressbase_premium_address_point.sql: -------------------------------------------------------------------------------- 1 | -- Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 2 | -- Licensed under [MIT License](https://git.io/fAxH0). 3 | 4 | -- View: addressbase_premium.address_point 5 | 6 | 7 | CREATE OR REPLACE VIEW addressbase_premium.address_point AS 8 | SELECT deliverypointaddress.udprn AS OSAPR, 9 | deliverypointaddress.departmentname AS departmentname, 10 | deliverypointaddress.poboxnumber AS poboxnumber, 11 | deliverypointaddress.organisationname AS organisationname, 12 | deliverypointaddress.buildingnumber AS buildingnumber, 13 | deliverypointaddress.subbuildingname AS subbuildingname, 14 | deliverypointaddress.buildingname AS buildingname, 15 | deliverypointaddress.thoroughfare AS thoroughfare, 16 | deliverypointaddress.dependentthoroughfare AS dependentthoroughfare, 17 | deliverypointaddress.posttown AS posttown, 18 | deliverypointaddress.dependentlocality AS dependentlocality, 19 | deliverypointaddress.doubledependentlocality AS doubledependentlocality, 20 | NULL AS county, 21 | replace(deliverypointaddress.postcode, ' ','') AS postcode, 22 | round(st_x(blpu.wkb_geometry)*10) as X, 23 | round(st_y(blpu.wkb_geometry)*10) as Y, 24 | NULL AS source_flag, 25 | blpu.changetype AS changetype, 26 | replace(deliverypointaddress.lastupdatedate, '-', '') AS lastupdatedate, 27 | replace(deliverypointaddress.processdate, '-', '') AS processdate 28 | FROM addressbase_premium.deliverypointaddress deliverypointaddress 29 | LEFT JOIN addressbase_premium.basiclandpropertyunit blpu ON deliverypointaddress.uprn = blpu.uprn; 30 | COMMENT ON VIEW addressbase_premium.address_point 31 | IS 'AddressBase Premium formatted to look similar to AddressPoint 32 | 33 | Author: Andy Berry 34 | www.dragontail.co.uk 35 | Version 1.2 03-07-2014 36 | 37 | '; 38 | 39 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/addressbase/premium/addressbase_premium_addresses_geo.sql: -------------------------------------------------------------------------------- 1 | -- Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 2 | -- Licensed under [MIT License](https://git.io/fAxH0). 3 | 4 | -- View: addressbase_premium.addresses_geo 5 | 6 | -- DROP VIEW addressbase_premium.addresses_geo; 7 | 8 | CREATE OR REPLACE VIEW addressbase_premium.addresses_geo AS 9 | SELECT formatted_address.ogc_fid, formatted_address.wkb_geometry, formatted_address.uprn, formatted_address.rm_udprn, ((((ltrim(formatted_address.saon || formatted_address.paon) || formatted_address.street_description) || ', '::text) || formatted_address.localitytown) || ' '::text) || formatted_address.postcode::text AS full_address_caps, (initcap(((ltrim(formatted_address.saon || formatted_address.paon) || formatted_address.street_description) || ', '::text) || formatted_address.localitytown) || ' '::text) || formatted_address.postcode::text AS full_address, formatted_address.postcode 10 | FROM ( SELECT premium_addresses.ogc_fid, premium_addresses.wkb_geometry, premium_addresses.uprn, premium_addresses.rm_udprn, btrim((((( 11 | CASE 12 | WHEN premium_addresses.organisation_name IS NOT NULL THEN premium_addresses.organisation_name::text || ', '::text 13 | ELSE ''::text 14 | END || 15 | CASE 16 | WHEN premium_addresses.sao_start_number IS NOT NULL THEN premium_addresses.sao_start_number::text 17 | ELSE ''::text 18 | END) || 19 | CASE 20 | WHEN premium_addresses.sao_start_suffix IS NOT NULL THEN premium_addresses.sao_start_suffix::text 21 | ELSE ''::text 22 | END) || 23 | CASE 24 | WHEN premium_addresses.sao_end_number IS NOT NULL THEN '-'::text || premium_addresses.sao_end_number::text 25 | ELSE ''::text 26 | END) || 27 | CASE 28 | WHEN premium_addresses.sao_end_suffix IS NOT NULL THEN premium_addresses.sao_end_suffix::text 29 | ELSE ''::text 30 | END) || 31 | CASE 32 | WHEN premium_addresses.sao_text IS NOT NULL THEN (' '::text || premium_addresses.sao_text::text) || ', '::text 33 | ELSE ''::text 34 | END) || ' '::text AS saon, ltrim(((( 35 | CASE 36 | WHEN premium_addresses.pao_start_number IS NOT NULL THEN premium_addresses.pao_start_number::text 37 | ELSE ''::text 38 | END || 39 | CASE 40 | WHEN premium_addresses.pao_start_suffix IS NOT NULL THEN premium_addresses.pao_start_suffix::text 41 | ELSE ''::text 42 | END) || 43 | CASE 44 | WHEN premium_addresses.pao_end_number IS NOT NULL THEN '-'::text || premium_addresses.pao_end_number::text 45 | ELSE ''::text 46 | END) || 47 | CASE 48 | WHEN premium_addresses.pao_end_suffix IS NOT NULL THEN premium_addresses.pao_end_suffix::text 49 | ELSE ''::text 50 | END) || 51 | CASE 52 | WHEN premium_addresses.pao_text IS NOT NULL THEN (' '::text || premium_addresses.pao_text::text) || ', '::text 53 | ELSE ' '::text 54 | END) AS paon, 55 | CASE 56 | WHEN premium_addresses.street_description IS NOT NULL THEN premium_addresses.street_description::text 57 | ELSE ''::text 58 | END AS street_description, 59 | CASE 60 | WHEN premium_addresses.locality IS NOT NULL THEN premium_addresses.locality::text || ', '::text 61 | ELSE ''::text 62 | END || 63 | CASE 64 | WHEN premium_addresses.town_name IS NOT NULL THEN premium_addresses.town_name::text 65 | ELSE ''::text 66 | END AS localitytown, premium_addresses.postcode_locator AS postcode 67 | FROM ( SELECT row_number() OVER ()::integer AS ogc_fid, b.uprn, b.wkb_geometry, dpa.udprn AS rm_udprn, b.addressbasepostal, b.postcodelocator AS postcode_locator, l.saostartnumber AS sao_start_number, l.saoendnumber AS sao_end_number, l.saostartsuffix AS sao_start_suffix, l.saoendsuffix AS sao_end_suffix, l.saotext AS sao_text, l.paostartnumber AS pao_start_number, l.paoendnumber AS pao_end_number, l.paostartsuffix AS pao_start_suffix, l.saoendsuffix AS pao_end_suffix, l.saotext AS pao_text, s.usrn, s.streetdescription AS street_description, s.locality AS locality, s.townname AS town_name, dpa.organisationname AS organisation_name 68 | FROM addressbase_premium.basiclandpropertyunit b 69 | LEFT JOIN addressbase_premium.landpropertyidentifier l ON b.uprn = l.uprn 70 | LEFT JOIN addressbase_premium.deliverypointaddress dpa ON b.uprn = dpa.uprn 71 | LEFT JOIN addressbase_premium.streetdescriptiveidentifier s ON l.usrn::double precision = s.usrn) premium_addresses) formatted_address; 72 | 73 | ALTER TABLE addressbase_premium.addresses_geo 74 | OWNER TO postgres; 75 | COMMENT ON VIEW addressbase_premium.addresses_geo 76 | IS 'Simple, nicely formatted view of AddressBase (premium) geographic addresses in PostgreSQL that has been imported with Loader! 77 | 78 | Author: Mike Saunt, Astun Technology Ltd 79 | Version 0.1 - 15th November 2013 80 | 81 | https://github.com/AstunTechnology/Loader 82 | '; 83 | 84 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/addressbase/premium/addressbase_premium_addresses_postal.sql: -------------------------------------------------------------------------------- 1 | -- Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 2 | -- Licensed under [MIT License](https://git.io/fAxH0). 3 | 4 | -- View: addressbase_premium.addresses_postal 5 | 6 | -- DROP VIEW addressbase_premium.addresses_postal; 7 | 8 | CREATE OR REPLACE VIEW addressbase_premium.addresses_postal AS 9 | SELECT blpu.ogc_fid, blpu.wkb_geometry, blpu.uprn, dpa.udprn AS rm_udprn, ((((((((( 10 | CASE 11 | WHEN dpa.organisationname IS NOT NULL THEN dpa.organisationname::text || ', '::text 12 | ELSE ''::text 13 | END || 14 | CASE 15 | WHEN dpa.departmentname IS NOT NULL THEN dpa.departmentname::text || ', '::text 16 | ELSE ''::text 17 | END) || 18 | CASE 19 | WHEN dpa.subbuildingname IS NOT NULL THEN dpa.subbuildingname::text || ', '::text 20 | ELSE ''::text 21 | END) || 22 | CASE 23 | WHEN dpa.buildingname IS NOT NULL THEN dpa.buildingname::text || ', '::text 24 | ELSE ''::text 25 | END) || 26 | CASE 27 | WHEN dpa.buildingnumber > 0::numeric THEN dpa.buildingnumber::text || ' '::text 28 | ELSE ''::text 29 | END) || 30 | CASE 31 | WHEN dpa.dependentthoroughfare IS NOT NULL THEN dpa.dependentthoroughfare::text || ', '::text 32 | ELSE ''::text 33 | END) || 34 | CASE 35 | WHEN dpa.thoroughfare IS NOT NULL THEN dpa.thoroughfare::text || ', '::text 36 | ELSE ''::text 37 | END) || 38 | CASE 39 | WHEN dpa.doubledependentlocality IS NOT NULL THEN dpa.doubledependentlocality::text || ', '::text 40 | ELSE ''::text 41 | END) || 42 | CASE 43 | WHEN dpa.dependentlocality IS NOT NULL THEN dpa.dependentlocality::text || ', '::text 44 | ELSE ''::text 45 | END) || 46 | CASE 47 | WHEN dpa.posttown IS NOT NULL THEN dpa.posttown::text || ' '::text 48 | ELSE ''::text 49 | END) || 50 | CASE 51 | WHEN dpa.postcode IS NOT NULL THEN dpa.postcode 52 | ELSE ''::character varying 53 | END::text AS full_address_caps, ((((((((( 54 | CASE 55 | WHEN dpa.organisationname IS NOT NULL THEN initcap(dpa.organisationname::text) || ', '::text 56 | ELSE ''::text 57 | END || 58 | CASE 59 | WHEN dpa.departmentname IS NOT NULL THEN initcap(dpa.departmentname::text) || ', '::text 60 | ELSE ''::text 61 | END) || 62 | CASE 63 | WHEN dpa.subbuildingname IS NOT NULL THEN initcap(dpa.subbuildingname::text) || ', '::text 64 | ELSE ''::text 65 | END) || 66 | CASE 67 | WHEN dpa.buildingname IS NOT NULL THEN initcap(dpa.buildingname::text) || ', '::text 68 | ELSE ''::text 69 | END) || 70 | CASE 71 | WHEN dpa.buildingnumber > 0::numeric THEN dpa.buildingnumber::text || ' '::text 72 | ELSE ''::text 73 | END) || 74 | CASE 75 | WHEN dpa.dependentthoroughfare IS NOT NULL THEN initcap(dpa.dependentthoroughfare::text) || ', '::text 76 | ELSE ''::text 77 | END) || 78 | CASE 79 | WHEN dpa.thoroughfare IS NOT NULL THEN initcap(dpa.thoroughfare::text) || ', '::text 80 | ELSE ''::text 81 | END) || 82 | CASE 83 | WHEN dpa.doubledependentlocality IS NOT NULL THEN initcap(dpa.doubledependentlocality::text) || ', '::text 84 | ELSE ''::text 85 | END) || 86 | CASE 87 | WHEN dpa.dependentlocality IS NOT NULL THEN initcap(dpa.dependentlocality::text) || ', '::text 88 | ELSE ''::text 89 | END) || 90 | CASE 91 | WHEN dpa.posttown IS NOT NULL THEN initcap(dpa.posttown::text) || ' '::text 92 | ELSE ''::text 93 | END) || 94 | CASE 95 | WHEN dpa.postcode IS NOT NULL THEN dpa.postcode 96 | ELSE ''::character varying 97 | END::text AS full_address, 98 | CASE 99 | WHEN dpa.postcode IS NOT NULL THEN dpa.postcode 100 | ELSE ''::character varying 101 | END AS postcode 102 | FROM addressbase_premium.deliverypointaddress dpa 103 | LEFT JOIN addressbase_premium.basiclandpropertyunit blpu ON dpa.uprn = blpu.uprn; 104 | 105 | ALTER TABLE addressbase_premium.addresses_postal 106 | OWNER TO postgres; 107 | COMMENT ON VIEW addressbase_premium.addresses_postal 108 | IS 'Simple, nicely formatted view of AddressBase Premium postal addresses in PostgreSQL that has been imported with Loader 109 | 110 | Author: Mike Saunt, Astun Technology Ltd 111 | Version 0.1 - 15th November 2013 112 | 113 | https://github.com/AstunTechnology/Loader 114 | '; 115 | 116 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/addressbase/premium/pgdump/create-indexes.sql: -------------------------------------------------------------------------------- 1 | -- Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 2 | -- Licensed under [MIT License](https://git.io/fAxH0). 3 | 4 | -- Creates a spatial index for each table with geometry 5 | 6 | CREATE INDEX "basiclandpropertyunit_wkb_geometry_geom_idx" ON "addressbase_premium"."basiclandpropertyunit" USING GIST ("wkb_geometry"); 7 | CREATE INDEX "street_wkb_geometry_geom_idx" ON "addressbase_premium"."street" USING GIST ("wkb_geometry"); 8 | 9 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/addressbase/premium/pgdump/create-tables.sql: -------------------------------------------------------------------------------- 1 | -- Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 2 | -- Licensed under [MIT License](https://git.io/fAxH0). 3 | 4 | -- Drops any existing AddressBase Premium tables and creates fresh tables to recieve data 5 | 6 | DROP TABLE "addressbase_premium"."basiclandpropertyunit" CASCADE; 7 | DELETE FROM geometry_columns WHERE f_table_name = 'basiclandpropertyunit' AND f_table_schema = 'addressbase_premium'; 8 | 9 | CREATE TABLE "addressbase_premium"."basiclandpropertyunit" ( OGC_FID SERIAL, CONSTRAINT "basiclandpropertyunit_pk" PRIMARY KEY (OGC_FID) ); 10 | SELECT AddGeometryColumn('addressbase_premium','basiclandpropertyunit','wkb_geometry',27700,'POINT',2); 11 | ALTER TABLE "addressbase_premium"."basiclandpropertyunit" ADD COLUMN "uprn" FLOAT8; 12 | ALTER TABLE "addressbase_premium"."basiclandpropertyunit" ADD COLUMN "logicalstatus" INTEGER; 13 | ALTER TABLE "addressbase_premium"."basiclandpropertyunit" ADD COLUMN "blpustate" INTEGER; 14 | ALTER TABLE "addressbase_premium"."basiclandpropertyunit" ADD COLUMN "blpustatedate" VARCHAR; 15 | ALTER TABLE "addressbase_premium"."basiclandpropertyunit" ADD COLUMN "parentuprn" FLOAT8; 16 | ALTER TABLE "addressbase_premium"."basiclandpropertyunit" ADD COLUMN "rpc" INTEGER; 17 | ALTER TABLE "addressbase_premium"."basiclandpropertyunit" ADD COLUMN "localcustodiancode" INTEGER; 18 | ALTER TABLE "addressbase_premium"."basiclandpropertyunit" ADD COLUMN "country" VARCHAR(1); 19 | ALTER TABLE "addressbase_premium"."basiclandpropertyunit" ADD COLUMN "addressbasepostal" VARCHAR(1); 20 | ALTER TABLE "addressbase_premium"."basiclandpropertyunit" ADD COLUMN "postcodelocator" VARCHAR; 21 | ALTER TABLE "addressbase_premium"."basiclandpropertyunit" ADD COLUMN "multiocccount" INTEGER; 22 | ALTER TABLE "addressbase_premium"."basiclandpropertyunit" ADD COLUMN "changetype" VARCHAR; 23 | ALTER TABLE "addressbase_premium"."basiclandpropertyunit" ADD COLUMN "startdate" VARCHAR; 24 | ALTER TABLE "addressbase_premium"."basiclandpropertyunit" ADD COLUMN "enddate" VARCHAR; 25 | ALTER TABLE "addressbase_premium"."basiclandpropertyunit" ADD COLUMN "entrydate" VARCHAR; 26 | ALTER TABLE "addressbase_premium"."basiclandpropertyunit" ADD COLUMN "lastupdatedate" VARCHAR; 27 | 28 | DROP TABLE "addressbase_premium"."classification" CASCADE; 29 | CREATE TABLE "addressbase_premium"."classification" ( OGC_FID SERIAL, CONSTRAINT "classification_pk" PRIMARY KEY (OGC_FID) ); 30 | ALTER TABLE "addressbase_premium"."classification" ADD COLUMN "uprn" FLOAT8; 31 | ALTER TABLE "addressbase_premium"."classification" ADD COLUMN "classkey" VARCHAR; 32 | ALTER TABLE "addressbase_premium"."classification" ADD COLUMN "classificationcode" VARCHAR; 33 | ALTER TABLE "addressbase_premium"."classification" ADD COLUMN "classscheme" VARCHAR; 34 | ALTER TABLE "addressbase_premium"."classification" ADD COLUMN "schemeversion" FLOAT8; 35 | ALTER TABLE "addressbase_premium"."classification" ADD COLUMN "startdate" VARCHAR; 36 | ALTER TABLE "addressbase_premium"."classification" ADD COLUMN "entrydate" VARCHAR; 37 | ALTER TABLE "addressbase_premium"."classification" ADD COLUMN "lastupdatedate" VARCHAR; 38 | ALTER TABLE "addressbase_premium"."classification" ADD COLUMN "enddate" VARCHAR(10); 39 | 40 | DROP TABLE "addressbase_premium"."deliverypointaddress" CASCADE; 41 | 42 | CREATE TABLE "addressbase_premium"."deliverypointaddress" ( OGC_FID SERIAL, CONSTRAINT "deliverypointaddress_pk" PRIMARY KEY (OGC_FID) ); 43 | ALTER TABLE "addressbase_premium"."deliverypointaddress" ADD COLUMN "uprn" FLOAT8; 44 | ALTER TABLE "addressbase_premium"."deliverypointaddress" ADD COLUMN "udprn" INTEGER; 45 | ALTER TABLE "addressbase_premium"."deliverypointaddress" ADD COLUMN "organisationname" VARCHAR; 46 | ALTER TABLE "addressbase_premium"."deliverypointaddress" ADD COLUMN "departmentname" VARCHAR; 47 | ALTER TABLE "addressbase_premium"."deliverypointaddress" ADD COLUMN "subbuildingname" VARCHAR; 48 | ALTER TABLE "addressbase_premium"."deliverypointaddress" ADD COLUMN "buildingname" VARCHAR; 49 | ALTER TABLE "addressbase_premium"."deliverypointaddress" ADD COLUMN "buildingnumber" INTEGER; 50 | ALTER TABLE "addressbase_premium"."deliverypointaddress" ADD COLUMN "dependentthoroughfare" VARCHAR; 51 | ALTER TABLE "addressbase_premium"."deliverypointaddress" ADD COLUMN "thoroughfare" VARCHAR; 52 | ALTER TABLE "addressbase_premium"."deliverypointaddress" ADD COLUMN "doubledependentlocality" VARCHAR; 53 | ALTER TABLE "addressbase_premium"."deliverypointaddress" ADD COLUMN "dependentlocality" VARCHAR; 54 | ALTER TABLE "addressbase_premium"."deliverypointaddress" ADD COLUMN "posttown" VARCHAR; 55 | ALTER TABLE "addressbase_premium"."deliverypointaddress" ADD COLUMN "postcode" VARCHAR; 56 | ALTER TABLE "addressbase_premium"."deliverypointaddress" ADD COLUMN "postcodetype" VARCHAR; 57 | ALTER TABLE "addressbase_premium"."deliverypointaddress" ADD COLUMN "welshdependentthoroughfare" VARCHAR; 58 | ALTER TABLE "addressbase_premium"."deliverypointaddress" ADD COLUMN "welshthoroughfare" VARCHAR; 59 | ALTER TABLE "addressbase_premium"."deliverypointaddress" ADD COLUMN "welshdoubledependentlocality" VARCHAR; 60 | ALTER TABLE "addressbase_premium"."deliverypointaddress" ADD COLUMN "welshdependentlocality" VARCHAR; 61 | ALTER TABLE "addressbase_premium"."deliverypointaddress" ADD COLUMN "welshposttown" VARCHAR; 62 | ALTER TABLE "addressbase_premium"."deliverypointaddress" ADD COLUMN "poboxnumber" VARCHAR; 63 | ALTER TABLE "addressbase_premium"."deliverypointaddress" ADD COLUMN "deliverypointsuffix" VARCHAR; 64 | ALTER TABLE "addressbase_premium"."deliverypointaddress" ADD COLUMN "processdate" VARCHAR; 65 | ALTER TABLE "addressbase_premium"."deliverypointaddress" ADD COLUMN "startdate" VARCHAR; 66 | ALTER TABLE "addressbase_premium"."deliverypointaddress" ADD COLUMN "entrydate" VARCHAR; 67 | ALTER TABLE "addressbase_premium"."deliverypointaddress" ADD COLUMN "lastupdatedate" VARCHAR; 68 | 69 | DROP TABLE "addressbase_premium"."landpropertyidentifier" CASCADE; 70 | 71 | CREATE TABLE "addressbase_premium"."landpropertyidentifier" ( OGC_FID SERIAL, CONSTRAINT "landpropertyidentifier_pk" PRIMARY KEY (OGC_FID) ); 72 | ALTER TABLE "addressbase_premium"."landpropertyidentifier" ADD COLUMN "uprn" FLOAT8; 73 | ALTER TABLE "addressbase_premium"."landpropertyidentifier" ADD COLUMN "lpikey" VARCHAR; 74 | ALTER TABLE "addressbase_premium"."landpropertyidentifier" ADD COLUMN "logicalstatus" INTEGER; 75 | ALTER TABLE "addressbase_premium"."landpropertyidentifier" ADD COLUMN "saostartnumber" INTEGER; 76 | ALTER TABLE "addressbase_premium"."landpropertyidentifier" ADD COLUMN "saostartsuffix" VARCHAR; 77 | ALTER TABLE "addressbase_premium"."landpropertyidentifier" ADD COLUMN "saoendnumber" INTEGER; 78 | ALTER TABLE "addressbase_premium"."landpropertyidentifier" ADD COLUMN "saoendsuffix" VARCHAR; 79 | ALTER TABLE "addressbase_premium"."landpropertyidentifier" ADD COLUMN "saotext" VARCHAR; 80 | ALTER TABLE "addressbase_premium"."landpropertyidentifier" ADD COLUMN "paostartnumber" INTEGER; 81 | ALTER TABLE "addressbase_premium"."landpropertyidentifier" ADD COLUMN "paostartsuffix" VARCHAR; 82 | ALTER TABLE "addressbase_premium"."landpropertyidentifier" ADD COLUMN "paoendnumber" INTEGER; 83 | ALTER TABLE "addressbase_premium"."landpropertyidentifier" ADD COLUMN "paoendsuffix" VARCHAR; 84 | ALTER TABLE "addressbase_premium"."landpropertyidentifier" ADD COLUMN "paotext" VARCHAR; 85 | ALTER TABLE "addressbase_premium"."landpropertyidentifier" ADD COLUMN "usrn" INTEGER; 86 | ALTER TABLE "addressbase_premium"."landpropertyidentifier" ADD COLUMN "usrnmatchindicator" INTEGER; 87 | ALTER TABLE "addressbase_premium"."landpropertyidentifier" ADD COLUMN "officialflag" VARCHAR; 88 | ALTER TABLE "addressbase_premium"."landpropertyidentifier" ADD COLUMN "startdate" VARCHAR; 89 | ALTER TABLE "addressbase_premium"."landpropertyidentifier" ADD COLUMN "entrydate" VARCHAR; 90 | ALTER TABLE "addressbase_premium"."landpropertyidentifier" ADD COLUMN "lastupdatedate" VARCHAR; 91 | ALTER TABLE "addressbase_premium"."landpropertyidentifier" ADD COLUMN "lang" VARCHAR; 92 | ALTER TABLE "addressbase_premium"."landpropertyidentifier" ADD COLUMN "enddate" VARCHAR; 93 | 94 | DROP TABLE "addressbase_premium"."organisation" CASCADE; 95 | 96 | CREATE TABLE "addressbase_premium"."organisation" ( OGC_FID SERIAL, CONSTRAINT "organisation_pk" PRIMARY KEY (OGC_FID) ); 97 | ALTER TABLE "addressbase_premium"."organisation" ADD COLUMN "uprn" FLOAT8; 98 | ALTER TABLE "addressbase_premium"."organisation" ADD COLUMN "orgkey" VARCHAR; 99 | ALTER TABLE "addressbase_premium"."organisation" ADD COLUMN "organisation" VARCHAR; 100 | ALTER TABLE "addressbase_premium"."organisation" ADD COLUMN "startdate" VARCHAR; 101 | ALTER TABLE "addressbase_premium"."organisation" ADD COLUMN "entrydate" VARCHAR; 102 | ALTER TABLE "addressbase_premium"."organisation" ADD COLUMN "lastupdatedate" VARCHAR; 103 | ALTER TABLE "addressbase_premium"."organisation" ADD COLUMN "enddate" VARCHAR(10); 104 | 105 | DROP TABLE "addressbase_premium"."applicationcrossreference" CASCADE; 106 | 107 | CREATE TABLE "addressbase_premium"."applicationcrossreference" ( OGC_FID SERIAL, CONSTRAINT "applicationcrossreference_pk" PRIMARY KEY (OGC_FID) ); 108 | ALTER TABLE "addressbase_premium"."applicationcrossreference" ADD COLUMN "uprn" FLOAT8; 109 | ALTER TABLE "addressbase_premium"."applicationcrossreference" ADD COLUMN "xrefkey" VARCHAR; 110 | ALTER TABLE "addressbase_premium"."applicationcrossreference" ADD COLUMN "crossreference" VARCHAR; 111 | ALTER TABLE "addressbase_premium"."applicationcrossreference" ADD COLUMN "version" INTEGER; 112 | ALTER TABLE "addressbase_premium"."applicationcrossreference" ADD COLUMN "source" VARCHAR; 113 | ALTER TABLE "addressbase_premium"."applicationcrossreference" ADD COLUMN "startdate" VARCHAR; 114 | ALTER TABLE "addressbase_premium"."applicationcrossreference" ADD COLUMN "entrydate" VARCHAR; 115 | ALTER TABLE "addressbase_premium"."applicationcrossreference" ADD COLUMN "lastupdatedate" VARCHAR; 116 | ALTER TABLE "addressbase_premium"."applicationcrossreference" ADD COLUMN "enddate" VARCHAR(10); 117 | 118 | DROP TABLE "addressbase_premium"."street" CASCADE; 119 | DELETE FROM geometry_columns WHERE f_table_name = 'street' AND f_table_schema = 'addressbase_premium'; 120 | 121 | CREATE TABLE "addressbase_premium"."street" ( OGC_FID SERIAL, CONSTRAINT "street_pk" PRIMARY KEY (OGC_FID) ); 122 | SELECT AddGeometryColumn('addressbase_premium','street','wkb_geometry',27700,'MULTIPOINT',2); 123 | ALTER TABLE "addressbase_premium"."street" ADD COLUMN "usrn" INTEGER; 124 | ALTER TABLE "addressbase_premium"."street" ADD COLUMN "recordtype" INTEGER; 125 | ALTER TABLE "addressbase_premium"."street" ADD COLUMN "swaorgrefnaming" INTEGER; 126 | ALTER TABLE "addressbase_premium"."street" ADD COLUMN "state" INTEGER; 127 | ALTER TABLE "addressbase_premium"."street" ADD COLUMN "statedate" VARCHAR(10); 128 | ALTER TABLE "addressbase_premium"."street" ADD COLUMN "streetsurface" INTEGER; 129 | ALTER TABLE "addressbase_premium"."street" ADD COLUMN "streetclassification" INTEGER; 130 | ALTER TABLE "addressbase_premium"."street" ADD COLUMN "version" INTEGER; 131 | ALTER TABLE "addressbase_premium"."street" ADD COLUMN "streettolerance" INTEGER; 132 | ALTER TABLE "addressbase_premium"."street" ADD COLUMN "startdate" VARCHAR; 133 | ALTER TABLE "addressbase_premium"."street" ADD COLUMN "enddate" VARCHAR; 134 | ALTER TABLE "addressbase_premium"."street" ADD COLUMN "lastupdatedate" VARCHAR; 135 | 136 | DROP TABLE "addressbase_premium"."streetdescriptiveidentifier" CASCADE; 137 | 138 | CREATE TABLE "addressbase_premium"."streetdescriptiveidentifier" ( OGC_FID SERIAL, CONSTRAINT "streetdescriptiveidentifier_pk" PRIMARY KEY (OGC_FID) ); 139 | ALTER TABLE "addressbase_premium"."streetdescriptiveidentifier" ADD COLUMN "usrn" INTEGER; 140 | ALTER TABLE "addressbase_premium"."streetdescriptiveidentifier" ADD COLUMN "streetdescription" VARCHAR; 141 | ALTER TABLE "addressbase_premium"."streetdescriptiveidentifier" ADD COLUMN "locality" VARCHAR; 142 | ALTER TABLE "addressbase_premium"."streetdescriptiveidentifier" ADD COLUMN "townname" VARCHAR; 143 | ALTER TABLE "addressbase_premium"."streetdescriptiveidentifier" ADD COLUMN "administrativearea" VARCHAR; 144 | ALTER TABLE "addressbase_premium"."streetdescriptiveidentifier" ADD COLUMN "lang" VARCHAR(2); 145 | ALTER TABLE "addressbase_premium"."streetdescriptiveidentifier" ADD COLUMN "changetype" VARCHAR(1); 146 | ALTER TABLE "addressbase_premium"."streetdescriptiveidentifier" ADD COLUMN "startdate" VARCHAR(10); 147 | ALTER TABLE "addressbase_premium"."streetdescriptiveidentifier" ADD COLUMN "entrydate" VARCHAR(10); 148 | ALTER TABLE "addressbase_premium"."streetdescriptiveidentifier" ADD COLUMN "lastupdatedate" VARCHAR(10); 149 | ALTER TABLE "addressbase_premium"."streetdescriptiveidentifier" ADD COLUMN "enddate" VARCHAR(10); 150 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/addressbase/premium/pgdump/loader.config: -------------------------------------------------------------------------------- 1 | ## Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 2 | ## Licensed under [MIT License](https://git.io/fAxH0). 3 | 4 | # The directory containing your source files. 5 | # All supported files in the specified directory and 6 | # it's descendants will be loaded. 7 | src_dir=/path/to/source/data/folder 8 | 9 | # The directory used to store the SQL files created by the PGDump driver 10 | out_dir=/path/to/output/data/folder 11 | 12 | # The directory used to store temporary working files during loading. 13 | tmp_dir=/path/to/temp/folder 14 | 15 | # Use the PGDump driver which will output a SQL file to disk. 16 | # Don't create schema, tables or indexes at this point as we will do that 17 | # manually. 18 | # The PG_LIST_ALL_TABLES config is important for AddressBase Premium as not all 19 | # tables have geometry and therefore do not appear in the geometry_columns table 20 | ogr_cmd=ogr2ogr --config PG_LIST_ALL_TABLES YES --config PG_USE_COPY YES --config GML_EXPOSE_FID NO -skipfailures -lco spatial_index=off -lco create_table=off -lco schema=addressbase_premium -lco create_schema=off -f PGDump $output_dir/$base_file_name.sql $file_path 21 | 22 | # Use the AddressBase Premium prep class to tease out nested feature types 23 | prep_cmd=python prepgml4ogr.py $file_path prep_osgml.prep_addressbase_premium 24 | 25 | # Load the SQL file produced by the PGDump driver using psql and delete it once 26 | # done 27 | post_cmd=sh -c 'PGPASSWORD=postgres psql -h localhost -U postgres -d postgis -f $output_dir/$base_file_name.sql && rm $output_dir/$base_file_name.sql' 28 | 29 | gfs_file=../gfs/addressbase_premium_postgres.gfs 30 | 31 | debug=False 32 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/addressbase/premium/pgdump/readme.md: -------------------------------------------------------------------------------- 1 | # Loading OS AddressBase Premium using PGDump driver 2 | 3 | Using the [PGDump OGR](http://www.gdal.org/ogr/drv_pgdump.html) ogr driver generally is much quicker than the [Postgres driver](http://www.gdal.org/ogr/drv_pg.html) but requires more set-up. 4 | 5 | The files in this directory are provided to help you get started, you should update the schema name in sql files and paths, connection details etc. in loader.config to suit your environment. 6 | 7 | ## Example shell script 8 | 9 | # Assumes current directory is the root of the repository 10 | 11 | # (Re)create the tables in Postgres 12 | psql -U postgres -d postgis -f extras/ordnancesurvey/addressbase/premium/pgdump/create-tables.sql 13 | 14 | # Run the Loader from the python directory using the AddressBase 15 | # Premium PGDump config in this directory 16 | (cd python && python loader.py ../extras/ordnancesurvey/addressbase/premium/pgdump/loader.config) 17 | 18 | # Create spatial indexes 19 | psql -U postgres -d postgis -f extras/ordnancesurvey/addressbase/premium/pgdump/create-indexes.sql 20 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/addressbase/standard/addressbase_standard_addresses_postal.sql: -------------------------------------------------------------------------------- 1 | -- Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 2 | -- Licensed under [MIT License](https://git.io/fAxH0). 3 | 4 | -- View: addressbase_standard.addresses_postal 5 | 6 | -- DROP VIEW addressbase_standard.addresses_postal; 7 | 8 | CREATE OR REPLACE VIEW addressbase_standard.addresses_postal AS 9 | SELECT formatted_address.ogc_fid, formatted_address.wkb_geometry, formatted_address.uprn, formatted_address.rm_udprn, ((((ltrim(formatted_address.saon || formatted_address.paon) || formatted_address.street_description) || ', '::text) || formatted_address.localitytown) || ' '::text) || formatted_address.postcode::text AS full_address_caps, (initcap(((ltrim(formatted_address.saon || formatted_address.paon) || formatted_address.street_description) || ', '::text) || formatted_address.localitytown) || ' '::text) || formatted_address.postcode::text AS full_address, formatted_address.postcode 10 | FROM ( SELECT address.ogc_fid, address.wkb_geometry, address.uprn, address.rm_udprn, btrim(( 11 | CASE 12 | WHEN address.organisation_name IS NOT NULL THEN address.organisation_name::text || ', '::text 13 | ELSE ''::text 14 | END || 15 | CASE 16 | WHEN address.sub_building_name IS NOT NULL THEN address.sub_building_name::text || ', '::text 17 | ELSE ''::text 18 | END) || 19 | CASE 20 | WHEN address.building_name IS NOT NULL THEN address.building_name::text || ', '::text 21 | ELSE ''::text 22 | END) || ' '::text AS saon, ltrim( 23 | CASE 24 | WHEN address.building_number IS NOT NULL THEN address.building_number::text 25 | ELSE ''::text 26 | END || 27 | CASE 28 | WHEN address.dependent_thoroughfare_name IS NOT NULL THEN (' '::text || address.dependent_thoroughfare_name::text) || ', '::text 29 | ELSE ' '::text 30 | END) AS paon, 31 | CASE 32 | WHEN address.throughfare_name IS NOT NULL THEN address.throughfare_name::text 33 | ELSE ''::text 34 | END AS street_description, 35 | CASE 36 | WHEN address.dependent_locality IS NOT NULL THEN address.dependent_locality::text || ', '::text 37 | ELSE ''::text 38 | END || 39 | CASE 40 | WHEN address.post_town IS NOT NULL THEN address.post_town::text 41 | ELSE ''::text 42 | END AS localitytown, address.postcode 43 | FROM addressbase_standard.address 44 | WHERE address.class::text <> 'PP'::text AND address.class::text <> 'PS'::text) formatted_address; 45 | 46 | ALTER TABLE addressbase_standard.addresses_postal 47 | OWNER TO postgres; 48 | COMMENT ON VIEW addressbase_standard.addresses_postal 49 | IS 'Simple, nicely formatted view of AddressBase (standard) addresses in PostgreSQL that has been imported with Loader! 50 | 51 | Author: Mike Saunt, Astun Technology Ltd 52 | Version 0.1 - 15th November 2013 53 | 54 | https://github.com/AstunTechnology/Loader 55 | '; 56 | 57 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/osmm/itn/pgdump/create-indexes.sql: -------------------------------------------------------------------------------- 1 | -- Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 2 | -- Licensed under [MIT License](https://git.io/fAxH0). 3 | 4 | CREATE INDEX "roadlink_wkb_geometry_geom_idx" ON "osmm_itn"."roadlink" USING GIST ("wkb_geometry"); 5 | CREATE INDEX "roadnode_wkb_geometry_geom_idx" ON "osmm_itn"."roadnode" USING GIST ("wkb_geometry"); 6 | CREATE INDEX "ferrynode_wkb_geometry_geom_idx" ON "osmm_itn"."ferrynode" USING GIST ("wkb_geometry"); 7 | CREATE INDEX "informationpoint_wkb_geometry_geom_idx" ON "osmm_itn"."informationpoint" USING GIST ("wkb_geometry"); 8 | CREATE INDEX "roadlinkinformation_wkb_geometry_geom_idx" ON "osmm_itn"."roadlinkinformation" USING GIST ("wkb_geometry"); 9 | CREATE INDEX "roadrouteinformation_wkb_geometry_geom_idx" ON "osmm_itn"."roadrouteinformation" USING GIST ("wkb_geometry"); 10 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/osmm/itn/pgdump/loader.config: -------------------------------------------------------------------------------- 1 | ## Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 2 | ## Licensed under [MIT License](https://git.io/fAxH0). 3 | 4 | # The directory containing source data All .gml / .gz files in the specified 5 | # directory and it's descendants will be loaded. 6 | src_dir=/path/to/source/folder 7 | 8 | # The output directory is specified in ogr_cmd as the location to write the SQL 9 | # files to. 10 | out_dir=/path/to/output/folder 11 | 12 | # The directory used to store temporary working files 13 | # during loading. 14 | tmp_dir=/path/to/temp/folder 15 | 16 | # Use the PGDump driver which will output a SQL file to disk. 17 | # Don't create schema, tables or indexes at this point as we will do that 18 | # manually but specify the schema so that the SQL files include the appropriate 19 | # schema. The PG_LIST_ALL_TABLES config is important for ITN as not all tables 20 | # have geometry and therefore do not appear in the geometry_columns table 21 | ogr_cmd=ogr2ogr --config PG_USE_COPY YES --config PG_LIST_ALL_TABLES YES --config GML_EXPOSE_FID NO -skipfailures -lco spatial_index=off -lco create_table=off -lco schema=osmm_itn -lco create_schema=off -f PGDump $output_dir/$base_file_name.sql $file_path 22 | 23 | # Use the OSMM ITN prep class which exposes references between the feature 24 | # types and formats dateTimeQualifier values 25 | prep_cmd=python prepgml4ogr.py $file_path prep_osgml.prep_osmm_itn 26 | 27 | # Once ogr2ogr has created the SQL from the source GML load the SQL file using 28 | # the command line PostgreSQL client psql 29 | post_cmd=psql -U postgres -d postgis -h localhost -f $output_dir/$base_file_name.sql 30 | 31 | gfs_file=../gfs/osmm_itn_postgres.gfs 32 | 33 | debug=False 34 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/osmm/itn/views.sql: -------------------------------------------------------------------------------- 1 | -- Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 2 | -- Licensed under [MIT License](https://git.io/fAxH0). 3 | 4 | -- Lookup between road and roadlink on fid 5 | CREATE OR REPLACE VIEW osmm_itn.road_roadlink AS 6 | SELECT road_fid, 7 | replace(roadlink_fid, '#', '') AS roadlink_fid 8 | FROM 9 | (SELECT fid AS road_fid, 10 | unnest(networkmember_href) AS roadlink_fid 11 | FROM osmm_itn.road) AS a; 12 | 13 | -- Lookup between roadlink and the roadnodes at it's start and end 14 | CREATE OR REPLACE VIEW osmm_itn.roadlink_roadnode AS 15 | SELECT a.roadlink_fid, 16 | replace(a.roadnode_fid::text, '#', '') AS roadnode_fid, 17 | a.directednode_orientation, 18 | a.directednode_gradeseparation 19 | FROM 20 | (SELECT roadlink.fid AS roadlink_fid, 21 | unnest(roadlink.directednode_href) AS roadnode_fid, 22 | unnest(roadlink.directednode_orientation) AS directednode_orientation, 23 | unnest(roadlink.directednode_gradeseparation) AS directednode_gradeseparation 24 | FROM osmm_itn.roadlink) AS a; 25 | 26 | -- Lookup between ferrylink and ferrynode on fid 27 | CREATE OR REPLACE VIEW osmm_itn.ferrylink_ferrynode AS 28 | SELECT ferrylink_fid, 29 | replace(ferrynode_fid, '#', '') AS ferrynode_fid 30 | FROM 31 | (SELECT fid AS ferrylink_fid, 32 | unnest(directednode_href) AS ferrynode_fid 33 | FROM osmm_itn.ferrylink) AS a; 34 | 35 | -- Lookup between ferryterminal and ferrynode on fid. A duplicate of 36 | -- ferryterminal_roadnode as ferryterminal.referencetonetwork_href references 37 | -- both ferrynode and roadnode 38 | CREATE OR REPLACE VIEW osmm_itn.ferryterminal_ferrynode AS 39 | SELECT ferryterminal_fid, 40 | replace(ferrynode_fid, '#', '') AS ferrynode_fid 41 | FROM 42 | (SELECT fid AS ferryterminal_fid, 43 | unnest(referencetonetwork_href) AS ferrynode_fid 44 | FROM osmm_itn.ferryterminal) AS a; 45 | 46 | -- Lookup between ferryterminal and roadnode on fid. A duplicate of 47 | -- ferryterminal_ferrynode as ferryterminal.referencetonetwork_href references 48 | -- both ferrynode and roadnode 49 | CREATE OR REPLACE VIEW osmm_itn.ferryterminal_roadnode AS 50 | SELECT ferryterminal_fid, 51 | replace(roadnode_fid, '#', '') AS roadnode_fid 52 | FROM 53 | (SELECT fid AS ferryterminal_fid, 54 | unnest(referencetonetwork_href) AS roadnode_fid 55 | FROM osmm_itn.ferryterminal) AS a; 56 | 57 | -- Lookup between roadrouteinformation and roadlink on fid including the order 58 | -- of each roadlink associated with a given roadrouteinformation row 59 | CREATE OR REPLACE VIEW osmm_itn.roadrouteinformation_roadlink AS 60 | SELECT roadrouteinformation_fid, 61 | replace(roadlink_fid, '#', '') AS roadlink_fid, 62 | roadlink_order 63 | FROM 64 | (SELECT fid AS roadrouteinformation_fid, 65 | unnest(directedlink_href) AS roadlink_fid, 66 | generate_subscripts(directedlink_href, 1) AS roadlink_order 67 | FROM osmm_itn.roadrouteinformation) AS a; 68 | 69 | -- Lookup between roadlinkinformation and roadlink on fid 70 | -- Used to link in additional RRI to the network 71 | CREATE OR REPLACE VIEW osmm_itn.roadlinkinformation_roadlink AS 72 | SELECT fid AS roadlinkinformation_fid, 73 | replace(referencetoroadlink_href, '#', '') AS roadlink_fid 74 | FROM osmm_itn.roadlinkinformation; 75 | 76 | -- Each roadlink with associated roadname(s) and fid of road in case more info 77 | -- is required 78 | CREATE OR REPLACE VIEW osmm_itn.roads AS 79 | SELECT array_to_string(road.roadname, ', ') AS roadname, 80 | road.fid AS road_fid, 81 | roadlink.* 82 | FROM osmm_itn.roadlink AS roadlink 83 | LEFT JOIN osmm_itn.road_roadlink AS road_roadlink ON (roadlink.fid = road_roadlink.roadlink_fid) 84 | LEFT JOIN osmm_itn.road AS road ON (road_roadlink.road_fid = road.fid); 85 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/osmm/topo/mapserver/mastermap.inc: -------------------------------------------------------------------------------- 1 | ## Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 2 | ## Licensed under [MIT License](https://git.io/fAxH0). 3 | 4 | LAYER 5 | METADATA 6 | WMS_TITLE "TopoArea" 7 | END 8 | GROUP "base_OS" 9 | NAME TopoArea 10 | TYPE POLYGON 11 | STATUS DEFAULT 12 | INCLUDE "pg_connection.inc" 13 | PROCESSING "CLOSE_CONNECTION=DEFER" 14 | DATA "wkb_geometry FROM (SELECT wkb_geometry, featurecode, ogc_fid FROM mapping.topographicarea) AS FOO USING UNIQUE ogc_fid USING SRID=27700" 15 | MINSCALEDENOM 1 16 | MAXSCALEDENOM 2500 17 | SYMBOLSCALEDENOM 1200 18 | OPACITY 40 19 | CLASSITEM "featurecode" 20 | CLASS 21 | EXPRESSION "10021" #Building Fill 22 | STYLE 23 | COLOR 252 226 197 24 | OUTLINECOLOR 0 0 0 25 | END 26 | END 27 | CLASS 28 | EXPRESSION "10053" 29 | STYLE 30 | #COLOR 255 255 204 31 | OUTLINECOLOR 212 212 212 32 | END 33 | END 34 | CLASS 35 | EXPRESSION ([featurecode] EQ 10111 OR [featurecode] == 20014 ) 36 | STYLE 37 | #COLOR 204 255 153 38 | OUTLINECOLOR 212 212 212 39 | END 40 | END 41 | 42 | CLASS 43 | EXPRESSION "10056" 44 | STYLE 45 | #COLOR 204 255 153 46 | OUTLINECOLOR 212 212 212 47 | END 48 | END 49 | CLASS 50 | EXPRESSION "10054" 51 | STYLE 52 | #COLOR 204 204 153 53 | OUTLINECOLOR 212 212 212 54 | END 55 | END 56 | CLASS 57 | EXPRESSION "10172" 58 | STYLE 59 | COLOR 220 220 220 60 | OUTLINECOLOR 220 220 220 61 | END 62 | END 63 | CLASS 64 | EXPRESSION "10089" 65 | STYLE 66 | COLOR 224 238 253 67 | END 68 | END 69 | CLASS 70 | EXPRESSION ([featurecode] EQ 20006 OR [featurecode] == 20022 ) 71 | STYLE 72 | COLOR 0 0 0 73 | OUTLINECOLOR 212 212 212 74 | SYMBOL "0384" 75 | END 76 | END 77 | CLASS 78 | EXPRESSION "10123" 79 | STYLE 80 | COLOR 220 220 220 81 | OUTLINECOLOR 220 220 220 82 | END 83 | END 84 | CLASS 85 | EXPRESSION "10185" 86 | STYLE 87 | #COLOR 255 204 204 88 | OUTLINECOLOR 212 212 212 89 | END 90 | END 91 | CLASS 92 | EXPRESSION "20012" 93 | STYLE 94 | COLOR 0 0 0 95 | OUTLINECOLOR 212 212 212 96 | SYMBOL "0392" 97 | END 98 | END 99 | CLASS 100 | EXPRESSION "20013" 101 | STYLE 102 | COLOR 0 0 0 103 | OUTLINECOLOR 204 204 204 104 | SYMBOL "0379" 105 | END 106 | END 107 | CLASS 108 | EXPRESSION "20008" 109 | STYLE 110 | COLOR 0 0 0 111 | OUTLINECOLOR 212 212 212 112 | SYMBOL "0386" 113 | END 114 | END 115 | CLASS 116 | EXPRESSION "20023" 117 | STYLE 118 | COLOR 0 0 0 119 | OUTLINECOLOR 212 212 212 120 | SYMBOL "0390" 121 | END 122 | END 123 | CLASS 124 | EXPRESSION "10062" 125 | STYLE 126 | COLOR 0 0 0 127 | OUTLINECOLOR 212 212 212 128 | SYMBOL "0323" 129 | END 130 | END 131 | CLASS 132 | EXPRESSION "10183" 133 | STYLE 134 | #COLOR 204 204 153 135 | OUTLINECOLOR 212 212 212 136 | END 137 | END 138 | CLASS 139 | EXPRESSION "20006" 140 | STYLE 141 | COLOR 0 0 0 142 | OUTLINECOLOR 212 212 212 143 | SYMBOL "0385Scattered" 144 | END 145 | END 146 | CLASS 147 | EXPRESSION "20002" 148 | STYLE 149 | COLOR 0 0 0 150 | OUTLINECOLOR 212 212 212 151 | SYMBOL "0382" 152 | END 153 | END 154 | CLASS 155 | EXPRESSION "0000" 156 | STYLE 157 | COLOR 0 0 0 158 | OUTLINECOLOR 255 255 255 159 | SYMBOL "0000RoadTrafficCalming" 160 | END 161 | END 162 | CLASS 163 | EXPRESSION "10145" 164 | STYLE 165 | #COLOR 255 255 153 166 | OUTLINECOLOR 212 212 212 167 | END 168 | END 169 | CLASS 170 | EXPRESSION "10167" 171 | STYLE 172 | COLOR 224 224 224 173 | OUTLINECOLOR 204 204 204 174 | END 175 | END 176 | CLASS 177 | EXPRESSION "20005" 178 | STYLE 179 | #COLOR 224 224 224 180 | OUTLINECOLOR 212 212 212 181 | SYMBOL "0380Scattered" 182 | END 183 | END 184 | CLASS 185 | EXPRESSION "" 186 | STYLE 187 | #COLOR 204 253 157 188 | OUTLINECOLOR 212 212 212 189 | END 190 | END 191 | END 192 | 193 | LAYER 194 | METADATA 195 | WMS_TITLE "TopoLine" 196 | END 197 | GROUP "base_OS" 198 | NAME TopoLine 199 | TYPE LINE 200 | STATUS DEFAULT 201 | INCLUDE "pg_connection.inc" 202 | DATA "wkb_geometry FROM (SELECT featurecode, wkb_geometry, ogc_fid FROM mapping.topographicline) AS FOO USING UNIQUE ogc_fid USING SRID=27700" 203 | PROCESSING "CLOSE_CONNECTION=DEFER" 204 | MINSCALEDENOM 1 205 | MAXSCALEDENOM 2500 206 | SYMBOLSCALEDENOM 1200 207 | OPACITY 50 208 | CLASSITEM "featurecode" 209 | CLASS 210 | EXPRESSION ([featurecode] == 10017 OR [featurecode] == 10019 OR [featurecode] == 1002) 211 | STYLE 212 | COLOR 0 0 0 213 | WIDTH 1 214 | END 215 | END 216 | CLASS 217 | EXPRESSION "10019" 218 | STYLE 219 | COLOR 0 0 0 220 | WIDTH 1 221 | END 222 | END 223 | CLASS 224 | EXPRESSION "10023" 225 | STYLE 226 | COLOR 0 0 0 227 | WIDTH 1 228 | END 229 | END 230 | CLASS 231 | EXPRESSION "10113" 232 | STYLE 233 | 234 | END 235 | END 236 | CLASS 237 | EXPRESSION "10168" 238 | STYLE 239 | SYMBOL "dashed" 240 | SIZE 1 241 | COLOR 0 0 0 242 | PATTERN 2 2 END 243 | END 244 | END 245 | CLASS 246 | EXPRESSION "10173" 247 | STYLE 248 | SYMBOL "dashed" 249 | SIZE 1 250 | COLOR 0 0 0 251 | END 252 | END 253 | CLASS 254 | EXPRESSION "10018" 255 | STYLE 256 | COLOR 0 0 0 257 | END 258 | END 259 | CLASS 260 | STYLE 261 | COLOR 153 153 153 262 | END 263 | END 264 | END 265 | 266 | LAYER 267 | METADATA 268 | WMS_TITLE "CartoText" 269 | END 270 | GROUP "base_OS" 271 | NAME CartoText 272 | TYPE ANNOTATION 273 | STATUS DEFAULT 274 | INCLUDE "pg_connection.inc" 275 | DATA "wkb_geometry FROM (SELECT featurecode, wkb_geometry, textstring, ogc_fid, orientation/10 as orientdeg, CASE anchorposition WHEN 2 THEN 'lr' WHEN 5 THEN 'lc' WHEN 8 THEN 'll' WHEN 1 THEN 'cr' WHEN 4 THEN 'cc' WHEN 7 THEN 'cl' WHEN 0 THEN 'ur' WHEN 3 THEN 'uc' WHEN 6 THEN 'ul' END as position FROM mapping.cartographictext) AS foo USING UNIQUE ogc_fid USING SRID=27700" 276 | LABELITEM "textstring" 277 | MINSCALEDENOM 1 278 | MAXSCALEDENOM 2500 279 | SYMBOLSCALEDENOM 1200 280 | OPACITY 50 281 | CLASSITEM "featurecode" 282 | CLASS 283 | EXPRESSION ([featurecode] == 10026 OR [featurecode] == 10166 OR [featurecode] == 10178 OR [featurecode] == 10184) 284 | LABEL 285 | FONT "arial" 286 | TYPE TRUETYPE 287 | COLOR 0 0 0 288 | OUTLINECOLOR 255 255 255 289 | SIZE 7 290 | POSITION [position] 291 | ANGLE [orientdeg] 292 | END 293 | END 294 | CLASS 295 | EXPRESSION ([featurecode] == 10033) 296 | LABEL 297 | FONT "arialbd" 298 | TYPE TRUETYPE 299 | COLOR 153 153 153 300 | SIZE 10 301 | POSITION [position] 302 | ANGLE [orientdeg] 303 | END 304 | END 305 | CLASS 306 | EXPRESSION ([featurecode] == 10043) 307 | LABEL 308 | FONT "arialbd" 309 | TYPE TRUETYPE 310 | COLOR 0 0 0 311 | SIZE 8 312 | POSITION [position] 313 | ANGLE [orientdeg] 314 | END 315 | END 316 | CLASS 317 | EXPRESSION ([featurecode] == 10059) 318 | LABEL 319 | FONT "arial" 320 | TYPE TRUETYPE 321 | COLOR 0 0 0 322 | SIZE 8 323 | POSITION [position] 324 | ANGLE [orientdeg] 325 | END 326 | END 327 | CLASS 328 | EXPRESSION ([featurecode] == 10069) 329 | LABEL 330 | FONT "ariali" 331 | TYPE TRUETYPE 332 | COLOR 0 0 0 333 | SIZE 6 334 | POSITION [position] 335 | ANGLE [orientdeg] 336 | END 337 | END 338 | CLASS 339 | EXPRESSION ([featurecode] == 10074) 340 | LABEL 341 | FONT "ariali" 342 | TYPE TRUETYPE 343 | COLOR 0 0 0 344 | SIZE 9 345 | POSITION [position] 346 | ANGLE [orientdeg] 347 | END 348 | END 349 | CLASS 350 | EXPRESSION ([featurecode] == 10090) 351 | LABEL 352 | FONT "ariali" 353 | TYPE TRUETYPE 354 | COLOR 0 02 0 355 | SIZE 8 356 | POSITION [position] 357 | ANGLE [orientdeg] 358 | END 359 | END 360 | CLASS 361 | EXPRESSION ([featurecode] == 10102 OR [featurecode] == 10133) 362 | LABEL 363 | FONT "arial" 364 | TYPE TRUETYPE 365 | COLOR 0 0 0 366 | SIZE 6 367 | POSITION [position] 368 | ANGLE [orientdeg] 369 | END 370 | END 371 | CLASS 372 | EXPRESSION ([featurecode] == 10169) 373 | LABEL 374 | FONT "arialbd" 375 | TYPE TRUETYPE 376 | ANTIALIAS TRUE 377 | COLOR 0 0 0 378 | OUTLINECOLOR 255 255 255 379 | SIZE 8 380 | POSITION [position] 381 | ANGLE [orientdeg] 382 | END 383 | END 384 | CLASS 385 | EXPRESSION ([featurecode] == 10198) 386 | LABEL 387 | FONT "arial" 388 | TYPE TRUETYPE 389 | ANTIALIAS TRUE 390 | COLOR 0 0 0 391 | SIZE 7 392 | POSITION [position] 393 | ANGLE [orientdeg] 394 | END 395 | END 396 | END 397 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/osmm/topo/mapserver/readme.markdown: -------------------------------------------------------------------------------- 1 | # A mapserver include file for styling Mastermap data loaded using Loader# 2 | 3 | Contact: support [at] astuntechnology.com 4 | 5 | A mapserver include file for Ordnance Survey Mastermap topographic data as loaded into PostgreSQL via Loader. 6 | 7 | ## Assumptions ## 8 | 9 | * Assumes that the data is in a PostgreSQL database- edit this if your data is stored in a different vector format. 10 | * The connection details for the database are stored in a file called pg\_connection.inc, stored in the same directory as your mapserver map file. Edit this as appropriate. See [here](http://mapserver.org/input/vector/postgis.html#data-access-connection-method) for information on the connection parameters that should be in pg\_connection.inc 11 | * The data is in a schema called "mapping"- edit as appropriate 12 | 13 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/osmm/topo/pgdump/create-indexes.sql: -------------------------------------------------------------------------------- 1 | -- Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 2 | -- Licensed under [MIT License](https://git.io/fAxH0). 3 | 4 | -- Creates a spatial index for each OSMM Topo table 5 | 6 | CREATE INDEX "boundaryline_geom_idx" ON "osmm_topo"."boundaryline" USING GIST ("wkb_geometry"); 7 | CREATE INDEX "cartographicsymbol_geom_idx" ON "osmm_topo"."cartographicsymbol" USING GIST ("wkb_geometry"); 8 | CREATE INDEX "cartographictext_geom_idx" ON "osmm_topo"."cartographictext" USING GIST ("wkb_geometry"); 9 | CREATE INDEX "topographicarea_geom_idx" ON "osmm_topo"."topographicarea" USING GIST ("wkb_geometry"); 10 | CREATE INDEX "topographicline_geom_idx" ON "osmm_topo"."topographicline" USING GIST ("wkb_geometry"); 11 | CREATE INDEX "topographicpoint_geom_idx" ON "osmm_topo"."topographicpoint" USING GIST ("wkb_geometry"); 12 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/osmm/topo/pgdump/create-tables.sql: -------------------------------------------------------------------------------- 1 | -- Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 2 | -- Licensed under [MIT License](https://git.io/fAxH0). 3 | 4 | -- Drops any existing OSMM Topo related tables and creates fresh tables ready to receive data 5 | 6 | DROP TABLE IF EXISTS "osmm_topo"."boundaryline" CASCADE; 7 | DELETE FROM geometry_columns WHERE f_table_name = 'boundaryline' AND f_table_schema = 'osmm_topo'; 8 | 9 | CREATE TABLE "osmm_topo"."boundaryline" ( OGC_FID SERIAL, CONSTRAINT "boundaryline_pk" PRIMARY KEY (OGC_FID) ); 10 | SELECT AddGeometryColumn('osmm_topo','boundaryline','wkb_geometry',27700,'MULTILINESTRING',2); 11 | ALTER TABLE "osmm_topo"."boundaryline" ADD COLUMN "fid" VARCHAR; 12 | ALTER TABLE "osmm_topo"."boundaryline" ADD COLUMN "featurecode" INTEGER; 13 | ALTER TABLE "osmm_topo"."boundaryline" ADD COLUMN "version" INTEGER; 14 | ALTER TABLE "osmm_topo"."boundaryline" ADD COLUMN "versiondate" VARCHAR; 15 | ALTER TABLE "osmm_topo"."boundaryline" ADD COLUMN "theme" VARCHAR[]; 16 | ALTER TABLE "osmm_topo"."boundaryline" ADD COLUMN "accuracyofposition" VARCHAR; 17 | ALTER TABLE "osmm_topo"."boundaryline" ADD COLUMN "changedate" VARCHAR[]; 18 | ALTER TABLE "osmm_topo"."boundaryline" ADD COLUMN "reasonforchange" VARCHAR[]; 19 | ALTER TABLE "osmm_topo"."boundaryline" ADD COLUMN "descriptivegroup" VARCHAR[]; 20 | ALTER TABLE "osmm_topo"."boundaryline" ADD COLUMN "descriptiveterm" VARCHAR[]; 21 | ALTER TABLE "osmm_topo"."boundaryline" ADD COLUMN "make" VARCHAR; 22 | ALTER TABLE "osmm_topo"."boundaryline" ADD COLUMN "physicallevel" INTEGER; 23 | ALTER TABLE "osmm_topo"."boundaryline" ADD COLUMN "physicalpresence" VARCHAR; 24 | ALTER TABLE "osmm_topo"."boundaryline" ADD COLUMN "filename" VARCHAR; 25 | ALTER TABLE "osmm_topo"."boundaryline" ADD COLUMN "style_code" INTEGER; 26 | ALTER TABLE "osmm_topo"."boundaryline" ADD COLUMN "style_description" VARCHAR; 27 | 28 | DROP TABLE IF EXISTS "osmm_topo"."cartographicsymbol" CASCADE; 29 | DELETE FROM geometry_columns WHERE f_table_name = 'cartographicsymbol' AND f_table_schema = 'osmm_topo'; 30 | 31 | CREATE TABLE "osmm_topo"."cartographicsymbol" ( OGC_FID SERIAL, CONSTRAINT "cartographicsymbol_pk" PRIMARY KEY (OGC_FID) ); 32 | SELECT AddGeometryColumn('osmm_topo','cartographicsymbol','wkb_geometry',27700,'POINT',2); 33 | ALTER TABLE "osmm_topo"."cartographicsymbol" ADD COLUMN "fid" VARCHAR; 34 | ALTER TABLE "osmm_topo"."cartographicsymbol" ADD COLUMN "featurecode" INTEGER; 35 | ALTER TABLE "osmm_topo"."cartographicsymbol" ADD COLUMN "version" INTEGER; 36 | ALTER TABLE "osmm_topo"."cartographicsymbol" ADD COLUMN "versiondate" VARCHAR; 37 | ALTER TABLE "osmm_topo"."cartographicsymbol" ADD COLUMN "theme" VARCHAR[]; 38 | ALTER TABLE "osmm_topo"."cartographicsymbol" ADD COLUMN "changedate" VARCHAR[]; 39 | ALTER TABLE "osmm_topo"."cartographicsymbol" ADD COLUMN "reasonforchange" VARCHAR[]; 40 | ALTER TABLE "osmm_topo"."cartographicsymbol" ADD COLUMN "descriptivegroup" VARCHAR[]; 41 | ALTER TABLE "osmm_topo"."cartographicsymbol" ADD COLUMN "descriptiveterm" VARCHAR[]; 42 | ALTER TABLE "osmm_topo"."cartographicsymbol" ADD COLUMN "orientation" INTEGER; 43 | ALTER TABLE "osmm_topo"."cartographicsymbol" ADD COLUMN "physicallevel" INTEGER; 44 | ALTER TABLE "osmm_topo"."cartographicsymbol" ADD COLUMN "physicalpresence" VARCHAR; 45 | ALTER TABLE "osmm_topo"."cartographicsymbol" ADD COLUMN "referencetofeature" VARCHAR; 46 | ALTER TABLE "osmm_topo"."cartographicsymbol" ADD COLUMN "filename" VARCHAR; 47 | ALTER TABLE "osmm_topo"."cartographicsymbol" ADD COLUMN "style_code" INTEGER; 48 | ALTER TABLE "osmm_topo"."cartographicsymbol" ADD COLUMN "style_description" VARCHAR; 49 | 50 | DROP TABLE IF EXISTS "osmm_topo"."cartographictext" CASCADE; 51 | DELETE FROM geometry_columns WHERE f_table_name = 'cartographictext' AND f_table_schema = 'osmm_topo'; 52 | 53 | CREATE TABLE "osmm_topo"."cartographictext" ( OGC_FID SERIAL, CONSTRAINT "cartographictext_pk" PRIMARY KEY (OGC_FID) ); 54 | SELECT AddGeometryColumn('osmm_topo','cartographictext','wkb_geometry',27700,'POINT',2); 55 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "fid" VARCHAR; 56 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "featurecode" INTEGER; 57 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "version" INTEGER; 58 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "versiondate" VARCHAR; 59 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "theme" VARCHAR[]; 60 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "changedate" VARCHAR[]; 61 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "reasonforchange" VARCHAR[]; 62 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "descriptivegroup" VARCHAR[]; 63 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "descriptiveterm" VARCHAR[]; 64 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "make" VARCHAR; 65 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "physicallevel" INTEGER; 66 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "physicalpresence" VARCHAR; 67 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "anchorposition" INTEGER; 68 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "font" INTEGER; 69 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "height" FLOAT8; 70 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "orientation" INTEGER; 71 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "textstring" VARCHAR; 72 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "filename" VARCHAR; 73 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "style_code" INTEGER; 74 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "style_description" VARCHAR; 75 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "anchor" VARCHAR; 76 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "geo_x" REAL; 77 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "geo_y" REAL; 78 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "font_code" INTEGER; 79 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "colour_code" INTEGER; 80 | ALTER TABLE "osmm_topo"."cartographictext" ADD COLUMN "rotation" REAL; 81 | 82 | DROP TABLE IF EXISTS "osmm_topo"."topographicarea" CASCADE; 83 | DELETE FROM geometry_columns WHERE f_table_name = 'topographicarea' AND f_table_schema = 'osmm_topo'; 84 | 85 | CREATE TABLE "osmm_topo"."topographicarea" ( OGC_FID SERIAL, CONSTRAINT "topographicarea_pk" PRIMARY KEY (OGC_FID) ); 86 | SELECT AddGeometryColumn('osmm_topo','topographicarea','wkb_geometry',27700,'POLYGON',2); 87 | ALTER TABLE "osmm_topo"."topographicarea" ADD COLUMN "fid" VARCHAR; 88 | ALTER TABLE "osmm_topo"."topographicarea" ADD COLUMN "featurecode" INTEGER; 89 | ALTER TABLE "osmm_topo"."topographicarea" ADD COLUMN "version" INTEGER; 90 | ALTER TABLE "osmm_topo"."topographicarea" ADD COLUMN "versiondate" VARCHAR; 91 | ALTER TABLE "osmm_topo"."topographicarea" ADD COLUMN "theme" VARCHAR[]; 92 | ALTER TABLE "osmm_topo"."topographicarea" ADD COLUMN "calculatedareavalue" FLOAT8; 93 | ALTER TABLE "osmm_topo"."topographicarea" ADD COLUMN "changedate" VARCHAR[]; 94 | ALTER TABLE "osmm_topo"."topographicarea" ADD COLUMN "reasonforchange" VARCHAR[]; 95 | ALTER TABLE "osmm_topo"."topographicarea" ADD COLUMN "descriptivegroup" VARCHAR[]; 96 | ALTER TABLE "osmm_topo"."topographicarea" ADD COLUMN "descriptiveterm" VARCHAR[]; 97 | ALTER TABLE "osmm_topo"."topographicarea" ADD COLUMN "make" VARCHAR; 98 | ALTER TABLE "osmm_topo"."topographicarea" ADD COLUMN "physicallevel" INTEGER; 99 | ALTER TABLE "osmm_topo"."topographicarea" ADD COLUMN "physicalpresence" VARCHAR; 100 | ALTER TABLE "osmm_topo"."topographicarea" ADD COLUMN "filename" VARCHAR; 101 | ALTER TABLE "osmm_topo"."topographicarea" ADD COLUMN "style_code" INTEGER; 102 | ALTER TABLE "osmm_topo"."topographicarea" ADD COLUMN "style_description" VARCHAR; 103 | 104 | DROP TABLE IF EXISTS "osmm_topo"."topographicline" CASCADE; 105 | DELETE FROM geometry_columns WHERE f_table_name = 'topographicline' AND f_table_schema = 'osmm_topo'; 106 | 107 | CREATE TABLE "osmm_topo"."topographicline" ( OGC_FID SERIAL, CONSTRAINT "topographicline_pk" PRIMARY KEY (OGC_FID) ); 108 | SELECT AddGeometryColumn('osmm_topo','topographicline','wkb_geometry',27700,'MULTILINESTRING',2); 109 | ALTER TABLE "osmm_topo"."topographicline" ADD COLUMN "fid" VARCHAR; 110 | ALTER TABLE "osmm_topo"."topographicline" ADD COLUMN "featurecode" INTEGER; 111 | ALTER TABLE "osmm_topo"."topographicline" ADD COLUMN "version" INTEGER; 112 | ALTER TABLE "osmm_topo"."topographicline" ADD COLUMN "versiondate" VARCHAR; 113 | ALTER TABLE "osmm_topo"."topographicline" ADD COLUMN "theme" VARCHAR[]; 114 | ALTER TABLE "osmm_topo"."topographicline" ADD COLUMN "accuracyofposition" VARCHAR; 115 | ALTER TABLE "osmm_topo"."topographicline" ADD COLUMN "changedate" VARCHAR[]; 116 | ALTER TABLE "osmm_topo"."topographicline" ADD COLUMN "reasonforchange" VARCHAR[]; 117 | ALTER TABLE "osmm_topo"."topographicline" ADD COLUMN "descriptivegroup" VARCHAR[]; 118 | ALTER TABLE "osmm_topo"."topographicline" ADD COLUMN "descriptiveterm" VARCHAR[]; 119 | ALTER TABLE "osmm_topo"."topographicline" ADD COLUMN "nonboundingline" VARCHAR; 120 | ALTER TABLE "osmm_topo"."topographicline" ADD COLUMN "heightabovedatum" FLOAT8; 121 | ALTER TABLE "osmm_topo"."topographicline" ADD COLUMN "accuracyofheightabovedatum" VARCHAR; 122 | ALTER TABLE "osmm_topo"."topographicline" ADD COLUMN "heightabovegroundlevel" FLOAT8; 123 | ALTER TABLE "osmm_topo"."topographicline" ADD COLUMN "accuracyofheightabovegroundlevel" VARCHAR; 124 | ALTER TABLE "osmm_topo"."topographicline" ADD COLUMN "make" VARCHAR; 125 | ALTER TABLE "osmm_topo"."topographicline" ADD COLUMN "physicallevel" INTEGER; 126 | ALTER TABLE "osmm_topo"."topographicline" ADD COLUMN "physicalpresence" VARCHAR; 127 | ALTER TABLE "osmm_topo"."topographicline" ADD COLUMN "filename" VARCHAR; 128 | ALTER TABLE "osmm_topo"."topographicline" ADD COLUMN "style_code" INTEGER; 129 | ALTER TABLE "osmm_topo"."topographicline" ADD COLUMN "style_description" VARCHAR; 130 | 131 | DROP TABLE IF EXISTS "osmm_topo"."topographicpoint" CASCADE; 132 | DELETE FROM geometry_columns WHERE f_table_name = 'topographicpoint' AND f_table_schema = 'osmm_topo'; 133 | 134 | CREATE TABLE "osmm_topo"."topographicpoint" ( OGC_FID SERIAL, CONSTRAINT "topographicpoint_pk" PRIMARY KEY (OGC_FID) ); 135 | SELECT AddGeometryColumn('osmm_topo','topographicpoint','wkb_geometry',27700,'POINT',2); 136 | ALTER TABLE "osmm_topo"."topographicpoint" ADD COLUMN "fid" VARCHAR; 137 | ALTER TABLE "osmm_topo"."topographicpoint" ADD COLUMN "featurecode" INTEGER; 138 | ALTER TABLE "osmm_topo"."topographicpoint" ADD COLUMN "version" INTEGER; 139 | ALTER TABLE "osmm_topo"."topographicpoint" ADD COLUMN "versiondate" VARCHAR; 140 | ALTER TABLE "osmm_topo"."topographicpoint" ADD COLUMN "theme" VARCHAR[]; 141 | ALTER TABLE "osmm_topo"."topographicpoint" ADD COLUMN "accuracyofposition" VARCHAR; 142 | ALTER TABLE "osmm_topo"."topographicpoint" ADD COLUMN "changedate" VARCHAR[]; 143 | ALTER TABLE "osmm_topo"."topographicpoint" ADD COLUMN "reasonforchange" VARCHAR[]; 144 | ALTER TABLE "osmm_topo"."topographicpoint" ADD COLUMN "descriptivegroup" VARCHAR[]; 145 | ALTER TABLE "osmm_topo"."topographicpoint" ADD COLUMN "descriptiveterm" VARCHAR[]; 146 | ALTER TABLE "osmm_topo"."topographicpoint" ADD COLUMN "heightabovedatum" FLOAT8; 147 | ALTER TABLE "osmm_topo"."topographicpoint" ADD COLUMN "accuracyofheightabovedatum" VARCHAR; 148 | ALTER TABLE "osmm_topo"."topographicpoint" ADD COLUMN "make" VARCHAR; 149 | ALTER TABLE "osmm_topo"."topographicpoint" ADD COLUMN "physicallevel" INTEGER; 150 | ALTER TABLE "osmm_topo"."topographicpoint" ADD COLUMN "physicalpresence" VARCHAR; 151 | ALTER TABLE "osmm_topo"."topographicpoint" ADD COLUMN "referencetofeature" VARCHAR; 152 | ALTER TABLE "osmm_topo"."topographicpoint" ADD COLUMN "filename" VARCHAR; 153 | ALTER TABLE "osmm_topo"."topographicpoint" ADD COLUMN "style_code" INTEGER; 154 | ALTER TABLE "osmm_topo"."topographicpoint" ADD COLUMN "style_description" VARCHAR; 155 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/osmm/topo/pgdump/loader.config: -------------------------------------------------------------------------------- 1 | ## Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 2 | ## Licensed under [MIT License](https://git.io/fAxH0). 3 | 4 | # The directory containing your source OS MasterMap 5 | # .gml or .gz files. All .gml / .gz files in the 6 | # specified directory and it's decendents will be loaded. 7 | src_dir=/path/to/source/data/folder 8 | 9 | # The directory used to store the translated data 10 | # if writing to a file based format such as ESRI 11 | # Shape, MapInfo TAB etc. 12 | out_dir=/path/to/output/data/folder 13 | 14 | # The directory used to store temporary working files 15 | # during loading. 16 | tmp_dir=/path/to/temp/folder 17 | 18 | # The ogr2ogr command that will be used to load the data. 19 | # Here you can specify the destination format and any 20 | # associated settings (for example database connection 21 | # details if you are writing to PostGIS). 22 | # 23 | # Example of using PGDump format which will create SQL files 24 | # ready to load via psql. 25 | # 26 | # The chosen options assume that the tables already exist, 27 | # COPY is used in favor of INSERT statements and no attempt 28 | # is made to create a spatial index for improved load performance. 29 | # 30 | # *Notes* 31 | # 32 | # If you want to avoid (no fatal) error messages when loading the 33 | # SQL dump files then you need OGR >= 1.8.1 in order to use the 34 | # create_schema layer creation option (-lco create_schema=off). 35 | # 36 | # There is a known issue with OGR 1.8 related to loading single features into 37 | # a geometry column of type MULTI. The issue is fixed in OGR 1.9. 38 | # 39 | # The path /path/to/output/ needs to be set to the directory 40 | # that the SQL dump files should be written to. 41 | # 42 | # Further details of the PGDump driver: http://www.gdal.org/ogr/drv_pgdump.html 43 | # 44 | ogr_cmd=ogr2ogr --config PG_USE_COPY YES --config GML_EXPOSE_FID NO -skipfailures -lco spatial_index=off -lco create_table=off -lco schema=osmm_topo -lco create_schema=off -f PGDump $output_dir/$base_file_name.sql $file_path 45 | 46 | # The command used to prepare the source 47 | # data so it is suitable for loading with OGR 48 | # (does not normally need changing). 49 | prep_cmd=python prepgml4ogr.py $file_path prep_osgml.prep_osmm_topo 50 | 51 | # An optional command to be run once OGR has created it's output. 52 | # Called once per file, useful for loading SQL dump files etc. 53 | # All of the tokens available to the ogr_cmd can be used here. 54 | post_cmd=psql -U postgres -d postgis -f $output_dir/$base_file_name.sql 55 | 56 | # Optional OGR .gfs file used to define the 57 | # feature attributes and geometry type of 58 | # the feautes read from the GML. 59 | gfs_file=../gfs/osmm_topo_postgres.gfs 60 | 61 | # Whether to output debug messages and keep 62 | # temporary files (True or False) 63 | debug=False 64 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/osmm/topo/pgdump/readme.md: -------------------------------------------------------------------------------- 1 | # Loading Postgres using the PGDump driver 2 | 3 | Tests have found that using the [PGDump OGR](http://www.gdal.org/ogr/drv_pgdump.html) driver to create SQL dump files that are then loaded into Postgres using psql can be significantly faster than using the standard [Postgres driver](http://www.gdal.org/ogr/drv_pg.html). Using the PGDump driver introduces some additional steps to the process but the extra effort are probably worthwhile if you are loading a reasonable amount of data (more than 100 files). 4 | 5 | The process goes like this: 6 | 7 | * Create the required Postgres schema and tables as demonstrated in create-tables.sql (you may need to alter the SQL to match your setup). 8 | * Run the loader to create SQL dump files in a given directory. The sample loader.config in this directory includes an example ogr2ogr command using the PGDump driver and COPY statements in place of INSERT for speed. 9 | * Create a spatial index for each table as demonstrated in create-indexes.sql 10 | 11 | ## Example shell script 12 | 13 | # Assumes current directory is the root of the repository 14 | 15 | # (Re)create the tables in Postgres 16 | psql -U postgres -d postgis -f extras/ordnancesurvey/osmm/topo/pgdump/create-tables.sql 17 | 18 | # Run Loader from the python directory using the OSMM Topo PGDump config 19 | (cd python && python loader.py ../extras/ordnancesurvey/osmm/topo/pgdump/loader.config) 20 | 21 | # Create spatial indexes 22 | psql -U postgres -d postgis -f extras/ordnancesurvey/osmm/topo/pgdump/create-indexes.sql 23 | 24 | ## Dependencies ## 25 | 26 | * OGR 1.9 27 | * OGR 1.9 is recommended to avoid the known issue with OGR 1.8 related to loading single features into a geometry column of type MULTI 28 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/osopen/roads/routing_prep.sql: -------------------------------------------------------------------------------- 1 | -- Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 2 | -- Licensed under [MIT License](https://git.io/fAxH0). 3 | 4 | --remove duplicated roadlink and roadnodes 5 | 6 | select count(*) from 7 | (SELECT ogc_fid, 8 | row_number() over (partition BY gml_id ORDER BY ogc_fid) AS rnum 9 | FROM osopen.roadlink) t 10 | WHERE t.rnum > 1; 11 | 12 | select count(*) from 13 | (SELECT ogc_fid, 14 | row_number() over (partition BY gml_id ORDER BY ogc_fid) AS rnum 15 | FROM osopen.roadnode) t 16 | WHERE t.rnum > 1; 17 | 18 | 19 | delete from osopen.roadlink 20 | where ogc_fid in ( select id 21 | from (SELECT ogc_fid id, 22 | row_number() over (partition BY gml_id ORDER BY ogc_fid) AS rnum 23 | FROM osopen.roadlink) t 24 | WHERE t.rnum > 1); 25 | 26 | 27 | delete from osopen.roadnode 28 | where ogc_fid in ( select id 29 | from (SELECT ogc_fid id, 30 | row_number() over (partition BY gml_id ORDER BY ogc_fid) AS rnum 31 | FROM osopen.roadnode) t 32 | WHERE t.rnum > 1); 33 | 34 | 35 | select count(*) from 36 | (SELECT ogc_fid, 37 | row_number() over (partition BY gml_id ORDER BY ogc_fid) AS rnum 38 | FROM osopen.roadlink) t 39 | WHERE t.rnum > 1; 40 | 41 | select count(*) from 42 | (SELECT ogc_fid, 43 | row_number() over (partition BY gml_id ORDER BY ogc_fid) AS rnum 44 | FROM osopen.roadnode) t 45 | WHERE t.rnum > 1; 46 | 47 | 48 | 49 | --drop materialized view osopen.routing_roadlink; 50 | 51 | create materialized view osopen.routing_roadlink as 52 | select ogc_fid, wkb_geometry, gml_id, cast(fictitious as boolean), 53 | regexp_replace(startnode, '^#L0*', '')::int startnode, 54 | regexp_replace(endnode, '^#L0*', '')::int endnode, 55 | length, 56 | length_uom, 57 | roadclassification, 58 | formofway, 59 | case 60 | when roadclassification = 'Motorway' then length/110000 -- 110 km/hr = 70 m/hr 61 | when roadclassification = 'A Road' then length/100000 -- 100 km/hr = 60 m/hr 62 | when roadclassification = 'B Road' then length/65000 -- 65 km/hr = 40 m/hr 63 | else length/50000 -- 50 km/hr = 30 m/hr 64 | end as cost_car, 65 | case 66 | when roadclassification = 'Motorway' then length/0.000001 67 | else length/16000 -- 10 m/hr 68 | end as cost_bike, 69 | cast(loop as boolean), 70 | name1 as name, 71 | roadclassificationnumber , 72 | strategicroad , 73 | name2 , 74 | name1_lang as name_lang, 75 | structure , 76 | name2_lang , 77 | formspartof 78 | from osopen.roadlink; 79 | 80 | 81 | --drop materialized view osopen.routing_roadnode; 82 | 83 | create materialized view osopen.routing_roadnode as 84 | select 85 | ogc_fid , 86 | regexp_replace(gml_id, '^L0*', '')::int nodeid, 87 | formofroadnode, 88 | wkb_geometry 89 | from osopen.roadnode; 90 | 91 | create unique index routing_roadnode_pk 92 | on osopen.routing_roadnode(nodeid); 93 | 94 | create index routing_roadnode_gix on osopen.routing_roadnode using GIST (wkb_geometry); 95 | 96 | -- fix roadlink lines where direction of digitisation is incorrect (goes from end node to start node) 97 | 98 | update osopen.roadlink 99 | set wkb_geometry = st_reverse(wkb_geometry) 100 | where ogc_fid in (select l.ogc_fid 101 | from osopen.routing_roadlink l , osopen.routing_roadnode sn, osopen.routing_roadnode en 102 | where l.startnode = sn.nodeid 103 | and l.endnode = en.nodeid 104 | and st_distance(st_startpoint(l.wkb_geometry), sn.wkb_geometry) > 0.1 105 | and st_distance(st_startpoint(l.wkb_geometry), en.wkb_geometry) < 0.1 ); 106 | 107 | create unique index routing_roadlink_pk 108 | on osopen.routing_roadlink(gml_id); 109 | 110 | create index routing_roadlink_gix on osopen.routing_roadlink using gist (wkb_geometry); 111 | 112 | create index routing_roadlink_idx1 on osopen.routing_roadlink(startnode); 113 | 114 | create index routing_roadlink_idx2 on osopen.routing_roadlink(endnode); -------------------------------------------------------------------------------- /extras/ordnancesurvey/vml/pgdump/create-indexes.sql: -------------------------------------------------------------------------------- 1 | -- Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 2 | -- Licensed under [MIT License](https://git.io/fAxH0). 3 | 4 | -- Creates a spatial index for each VML table. 5 | 6 | CREATE INDEX "text_geom_idx" ON "vml"."text" USING GIST ("wkb_geometry"); 7 | CREATE INDEX "vectormappoint_geom_idx" ON "vml"."vectormappoint" USING GIST ("wkb_geometry"); 8 | CREATE INDEX "line_geom_idx" ON "vml"."line" USING GIST ("wkb_geometry"); 9 | CREATE INDEX "roadcline_geom_idx" ON "vml"."roadcline" USING GIST ("wkb_geometry"); 10 | CREATE INDEX "railcline_geom_idx" ON "vml"."railcline" USING GIST ("wkb_geometry"); 11 | CREATE INDEX "area_geom_idx" ON "vml"."area" USING GIST ("wkb_geometry"); 12 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/vml/pgdump/create-tables.sql: -------------------------------------------------------------------------------- 1 | -- Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 2 | -- Licensed under [MIT License](https://git.io/fAxH0). 3 | 4 | -- Drops any existing VML related tables and creates fresh tables ready to 5 | -- receive data. 6 | 7 | DROP TABLE IF EXISTS "vml"."text" CASCADE; 8 | DELETE FROM geometry_columns WHERE f_table_name = 'text' AND f_table_schema = 'vml'; 9 | 10 | CREATE TABLE "vml"."text" ( OGC_FID SERIAL, CONSTRAINT "text_pk" PRIMARY KEY (OGC_FID) ); 11 | SELECT AddGeometryColumn('vml','text','wkb_geometry',27700,'POINT',2); 12 | ALTER TABLE "vml"."text" ADD COLUMN "featureid" VARCHAR; 13 | ALTER TABLE "vml"."text" ADD COLUMN "featurecode" INTEGER; 14 | ALTER TABLE "vml"."text" ADD COLUMN "featuredescription" VARCHAR; 15 | ALTER TABLE "vml"."text" ADD COLUMN "anchorposition" INTEGER; 16 | ALTER TABLE "vml"."text" ADD COLUMN "font" INTEGER; 17 | ALTER TABLE "vml"."text" ADD COLUMN "height" FLOAT8; 18 | ALTER TABLE "vml"."text" ADD COLUMN "orientation" INTEGER; 19 | ALTER TABLE "vml"."text" ADD COLUMN "orientdeg" FLOAT8; 20 | ALTER TABLE "vml"."text" ADD COLUMN "orientation_uom" VARCHAR; 21 | ALTER TABLE "vml"."text" ADD COLUMN "textstring" VARCHAR; 22 | ALTER TABLE "vml"."text" ADD COLUMN "tile" VARCHAR; 23 | 24 | DROP TABLE IF EXISTS "vml"."vectormappoint" CASCADE; 25 | DELETE FROM geometry_columns WHERE f_table_name = 'vectormappoint' AND f_table_schema = 'vml'; 26 | 27 | CREATE TABLE "vml"."vectormappoint" ( OGC_FID SERIAL, CONSTRAINT "vectormappoint_pk" PRIMARY KEY (OGC_FID) ); 28 | SELECT AddGeometryColumn('vml','vectormappoint','wkb_geometry',27700,'POINT',2); 29 | ALTER TABLE "vml"."vectormappoint" ADD COLUMN "featureid" VARCHAR; 30 | ALTER TABLE "vml"."vectormappoint" ADD COLUMN "featurecode" INTEGER; 31 | ALTER TABLE "vml"."vectormappoint" ADD COLUMN "featuredescription" VARCHAR; 32 | ALTER TABLE "vml"."vectormappoint" ADD COLUMN "orientation" INTEGER; 33 | ALTER TABLE "vml"."vectormappoint" ADD COLUMN "orientdeg" FLOAT8; 34 | ALTER TABLE "vml"."vectormappoint" ADD COLUMN "orientation_uom" VARCHAR; 35 | ALTER TABLE "vml"."vectormappoint" ADD COLUMN "tile" VARCHAR; 36 | 37 | DROP TABLE IF EXISTS "vml"."line" CASCADE; 38 | DELETE FROM geometry_columns WHERE f_table_name = 'line' AND f_table_schema = 'vml'; 39 | 40 | CREATE TABLE "vml"."line" ( OGC_FID SERIAL, CONSTRAINT "line_pk" PRIMARY KEY (OGC_FID) ); 41 | SELECT AddGeometryColumn('vml','line','wkb_geometry',27700,'LINESTRING',2); 42 | ALTER TABLE "vml"."line" ADD COLUMN "featureid" VARCHAR; 43 | ALTER TABLE "vml"."line" ADD COLUMN "featurecode" INTEGER; 44 | ALTER TABLE "vml"."line" ADD COLUMN "featuredescription" VARCHAR; 45 | ALTER TABLE "vml"."line" ADD COLUMN "tile" VARCHAR; 46 | 47 | DROP TABLE IF EXISTS "vml"."roadcline" CASCADE; 48 | DELETE FROM geometry_columns WHERE f_table_name = 'roadcline' AND f_table_schema = 'vml'; 49 | 50 | CREATE TABLE "vml"."roadcline" ( OGC_FID SERIAL, CONSTRAINT "roadcline_pk" PRIMARY KEY (OGC_FID) ); 51 | SELECT AddGeometryColumn('vml','roadcline','wkb_geometry',27700,'LINESTRING',2); 52 | ALTER TABLE "vml"."roadcline" ADD COLUMN "featureid" VARCHAR; 53 | ALTER TABLE "vml"."roadcline" ADD COLUMN "featurecode" INTEGER; 54 | ALTER TABLE "vml"."roadcline" ADD COLUMN "featuredescription" VARCHAR; 55 | ALTER TABLE "vml"."roadcline" ADD COLUMN "roadnumber" VARCHAR; 56 | ALTER TABLE "vml"."roadcline" ADD COLUMN "roadname" VARCHAR; 57 | ALTER TABLE "vml"."roadcline" ADD COLUMN "drawlevel" INTEGER; 58 | ALTER TABLE "vml"."roadcline" ADD COLUMN "override" BOOLEAN; 59 | ALTER TABLE "vml"."roadcline" ADD COLUMN "suppressed" BOOLEAN; 60 | ALTER TABLE "vml"."roadcline" ADD COLUMN "intunnel" BOOLEAN; 61 | ALTER TABLE "vml"."roadcline" ADD COLUMN "tile" VARCHAR; 62 | 63 | DROP TABLE IF EXISTS "vml"."area" CASCADE; 64 | DELETE FROM geometry_columns WHERE f_table_name = 'area' AND f_table_schema = 'vml'; 65 | 66 | CREATE TABLE "vml"."area" ( OGC_FID SERIAL, CONSTRAINT "area_pk" PRIMARY KEY (OGC_FID) ); 67 | SELECT AddGeometryColumn('vml','area','wkb_geometry',27700,'POLYGON',2); 68 | ALTER TABLE "vml"."area" ADD COLUMN "featureid" VARCHAR; 69 | ALTER TABLE "vml"."area" ADD COLUMN "featurecode" INTEGER; 70 | ALTER TABLE "vml"."area" ADD COLUMN "featuredescription" VARCHAR; 71 | ALTER TABLE "vml"."area" ADD COLUMN "tile" VARCHAR; 72 | 73 | DROP TABLE IF EXISTS "vml"."railcline" CASCADE; 74 | DELETE FROM geometry_columns WHERE f_table_name = 'railcline' AND f_table_schema = 'vml'; 75 | 76 | CREATE TABLE "vml"."railcline" ( OGC_FID SERIAL, CONSTRAINT "railcline_pk" PRIMARY KEY (OGC_FID) ); 77 | SELECT AddGeometryColumn('vml','railcline','wkb_geometry',27700,'LINESTRING',2); 78 | ALTER TABLE "vml"."railcline" ADD COLUMN "featureid" VARCHAR; 79 | ALTER TABLE "vml"."railcline" ADD COLUMN "featurecode" INTEGER; 80 | ALTER TABLE "vml"."railcline" ADD COLUMN "featuredescription" VARCHAR; 81 | ALTER TABLE "vml"."railcline" ADD COLUMN "suppressed" BOOLEAN; 82 | ALTER TABLE "vml"."railcline" ADD COLUMN "intunnel" BOOLEAN; 83 | ALTER TABLE "vml"."railcline" ADD COLUMN "tile" VARCHAR; 84 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/vml/pgdump/readme.md: -------------------------------------------------------------------------------- 1 | # Loading VML into Postgres using the PGDump driver # 2 | 3 | Generally you want to use the OGR `PGDump` driver to load into Postgres if you are loading a significant number of files as it's much quicker than the standard `PostgreSQL` driver. See the [OSMM Topo readme](../../osmm/topo/pgdump/readme.markdown) for more background. 4 | 5 | ## Assumptions 6 | 7 | The example SQL and configuration provided assume loading into a database called `postgis` and a schema called `vml`, you many need to edit these files to match your enviroment. 8 | 9 | ## Usage 10 | 11 | A bash shell script to coordinate the load might look like this: 12 | 13 | ``` 14 | # Assumes current directory is Loader/python (where loader.py lives) 15 | 16 | # (Re)create the tables in Postgres 17 | psql -d postgis -U postgres -f ../extras/ordnancesurvey/vml/pgdump/create-tables.sql 18 | 19 | # Run Loader 20 | python loader.py ../extras/ordnancesurvey/vml/pgdump/vml_pgdump.config 21 | 22 | # Create spatial indexes 23 | psql -d postgis -U postgres -f ../extras/ordnancesurvey/vml/pgdump/create-indexes.sql 24 | ``` 25 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/vml/pgdump/vml_pgdump.config: -------------------------------------------------------------------------------- 1 | ## Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 2 | ## Licensed under [MIT License](https://git.io/fAxH0). 3 | 4 | # The directory containing your source files. All supported files in the 5 | # specified directory and it's descendants will be loaded. 6 | src_dir=/path/to/source/data/folder 7 | 8 | # Temporary SQL files will be written here 9 | out_dir=/path/to/output/data/folder 10 | 11 | # The directory used to store temporary working files during loading. 12 | tmp_dir=/path/to/temp/folder 13 | 14 | # Use the OGR PGDump driver using COPY for speed. The PGDump driver does not 15 | # load into the database itself but instead creates a SQL file which we later 16 | # load with the post_cmd 17 | ogr_cmd=ogr2ogr --config PG_USE_COPY YES --config GML_EXPOSE_FID NO -skipfailures -lco spatial_index=off -lco create_table=off -lco schema=vml -lco create_schema=off -f PGDump $output_dir/$base_file_name.sql $file_path 18 | 19 | # Use the standard preparation logic for VML 20 | prep_cmd=python prepgml4ogr.py $file_path prep_osgml.prep_vml 21 | 22 | # Use the standard OGR GFS file for VML loaded into Postgres to define the 23 | # tables and their attributes. The tables and attributes defined in the GFS 24 | # file must match the SQL in create-tables.sql and create-indexes.sql. 25 | gfs_file=../gfs/vml_postgres.gfs 26 | 27 | # Load the generated SQL file using the Postgres command-line client psql 28 | post_cmd=psql -d postgis -U postgres -f $output_dir/$base_file_name.sql 29 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/vml/updates/apply-update.sql: -------------------------------------------------------------------------------- 1 | -- Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 2 | -- Licensed under [MIT License](https://git.io/fAxH0). 3 | 4 | BEGIN; 5 | 6 | -- Delete rows in current table (vml schema) that belong to a tile for which 7 | -- features are present in the update table (vml_update schema); Insert 8 | -- superseded rows from the current table to archive table (vml_archive schema) 9 | -- providing they do not already exist in the archive 10 | WITH superseded AS (DELETE FROM vml.text WHERE tile IN (SELECT DISTINCT tile FROM vml_update.text) RETURNING *) 11 | INSERT INTO vml_archive.text SELECT * FROM superseded s WHERE NOT EXISTS (SELECT 1 FROM vml_archive.text a WHERE s.tile = a.tile and s.creationdate = a.creationdate); 12 | 13 | -- Delete rows from update table and insert into current table taking care to 14 | -- increment the ogc_fid column which is a SERIAL. 15 | WITH fresh AS (DELETE FROM vml_update.text RETURNING *) 16 | INSERT INTO vml.text (SELECT nextval('vml.text_ogc_fid_seq'), * FROM fresh); 17 | 18 | WITH superseded AS (DELETE FROM vml.vectormappoint WHERE tile IN (SELECT DISTINCT tile FROM vml_update.vectormappoint) RETURNING *) 19 | INSERT INTO vml_archive.vectormappoint SELECT * FROM superseded s WHERE NOT EXISTS (SELECT 1 FROM vml_archive.vectormappoint a WHERE s.tile = a.tile and s.creationdate = a.creationdate); 20 | WITH fresh AS (DELETE FROM vml_update.vectormappoint RETURNING *) 21 | INSERT INTO vml.vectormappoint (SELECT nextval('vml.vectormappoint_ogc_fid_seq'), * FROM fresh); 22 | 23 | WITH superseded AS (DELETE FROM vml.line WHERE tile IN (SELECT DISTINCT tile FROM vml_update.line) RETURNING *) 24 | INSERT INTO vml_archive.line SELECT * FROM superseded s WHERE NOT EXISTS (SELECT 1 FROM vml_archive.line a WHERE s.tile = a.tile and s.creationdate = a.creationdate); 25 | WITH fresh AS (DELETE FROM vml_update.line RETURNING *) 26 | INSERT INTO vml.line (SELECT nextval('vml.line_ogc_fid_seq'), * FROM fresh); 27 | 28 | WITH superseded AS (DELETE FROM vml.roadcline WHERE tile IN (SELECT DISTINCT tile FROM vml_update.roadcline) RETURNING *) 29 | INSERT INTO vml_archive.roadcline SELECT * FROM superseded s WHERE NOT EXISTS (SELECT 1 FROM vml_archive.roadcline a WHERE s.tile = a.tile and s.creationdate = a.creationdate); 30 | WITH fresh AS (DELETE FROM vml_update.roadcline RETURNING *) 31 | INSERT INTO vml.roadcline (SELECT nextval('vml.roadcline_ogc_fid_seq'), * FROM fresh); 32 | 33 | WITH superseded AS (DELETE FROM vml.area WHERE tile IN (SELECT DISTINCT tile FROM vml_update.area) RETURNING *) 34 | INSERT INTO vml_archive.area SELECT * FROM superseded s WHERE NOT EXISTS (SELECT 1 FROM vml_archive.area a WHERE s.tile = a.tile and s.creationdate = a.creationdate); 35 | WITH fresh AS (DELETE FROM vml_update.area RETURNING *) 36 | INSERT INTO vml.area (SELECT nextval('vml.area_ogc_fid_seq'), * FROM fresh); 37 | 38 | COMMIT; 39 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/vml/updates/create-archive-tables.sql: -------------------------------------------------------------------------------- 1 | -- Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 2 | -- Licensed under [MIT License](https://git.io/fAxH0). 3 | 4 | -- Create tables suitable for archiving superseded VML features. Assumes there 5 | -- is a schema called vml_archive. The script apply-update.sql manages moving 6 | -- superseded features to the archive tables. 7 | 8 | CREATE TABLE IF NOT EXISTS vml_archive.text (LIKE vml.text); 9 | CREATE TABLE IF NOT EXISTS vml_archive.vectormappoint (LIKE vml.vectormappoint); 10 | CREATE TABLE IF NOT EXISTS vml_archive.line (LIKE vml.line); 11 | CREATE TABLE IF NOT EXISTS vml_archive.roadcline (LIKE vml.roadcline); 12 | CREATE TABLE IF NOT EXISTS vml_archive.area (LIKE vml.area); 13 | -------------------------------------------------------------------------------- /extras/ordnancesurvey/vml/updates/create-update-tables.sql: -------------------------------------------------------------------------------- 1 | -- Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 2 | -- Licensed under [MIT License](https://git.io/fAxH0). 3 | 4 | -- Create tables suitable for loading a VML update. Drops any existing VML 5 | -- update tables. Assumes there is a schema called vml_update. The ogc_fid 6 | -- column is dropped to avoid issues with inserting into the main tables as 7 | -- ogc_fid is an auto generated SERIAL. It is expected that this script is ran 8 | -- prior to an update being loaded. 9 | 10 | DROP TABLE IF EXISTS vml_update.text CASCADE; 11 | CREATE TABLE vml_update.text (LIKE vml.text); 12 | ALTER TABLE vml_update.text DROP COLUMN ogc_fid; 13 | 14 | DROP TABLE IF EXISTS vml_update.vectormappoint CASCADE; 15 | CREATE TABLE vml_update.vectormappoint (LIKE vml.vectormappoint); 16 | ALTER TABLE vml_update.vectormappoint DROP COLUMN ogc_fid; 17 | 18 | DROP TABLE IF EXISTS vml_update.line CASCADE; 19 | CREATE TABLE vml_update.line (LIKE vml.line); 20 | ALTER TABLE vml_update.line DROP COLUMN ogc_fid; 21 | 22 | DROP TABLE IF EXISTS vml_update.roadcline CASCADE; 23 | CREATE TABLE vml_update.roadcline (LIKE vml.roadcline); 24 | ALTER TABLE vml_update.roadcline DROP COLUMN ogc_fid; 25 | 26 | DROP TABLE IF EXISTS vml_update.area CASCADE; 27 | CREATE TABLE vml_update.area (LIKE vml.area); 28 | ALTER TABLE vml_update.area DROP COLUMN ogc_fid; 29 | -------------------------------------------------------------------------------- /gfs/addressbase_plus_postgres.gfs: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | Address 8 | Address 9 | 1 10 | position 11 | EPSG:27700 12 | 13 | uprn 14 | uprn 15 | Real 16 | 17 | 18 | rm_udprn 19 | rmUDPRN 20 | Integer 21 | 22 | 23 | change_type 24 | changeType 25 | String 26 | 27 | 28 | state 29 | state 30 | Integer 31 | 32 | 33 | state_date 34 | stateDate 35 | String 36 | 37 | 38 | class 39 | class 40 | String 41 | 42 | 43 | parent_uprn 44 | parentUPRN 45 | Real 46 | 47 | 48 | rpc 49 | rpc 50 | Integer 51 | 52 | 53 | local_custodian_code 54 | localCustodianCode 55 | Integer 56 | 57 | 58 | start_date 59 | startDate 60 | String 61 | 62 | 63 | end_date 64 | endDate 65 | String 66 | 67 | 68 | last_update_date 69 | lastUpdateDate 70 | String 71 | 72 | 73 | entry_date 74 | entryDate 75 | String 76 | 77 | 78 | organisation_name 79 | organisationName 80 | String 81 | 82 | 83 | blpu_organisation 84 | blpuOrganisation 85 | String 86 | 87 | 88 | department_name 89 | departmentName 90 | String 91 | 92 | 93 | scottish_department_name 94 | scottishDepartmentName 95 | String 96 | 97 | 98 | building_name 99 | buildingName 100 | String 101 | 102 | 103 | sub_building_name 104 | subBuildingName 105 | String 106 | 107 | 108 | sao_start_number 109 | saoStartNumber 110 | Integer 111 | 112 | 113 | sao_start_suffix 114 | saoStartSuffix 115 | String 116 | 117 | 118 | sao_end_number 119 | saoEndNumber 120 | Integer 121 | 122 | 123 | sao_end_suffix 124 | saoEndSuffix 125 | String 126 | 127 | 128 | sao_text 129 | saoText 130 | String 131 | 132 | 133 | alt_language_sao_text 134 | altLanguageSaoText 135 | String 136 | 137 | 138 | pao_start_number 139 | paoStartNumber 140 | Integer 141 | 142 | 143 | pao_start_suffix 144 | paoStartSuffix 145 | String 146 | 147 | 148 | pao_end_number 149 | paoEndNumber 150 | Integer 151 | 152 | 153 | pao_end_suffix 154 | paoEndSuffix 155 | String 156 | 157 | 158 | pao_text 159 | paoText 160 | String 161 | 162 | 163 | alt_language_pao_text 164 | altLanguagePaoText 165 | String 166 | 167 | 168 | usrn 169 | usrn 170 | Integer 171 | 172 | 173 | usrn_match_indicator 174 | usrnMatchIndicator 175 | Integer 176 | 177 | 178 | area_name 179 | areaName 180 | String 181 | 182 | 183 | level 184 | level 185 | String 186 | 187 | 188 | official_flag 189 | officialFlag 190 | String 191 | 192 | 193 | os_address_toid 194 | osAddressTOID 195 | String 196 | 197 | 198 | os_address_toid_version 199 | osAddressTOIDVersion 200 | Integer 201 | 202 | 203 | os_roadlink_toid 204 | osRoadLinkTOID 205 | String 206 | 207 | 208 | os_roadlink_toid_version 209 | osRoadLinkTOIDVersion 210 | Integer 211 | 212 | 213 | os_topo_toid 214 | osTopoToid 215 | String 216 | 217 | os_topo_toid_version 218 | osTopoToidVersion 219 | Integer 220 | 221 | 222 | voa_ct_record 223 | voaCTRecord 224 | Real 225 | 226 | 227 | voa_ndr_record 228 | voaNDRRecord 229 | Real 230 | 231 | 232 | street_description 233 | streetDescription 234 | String 235 | 236 | 237 | alt_language_street_descriptor 238 | altLanguageStreetDescriptor 239 | String 240 | 241 | 242 | dependent_thoroughfare 243 | dependentThoroughfare 244 | String 245 | 246 | 247 | thoroughfare 248 | thoroughfare 249 | String 250 | 251 | 252 | welsh_dependent_thoroughfare 253 | welshDependentThoroughfare 254 | String 255 | 256 | 257 | welsh_thoroughfare 258 | welshThoroughfare 259 | String 260 | 261 | 262 | double_dependent_locality 263 | doubleDependentLocality 264 | String 265 | 266 | 267 | dependent_locality 268 | dependentLocality 269 | String 270 | 271 | 272 | locality 273 | locality 274 | String 275 | 276 | 277 | welsh_double_dependent_locality 278 | welshDoubleDependentLocality 279 | String 280 | 281 | 282 | welsh_dependent_locality 283 | welshDependentLocality 284 | String 285 | 286 | 287 | town_name 288 | townName 289 | String 290 | 291 | 292 | administrative_area 293 | administrativeArea 294 | String 295 | 296 | 297 | post_town 298 | postTown 299 | String 300 | 301 | 302 | postcode 303 | postcode 304 | String 305 | 306 | 307 | postcode_locator 308 | postcodeLocator 309 | String 310 | 311 | 312 | postcode_type 313 | postcodeType 314 | String 315 | 316 | 317 | postal_addressable 318 | postalAddressable 319 | String 320 | 321 | 322 | po_box_number 323 | poBoxNumber 324 | Integer 325 | 326 | 327 | ward_code 328 | wardCode 329 | String 330 | 331 | 332 | parish_code 333 | parishCode 334 | String 335 | 336 | 337 | process_date 338 | processDate 339 | String 340 | 341 | 342 | multi_occ_count 343 | multiOccCount 344 | Integer 345 | 346 | 347 | voa_ndr_p_desc_code 348 | voaNDRPDescCode 349 | String 350 | 351 | 352 | voa_ndr_scat_code 353 | voaNDRScatCode 354 | String 355 | 356 | 357 | alt_language 358 | altLanguage 359 | String 360 | 361 | 362 | 363 | -------------------------------------------------------------------------------- /gfs/addressbase_standard.gfs: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | Address 8 | Address 9 | 1 10 | position 11 | EPSG:27700 12 | 13 | uprn 14 | uprn 15 | Real 16 | 17 | 18 | os_address_toid 19 | toid 20 | String 21 | 20 22 | 23 | 24 | rm_udprn 25 | udprn 26 | Integer 27 | 28 | 29 | organisation_name 30 | organisationName 31 | String 32 | 254 33 | 34 | 35 | department_name 36 | departmentName 37 | String 38 | 254 39 | 40 | 41 | po_box_number 42 | poBoxNumber 43 | Integer 44 | 45 | 46 | building_name 47 | buildingName 48 | String 49 | 254 50 | 51 | 52 | sub_building_name 53 | subBuildingName 54 | String 55 | 254 56 | 57 | 58 | building_number 59 | buildingNumber 60 | Integer 61 | 62 | 63 | dependent_thoroughfare_name 64 | dependentThoroughfareName 65 | String 66 | 254 67 | 68 | 69 | throughfare_name 70 | throughfareName 71 | String 72 | 254 73 | 74 | 75 | post_town 76 | postTown 77 | String 78 | 254 79 | 80 | 81 | double_dependent_locality 82 | doubleDependentLocality 83 | String 84 | 254 85 | 86 | 87 | dependent_locality 88 | dependentLocality 89 | String 90 | 254 91 | 92 | 93 | postcode 94 | postcode 95 | String 96 | 12 97 | 98 | 99 | postcode_type 100 | postcodeType 101 | String 102 | 1 103 | 104 | 105 | rpc 106 | rpc 107 | Integer 108 | 109 | 110 | change_type 111 | changeType 112 | String 113 | 1 114 | 115 | 116 | start_date 117 | startDate 118 | String 119 | 10 120 | 121 | 122 | last_update_date 123 | lastUpdateDate 124 | String 125 | 10 126 | 127 | 128 | entry_date 129 | entryDate 130 | String 131 | 10 132 | 133 | 134 | class 135 | class 136 | String 137 | 1 138 | 139 | 140 | process_date 141 | processDate 142 | String 143 | 10 144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /gfs/addressbase_standard_postgres.gfs: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | Address 8 | Address 9 | 1 10 | position 11 | EPSG:27700 12 | 13 | uprn 14 | uprn 15 | Real 16 | 17 | 18 | os_address_toid 19 | toid 20 | String 21 | 22 | 23 | rm_udprn 24 | udprn 25 | Integer 26 | 27 | 28 | organisation_name 29 | organisationName 30 | String 31 | 32 | 33 | department_name 34 | departmentName 35 | String 36 | 37 | 38 | po_box_number 39 | poBoxNumber 40 | Integer 41 | 42 | 43 | building_name 44 | buildingName 45 | String 46 | 47 | 48 | sub_building_name 49 | subBuildingName 50 | String 51 | 52 | 53 | building_number 54 | buildingNumber 55 | Integer 56 | 57 | 58 | dependent_thoroughfare_name 59 | dependentThoroughfareName 60 | String 61 | 62 | 63 | throughfare_name 64 | throughfareName 65 | String 66 | 67 | 68 | post_town 69 | postTown 70 | String 71 | 72 | 73 | double_dependent_locality 74 | doubleDependentLocality 75 | String 76 | 77 | 78 | dependent_locality 79 | dependentLocality 80 | String 81 | 82 | 83 | postcode 84 | postcode 85 | String 86 | 87 | 88 | postcode_type 89 | postcodeType 90 | String 91 | 92 | 93 | rpc 94 | rpc 95 | Integer 96 | 97 | 98 | change_type 99 | changeType 100 | String 101 | 102 | 103 | start_date 104 | startDate 105 | String 106 | 107 | 108 | last_update_date 109 | lastUpdateDate 110 | String 111 | 112 | 113 | entry_date 114 | entryDate 115 | String 116 | 117 | 118 | class 119 | class 120 | String 121 | 122 | 123 | process_date 124 | processDate 125 | String 126 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /gfs/land_registry_cadastral_parcels.gfs: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | LandRegParcels 8 | PREDEFINED 9 | 3 10 | urn:ogc:def:crs:EPSG::27700 11 | 12 | INSPIREID 13 | INSPIREID 14 | Integer 15 | 16 | 17 | LABEL 18 | LABEL 19 | Integer 20 | 21 | 22 | NATIONALCADASTRALREFERENCE 23 | NATIONALCADASTRALREFERENCE 24 | Integer 25 | 26 | 27 | VALIDFROM 28 | VALIDFROM 29 | String 30 | 24 31 | 32 | 33 | BEGINLIFESPANVERSION 34 | BEGINLIFESPANVERSION 35 | String 36 | 24 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /gfs/osmm_sites_postgres.gfs: -------------------------------------------------------------------------------- 1 | 2 | 6 | false 7 | 8 | FunctionalSite 9 | FunctionalSite 10 | 6 11 | EPSG:27700 12 | 13 | toid 14 | toid 15 | String 16 | 17 | 18 | version 19 | version 20 | Integer 21 | 22 | 23 | versionDate 24 | versionDate 25 | String 26 | 27 | 28 | reasonForChange 29 | reasonForChange 30 | String 31 | 32 | 33 | functionStatus 34 | functionStatus 35 | String 36 | 37 | 38 | functionTheme 39 | functionTheme 40 | String 41 | 42 | 43 | function 44 | function 45 | String 46 | 47 | 48 | perimeter 49 | perimeter 50 | Real 51 | 52 | 53 | area 54 | area 55 | Real 56 | 57 | 58 | distinctiveName1 59 | distinctiveName1 60 | String 61 | 62 | 63 | distinctiveName2 64 | distinctiveName2 65 | String 66 | 67 | 68 | distinctiveName3 69 | distinctiveName3 70 | String 71 | 72 | 73 | distinctiveName4 74 | distinctiveName4 75 | String 76 | 77 | 78 | stakeholder1 79 | stakeholder1 80 | String 81 | 82 | 83 | stakeholder2 84 | stakeholder2 85 | String 86 | 87 | 88 | stakeholder1Role 89 | stakeholder1Role 90 | String 91 | 92 | 93 | stakeholder2Role 94 | stakeholder2Role 95 | String 96 | 97 | 98 | primaryAddressBaseUPRN 99 | primaryAddressBaseUPRN 100 | Real 101 | 102 | 103 | extentDefinition 104 | extentDefinition 105 | String 106 | 107 | 108 | 109 | AccessPoint 110 | AccessPoint 111 | 1 112 | EPSG:27700 113 | 114 | toid 115 | toid 116 | String 117 | 118 | 119 | version 120 | version 121 | Integer 122 | 123 | 124 | versionDate 125 | versionDate 126 | String 127 | 128 | 129 | reasonForChange 130 | reasonForChange 131 | String 132 | 133 | 134 | refToFunctionalSite 135 | refToFunctionalSite 136 | String 137 | 138 | 139 | accessType 140 | accessType 141 | String 142 | 143 | 144 | accessMechanism 145 | accessMechanism 146 | String 147 | 148 | 149 | accessDirection 150 | accessDirection 151 | String 152 | 153 | 154 | accessUseRestriction 155 | accessUseRestriction 156 | String 157 | 158 | 159 | refToRoutingPoint 160 | refToRoutingPoint 161 | String 162 | 163 | 164 | refToITNRoadNode 165 | refToITNRoadNode 166 | String 167 | 168 | 169 | itnRoadNodeVersionDate 170 | itnRoadNodeVersionDate 171 | String 172 | 173 | 174 | dateTimeQualifier 175 | dateTimeQualifier 176 | String 177 | 178 | 179 | heightQualifier 180 | heightQualifier 181 | String 182 | 183 | 184 | widthQualifier 185 | widthQualifier 186 | String 187 | 188 | 189 | weightQualifier 190 | weightQualifier 191 | String 192 | 193 | 194 | lengthQualifier 195 | lengthQualifier 196 | String 197 | 198 | 199 | natureOfAccess 200 | natureOfAccess 201 | String 202 | 203 | 204 | 205 | RoutingPoint 206 | RoutingPoint 207 | 1 208 | EPSG:27700 209 | 210 | toid 211 | toid 212 | String 213 | 214 | 215 | version 216 | version 217 | Integer 218 | 219 | 220 | versionDate 221 | versionDate 222 | String 223 | 224 | 225 | reasonForChange 226 | reasonForChange 227 | String 228 | 229 | 230 | refToITNRoadLink 231 | refToITNRoadLink 232 | String 233 | 234 | 235 | itnRoadLinkVersionDate 236 | itnRoadLinkVersionDate 237 | String 238 | 239 | 240 | startDistance 241 | startDistance 242 | Real 243 | 244 | 245 | 246 | -------------------------------------------------------------------------------- /gfs/osmm_topo_postgres_basemap_minimal.gfs: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | TopographicArea 8 | TopographicArea 9 | 3 10 | EPSG:27700 11 | 12 | fid 13 | fid 14 | String 15 | 16 | 17 | featureCode 18 | featureCode 19 | Integer 20 | 21 | 22 | filename 23 | filename 24 | String 25 | 26 | 27 | 28 | CartographicText 29 | CartographicText 30 | 1 31 | EPSG:27700 32 | 33 | fid 34 | fid 35 | String 36 | 37 | 38 | featureCode 39 | featureCode 40 | Integer 41 | 42 | 43 | anchorPosition 44 | textRendering|anchorPosition 45 | Integer 46 | 47 | 48 | font 49 | textRendering|font 50 | Integer 51 | 52 | 53 | height 54 | textRendering|height 55 | Real 56 | 57 | 58 | orientDeg 59 | textRendering|orientDeg 60 | Real 61 | 62 | 63 | textString 64 | textString 65 | String 66 | 67 | 68 | filename 69 | filename 70 | String 71 | 72 | 73 | 74 | BoundaryLine 75 | BoundaryLine 76 | 5 77 | EPSG:27700 78 | 79 | fid 80 | fid 81 | String 82 | 83 | 84 | featureCode 85 | featureCode 86 | Integer 87 | 88 | 89 | filename 90 | filename 91 | String 92 | 93 | 94 | 95 | TopographicLine 96 | TopographicLine 97 | 5 98 | EPSG:27700 99 | 100 | fid 101 | fid 102 | String 103 | 104 | 105 | featureCode 106 | featureCode 107 | Integer 108 | 109 | 110 | filename 111 | filename 112 | String 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /gfs/osmm_water_postgres.gfs: -------------------------------------------------------------------------------- 1 | 2 | 6 | true 7 | 8 | WatercourseLink 9 | WatercourseLink 10 | -2147483646 11 | EPSG:27700 12 | 13 | identifier 14 | identifier 15 | String 16 | 17 | 18 | beginLifespanVersion 19 | beginLifespanVersion 20 | String 21 | 22 | 23 | localId 24 | inspireId|Identifier|localId 25 | Real 26 | 27 | 28 | namespace 29 | inspireId|Identifier|namespace 30 | String 31 | 32 | 33 | versionId 34 | inspireId|Identifier|versionId 35 | Integer 36 | 37 | 38 | fictitious 39 | fictitious 40 | String 41 | 42 | 43 | flowDirection 44 | flowDirection 45 | String 46 | 47 | 48 | length_uom 49 | length_uom 50 | String 51 | 52 | 53 | primacy 54 | primacy 55 | Integer 56 | 57 | 58 | permanence 59 | permanence 60 | String 61 | 62 | 63 | managedNavigation 64 | managedNavigation 65 | String 66 | 67 | 68 | gradient 69 | gradient 70 | Real 71 | 72 | 73 | width 74 | width 75 | Real 76 | 77 | 78 | width_uom 79 | width_uom 80 | String 81 | 82 | 83 | watercourseName 84 | watercourseName 85 | String 86 | 87 | 88 | startNode 89 | startNode 90 | String 91 | 92 | 93 | endNode 94 | endNode 95 | String 96 | 97 | 98 | reasonForChange 99 | reasonForChange 100 | String 101 | 102 | 103 | form 104 | form 105 | String 106 | 107 | 108 | provenance 109 | provenance 110 | String 111 | 112 | 113 | levelOfDetail 114 | levelOfDetail 115 | String 116 | 117 | 118 | fid 119 | fid 120 | String 121 | 122 | 123 | filename 124 | filename 125 | String 126 | 127 | 128 | 129 | HydroNode 130 | HydroNode 131 | -2147483647 132 | EPSG:27700 133 | 134 | identifier 135 | identifier 136 | String 137 | 138 | 139 | beginLifespanVersion 140 | beginLifespanVersion 141 | String 142 | 143 | 144 | localId 145 | inspireId|Identifier|localId 146 | Real 147 | 148 | 149 | namespace 150 | inspireId|Identifier|namespace 151 | String 152 | 153 | 154 | versionId 155 | inspireId|Identifier|versionId 156 | Integer 157 | 158 | 159 | hydroNodeCategory 160 | hydroNodeCategory 161 | String 162 | 163 | 164 | reasonForChange 165 | reasonForChange 166 | String 167 | 168 | 169 | fid 170 | fid 171 | String 172 | 173 | 174 | filename 175 | filename 176 | String 177 | 178 | 179 | 180 | -------------------------------------------------------------------------------- /gfs/osopenmap.gfs: -------------------------------------------------------------------------------- 1 | 2 | 6 | true 7 | 8 | Building 9 | Building 10 | 3 11 | urn:ogc:def:crs:EPSG::27700 12 | 13 | featurecode 14 | featureCode 15 | Integer 16 | 17 | 18 | 19 | ElectricityTransmissionLine 20 | ElectricityTransmissionLine 21 | 2 22 | urn:ogc:def:crs:EPSG::27700 23 | 24 | featurecode 25 | featureCode 26 | Integer 27 | 28 | 29 | 30 | Foreshore 31 | Foreshore 32 | 3 33 | urn:ogc:def:crs:EPSG::27700 34 | 35 | featurecode 36 | featureCode 37 | Integer 38 | 39 | 40 | 41 | FunctionalSite 42 | FunctionalSite 43 | 6 44 | urn:ogc:def:crs:EPSG::27700 45 | 46 | featurecode 47 | featureCode 48 | Integer 49 | 50 | 51 | distinctiveName 52 | distinctiveName 53 | String 54 | 55 | 56 | siteTheme 57 | siteTheme 58 | String 59 | 15 60 | 61 | 62 | classification 63 | classification 64 | String 65 | 66 | 67 | 68 | Glasshouse 69 | Glasshouse 70 | 3 71 | urn:ogc:def:crs:EPSG::27700 72 | 73 | featurecode 74 | featureCode 75 | Integer 76 | 77 | 78 | 79 | ImportantBuilding 80 | ImportantBuilding 81 | 3 82 | urn:ogc:def:crs:EPSG::27700 83 | 84 | featurecode 85 | featureCode 86 | Integer 87 | 88 | 89 | distinctiveName 90 | distinctiveName 91 | String 92 | 93 | 94 | buildingTheme 95 | buildingTheme 96 | String 97 | 98 | 99 | classification 100 | classification 101 | String 102 | 103 | 104 | 105 | MotorwayJunction 106 | MotorwayJunction 107 | 1 108 | urn:ogc:def:crs:EPSG::27700 109 | 110 | featurecode 111 | featureCode 112 | Integer 113 | 114 | 115 | junctionNumber 116 | junctionnumber 117 | Integer 118 | 119 | 120 | 121 | NamedPlace 122 | NamedPlace 123 | 1 124 | urn:ogc:def:crs:EPSG::27700 125 | 126 | featurecode 127 | featureCode 128 | Integer 129 | 130 | 131 | distinctiveName 132 | distinctiveName 133 | String 134 | 135 | 136 | classification 137 | classification 138 | String 139 | 18 140 | 141 | 142 | fontHeight 143 | fontHeight 144 | String 145 | 6 146 | 147 | 148 | textOrientation 149 | textOrientation 150 | Integer 151 | 152 | 153 | textOrientation_uom 154 | textOrientation_uom 155 | String 156 | 7 157 | 158 | 159 | 160 | RailwayStation 161 | RailwayStation 162 | 1 163 | urn:ogc:def:crs:EPSG::27700 164 | 165 | featurecode 166 | featureCode 167 | Integer 168 | 169 | 170 | distinctiveName 171 | distinctiveName 172 | String 173 | 174 | 175 | classification 176 | classification 177 | String 178 | 179 | 180 | 181 | RailwayTrack 182 | RailwayTrack 183 | 2 184 | urn:ogc:def:crs:EPSG::27700 185 | 186 | featurecode 187 | featureCode 188 | Integer 189 | 190 | 191 | classification 192 | classification 193 | String 194 | 12 195 | 196 | 197 | 198 | RailwayTunnel 199 | RailwayTunnel 200 | 2 201 | urn:ogc:def:crs:EPSG::27700 202 | 203 | featurecode 204 | featureCode 205 | Integer 206 | 207 | 208 | 209 | Road 210 | Road 211 | 2 212 | urn:ogc:def:crs:EPSG::27700 213 | 214 | featurecode 215 | featureCode 216 | Integer 217 | 218 | 219 | distinctiveName 220 | distinctiveName 221 | String 222 | 223 | 224 | roadNumber 225 | roadNumber 226 | String 227 | 228 | 229 | classification 230 | classification 231 | String 232 | 40 233 | 234 | 235 | drawLevel 236 | drawLevel 237 | Integer 238 | 239 | 240 | override 241 | override 242 | String 243 | 1 244 | 245 | 246 | 247 | RoadTunnel 248 | RoadTunnel 249 | 2 250 | urn:ogc:def:crs:EPSG::27700 251 | 252 | featurecode 253 | featureCode 254 | Integer 255 | 256 | 257 | 258 | Roundabout 259 | Roundabout 260 | 1 261 | urn:ogc:def:crs:EPSG::27700 262 | 263 | featurecode 264 | featureCode 265 | Integer 266 | 267 | 268 | classification 269 | classification 270 | String 271 | 12 272 | 273 | 274 | 275 | SurfaceWater_Area 276 | SurfaceWater_Area 277 | 3 278 | urn:ogc:def:crs:EPSG::27700 279 | 280 | featurecode 281 | featureCode 282 | Integer 283 | 284 | 285 | 286 | SurfaceWater_Line 287 | SurfaceWater_Line 288 | 2 289 | urn:ogc:def:crs:EPSG::27700 290 | 291 | featurecode 292 | featureCode 293 | Integer 294 | 295 | 296 | 297 | TidalBoundary 298 | TidalBoundary 299 | 2 300 | urn:ogc:def:crs:EPSG::27700 301 | 302 | featurecode 303 | featureCode 304 | Integer 305 | 306 | 307 | classification 308 | classification 309 | String 310 | 15 311 | 312 | 313 | 314 | TidalWater 315 | TidalWater 316 | 3 317 | urn:ogc:def:crs:EPSG::27700 318 | 319 | featurecode 320 | featureCode 321 | Integer 322 | 323 | 324 | 325 | Woodland 326 | Woodland 327 | 3 328 | urn:ogc:def:crs:EPSG::27700 329 | 330 | featurecode 331 | featureCode 332 | Integer 333 | 334 | 335 | 336 | -------------------------------------------------------------------------------- /gfs/osopenroads.gfs: -------------------------------------------------------------------------------- 1 | 2 | 6 | true 7 | 8 | RoadLink 9 | RoadLink 10 | 2 11 | urn:ogc:def:crs:EPSG::27700 12 | 13 | fictitious 14 | fictitious 15 | String 16 | 17 | 18 | startNode 19 | startNode@href 20 | String 21 | 22 | 23 | endNode 24 | endNode@href 25 | String 26 | 27 | 28 | roadClassification 29 | roadClassification 30 | String 31 | 32 | 33 | formOfWay 34 | formOfWay 35 | String 36 | 37 | 38 | length 39 | length 40 | Real 41 | 42 | 43 | length_uom 44 | length_uom 45 | String 46 | 47 | 48 | loop 49 | loop 50 | String 51 | 52 | 53 | name1 54 | name1 55 | String 56 | 57 | 58 | roadClassificationNumber 59 | roadClassificationNumber 60 | String 61 | 62 | 63 | strategicRoad 64 | strategicRoad 65 | String 66 | 67 | 68 | name2 69 | name2 70 | String 71 | 72 | 73 | name1_lang 74 | name1@lang 75 | String 76 | 77 | 78 | structure 79 | structure 80 | String 81 | 82 | 83 | name2_lang 84 | name2@lang 85 | String 86 | 87 | 88 | formsPartOf 89 | formsPartOf@href 90 | String 91 | 92 | 93 | 94 | RoadNode 95 | RoadNode 96 | 1 97 | urn:ogc:def:crs:EPSG::27700 98 | 99 | formOfRoadNode 100 | formOfRoadNode 101 | String 102 | 103 | 104 | 105 | MotorwayJunction 106 | MotorwayJunction 107 | 1 108 | urn:ogc:def:crs:EPSG::27700 109 | 110 | junctionNumber 111 | junctionNumber 112 | String 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /gfs/terrain50.gfs: -------------------------------------------------------------------------------- 1 | 2 | 3 | SpotHeight 4 | SpotHeight 5 | 1 6 | urn:ogc:def:crs:EPSG::27700 7 | 8 | propertyValue 9 | propertyValue 10 | Integer 11 | 12 | 13 | propertyValue_uom 14 | propertyValue_uom 15 | String 16 | 1 17 | 18 | 19 | spotHeightType 20 | spotHeightType 21 | String 22 | 7 23 | 24 | 25 | fid 26 | fid 27 | String 28 | 20 29 | 30 | 31 | 32 | ContourLine 33 | ContourLine 34 | 2 35 | urn:ogc:def:crs:EPSG::27700 36 | 37 | propertyValue 38 | propertyValue 39 | Integer 40 | 41 | 42 | propertyValue_uom 43 | propertyValue_uom 44 | String 45 | 1 46 | 47 | 48 | contourLineType 49 | contourLineType 50 | String 51 | 8 52 | 53 | 54 | fid 55 | fid 56 | String 57 | 20 58 | 59 | 60 | 61 | LandWaterBoundary 62 | LandWaterBoundary 63 | 2 64 | urn:ogc:def:crs:EPSG::27700 65 | 66 | propertyValue 67 | propertyValue 68 | Real 69 | 70 | 71 | propertyValue_uom 72 | propertyValue_uom 73 | String 74 | 1 75 | 76 | 77 | waterLevelCategory 78 | waterLevelCategory 79 | String 80 | 13 81 | 82 | 83 | fid 84 | fid 85 | String 86 | 20 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /gfs/vml_postgres.gfs: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | Text 8 | Text 9 | 1 10 | EPSG:27700 11 | 12 | featureid 13 | featureid 14 | String 15 | 16 | 17 | featureCode 18 | featureCode 19 | Integer 20 | 21 | 22 | featureDescription 23 | featureDescription 24 | String 25 | 26 | 27 | anchorPosition 28 | textRendering|textRenderingType|anchorPosition 29 | Integer 30 | 31 | 32 | font 33 | textRendering|textRenderingType|font 34 | Integer 35 | 36 | 37 | height 38 | textRendering|textRenderingType|height 39 | Integer 40 | 41 | 42 | orientation 43 | textRendering|textRenderingType|orientation 44 | Integer 45 | 46 | 47 | orientDeg 48 | textRendering|orientDeg 49 | Real 50 | 51 | 52 | orientation_uom 53 | textRendering|textRenderingType|orientation_uom 54 | String 55 | 6 56 | 57 | 58 | textString 59 | textString 60 | String 61 | 62 | 63 | tile 64 | tile 65 | String 66 | 67 | 68 | 69 | VectorMapPoint 70 | VectorMapPoint 71 | 1 72 | EPSG:27700 73 | 74 | featureid 75 | featureID 76 | String 77 | 78 | 79 | featureCode 80 | featureCode 81 | Integer 82 | 83 | 84 | featureDescription 85 | featureDescription 86 | String 87 | 88 | 89 | orientation 90 | orientation 91 | Integer 92 | 93 | 94 | orientDeg 95 | orientDeg 96 | Real 97 | 98 | 99 | orientation_uom 100 | orientation_uom 101 | String 102 | 103 | 104 | tile 105 | tile 106 | String 107 | 108 | 109 | 110 | Line 111 | Line 112 | 2 113 | EPSG:27700 114 | 115 | featureid 116 | featureID 117 | String 118 | 119 | 120 | featureCode 121 | featureCode 122 | Integer 123 | 124 | 125 | featureDescription 126 | featureDescription 127 | String 128 | 129 | 130 | tile 131 | tile 132 | String 133 | 134 | 135 | 136 | RoadCLine 137 | RoadCLine 138 | 2 139 | EPSG:27700 140 | 141 | featureid 142 | featureID 143 | String 144 | 145 | 146 | featureCode 147 | featureCode 148 | Integer 149 | 150 | 151 | featureDescription 152 | featureDescription 153 | String 154 | 155 | 156 | roadNumber 157 | roadNumber 158 | String 159 | 160 | 161 | roadName 162 | roadName 163 | String 164 | 165 | 166 | drawLevel 167 | drawLevel 168 | Integer 169 | 170 | 171 | override 172 | override 173 | String 174 | Boolean 175 | 0 176 | 177 | 178 | suppressed 179 | suppressed 180 | String 181 | Boolean 182 | 183 | 184 | inTunnel 185 | inTunnel 186 | String 187 | Boolean 188 | 189 | 190 | tile 191 | tile 192 | String 193 | 194 | 195 | 196 | RailCLine 197 | RailCLine 198 | 2 199 | EPSG:27700 200 | 201 | featureid 202 | featureID 203 | String 204 | 205 | 206 | featureCode 207 | featureCode 208 | Integer 209 | 210 | 211 | featureDescription 212 | featureDescription 213 | String 214 | 215 | 216 | suppressed 217 | suppressed 218 | String 219 | Boolean 220 | 221 | 222 | inTunnel 223 | inTunnel 224 | String 225 | Boolean 226 | 227 | 228 | tile 229 | tile 230 | String 231 | 232 | 233 | 234 | Area 235 | Area 236 | 3 237 | EPSG:27700 238 | 239 | featureid 240 | featureID 241 | String 242 | 243 | 244 | featureCode 245 | featureCode 246 | Integer 247 | 248 | 249 | featureDescription 250 | featureDescription 251 | String 252 | 253 | 254 | tile 255 | tile 256 | String 257 | 258 | 259 | 260 | -------------------------------------------------------------------------------- /gfs/vml_shape.gfs: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | Text 8 | Text 9 | 1 10 | EPSG:27700 11 | 12 | fid 13 | fid 14 | String 15 | 7 16 | 17 | 18 | featcode 19 | featureCode 20 | Integer 21 | 22 | 23 | featdesc 24 | featureDescription 25 | String 26 | 254 27 | 28 | 29 | anchor 30 | textRendering|anchorPosition 31 | Integer 32 | 33 | 34 | font 35 | textRendering|font 36 | Integer 37 | 38 | 39 | height 40 | textRendering|height 41 | Real 42 | 43 | 44 | angle 45 | textRendering|orientation 46 | Integer 47 | 48 | 49 | text 50 | textString 51 | String 52 | 254 53 | 54 | 55 | 56 | VectorMapPoint 57 | VectorMapPoint 58 | 1 59 | EPSG:27700 60 | 61 | fid 62 | fid 63 | String 64 | 7 65 | 66 | 67 | featcode 68 | featureCode 69 | Integer 70 | 71 | 72 | featdesc 73 | featureDescription 74 | String 75 | 254 76 | 77 | 78 | angle 79 | orientation 80 | Integer 81 | 82 | 83 | 84 | Line 85 | Line 86 | 2 87 | EPSG:27700 88 | 89 | fid 90 | fid 91 | String 92 | 7 93 | 94 | 95 | featcode 96 | featureCode 97 | Integer 98 | 99 | 100 | featdesc 101 | featureDescription 102 | String 103 | 254 104 | 105 | 106 | 107 | RoadCLine 108 | RoadCLine 109 | 2 110 | EPSG:27700 111 | 112 | fid 113 | fid 114 | String 115 | 7 116 | 117 | 118 | featcode 119 | featureCode 120 | Integer 121 | 122 | 123 | featdesc 124 | featureDescription 125 | String 126 | 254 127 | 128 | 129 | number 130 | roadNumber 131 | String 132 | 254 133 | 134 | 135 | name 136 | roadName 137 | String 138 | 254 139 | 140 | 141 | 142 | Area 143 | Area 144 | 3 145 | EPSG:27700 146 | 147 | fid 148 | fid 149 | String 150 | 7 151 | 152 | 153 | featcode 154 | featureCode 155 | Integer 156 | 157 | 158 | featdesc 159 | featureDescription 160 | String 161 | 254 162 | 163 | 164 | 165 | -------------------------------------------------------------------------------- /python/loader.config: -------------------------------------------------------------------------------- 1 | # Note: Environment variables can be used with any of 2 | # the options by using a token of the form: 3 | # $HOME, ${HOME} or %TEMP% (Windows only) 4 | 5 | # The directory containing your source files. 6 | # All supported files in the specified directory and 7 | # it's descendants will be loaded. 8 | src_dir=/path/to/source/data/folder 9 | 10 | # The directory used to store the translated data 11 | # if writing to a file based format such as ESRI 12 | # Shape, MapInfo TAB etc. 13 | out_dir=/path/to/output/data/folder 14 | 15 | # The directory used to store temporary working files 16 | # during loading. 17 | tmp_dir=/path/to/temp/folder 18 | 19 | # The ogr2ogr command that will be used to load the data. 20 | # Here you can specify the destination format and any 21 | # associated settings (for example database connection 22 | # details if you are writing to PostGIS). 23 | # As well as environment variables the following tokens can 24 | # be used which will be substituted at runtime: 25 | # $output_dir - the directory specified by the out_dir setting 26 | # $base_file_name - the file name of the file to be loaded 27 | # $file_path - the full path of the file to be loaded 28 | # $gfs_file - the path to the gfs_file (commonly used via: --config GML_GFS_TEMPLATE $gfs_file) 29 | ogr_cmd=ogr2ogr --config GML_EXPOSE_FID NO -append -skipfailures -f PostgreSQL PG:'dbname=postgis active_schema=public host=localhost user=postgres password=postgres' $file_path 30 | 31 | # The command used to prepare the source 32 | # data so it is suitable for loading with OGR. Choose a prep 33 | # class appropriate for your data, for Ordnance Survey 34 | # products take a look at prep_osgml.py for the available classes. 35 | prep_cmd=python prepgml4ogr.py $file_path prep_osgml.prep_osmm_topo 36 | 37 | # An optional command to be run once OGR has created it's output. 38 | # Called once per file, useful for loading SQL dump files etc. 39 | # All of the tokens available to the ogr_cmd can be used here. 40 | post_cmd= 41 | 42 | # Optional OGR .gfs file used to define the 43 | # feature attributes and geometry type of 44 | # the features read from the GML. 45 | gfs_file=../gfs/osmm_topo_postgres.gfs 46 | 47 | # Whether to output debug messages and keep 48 | # temporary files (True or False). 49 | debug=False 50 | -------------------------------------------------------------------------------- /python/loader.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 3 | # Licensed under [MIT License](https://git.io/fAxH0). 4 | 5 | """Simple GML/KML loader that provides an easy way of preparing the document before 6 | passing it to OGR for loading, handles loading a directory of files and uncompresses 7 | GZ/ZIP if required """ 8 | 9 | from __future__ import with_statement 10 | import sys 11 | import os 12 | import shutil 13 | import shlex 14 | import subprocess 15 | from string import Template 16 | import tempfile 17 | 18 | 19 | class LoaderError(Exception): 20 | def __init__(self, message=''): 21 | Exception.__init__(self, message) 22 | 23 | 24 | class ConfigError(LoaderError): 25 | pass 26 | 27 | 28 | class MissingConfigError(ConfigError): 29 | def __init__(self, key): 30 | Exception.__init__(self, 'Missing configuration value: %s' % key) 31 | self.key = key 32 | 33 | 34 | class CreateTempDirError(IOError): 35 | def __init__(self, errno, strerror, filename): 36 | strerror = 'Could not create temp directory (%s)' % strerror.lower() 37 | IOError.__init__(self, errno, strerror, filename) 38 | 39 | 40 | class RemoveTempDirError(OSError): 41 | def __init__(self, errno, strerror, filename): 42 | strerror = 'Could not remove temp directory (%s)' % strerror.lower() 43 | OSError.__init__(self, errno, strerror, filename) 44 | 45 | 46 | class Loader: 47 | 48 | """Simple GML & KML Loader wrapping ogr2ogr. 49 | Usage: 50 | loader = Loader() 51 | loader.run(config) 52 | For a full list of config see read_config""" 53 | 54 | def __init__(self): 55 | pass 56 | 57 | def run(self, config): 58 | self.read_config(config) 59 | self.setup() 60 | self.load() 61 | self.cleanup() 62 | 63 | def read_config(self, config): 64 | self.config = config 65 | try: 66 | self.src_dir = config['src_dir'] 67 | self.out_dir = config['out_dir'] 68 | self.tmp_dir = config['tmp_dir'] 69 | self.prep_cmd = config['prep_cmd'] 70 | self.ogr_cmd = config['ogr_cmd'] 71 | self.gfs_file = config['gfs_file'] 72 | except KeyError as key: 73 | raise MissingConfigError(key) 74 | self.debug = config.get('debug') 75 | self.post_cmd = config.get('post_cmd') 76 | 77 | def setup(self): 78 | # Determine if we are in debug mode 79 | self.debug = (str(self.debug).lower() == 'true') 80 | if self.debug: 81 | print("Config: %s" % self.config) 82 | # Set the encoding of the text output by the prep_cmd 83 | os.environ['PYTHONIOENCODING'] = 'utf-8' 84 | # Check that a valid gfs is file specified 85 | if not os.path.isfile(self.gfs_file): 86 | self.gfs_file = None 87 | print("No valid gfs file found, output schema and geometry types will be determined dynamically by OGR") 88 | # Create a temp directory as a child to the temp 89 | # directory specified to hold all of our working 90 | # files and to make cleaning up simple 91 | try: 92 | self.tmp_dir = tempfile.mkdtemp(dir=self.tmp_dir) 93 | except (OSError) as ex: 94 | raise CreateTempDirError(ex.errno, ex.strerror, self.tmp_dir) 95 | 96 | def cleanup(self): 97 | if not self.debug: 98 | try: 99 | shutil.rmtree(self.tmp_dir) 100 | except OSError as ex: 101 | raise RemoveTempDirError(ex.errno, ex.strerror, self.tmp_dir) 102 | 103 | def load(self): 104 | # Create string templates for the commands 105 | self.ogr_cmd = Template(self.ogr_cmd) 106 | num_files = 0 107 | if os.path.isdir(self.src_dir): 108 | for root, dirs, files in os.walk(self.src_dir): 109 | for file_name in files: 110 | ext = os.path.splitext(file_name)[1].lower() 111 | if ext in ['.gz', '.gml', '.zip', '.kml']: 112 | if self.load_file(root, file_name): 113 | num_files += 1 114 | else: 115 | (root, file_name) = os.path.split(self.src_dir) 116 | if self.load_file(root, file_name): 117 | num_files += 1 118 | print("Loaded %i file%s" % (num_files, "" if num_files == 1 else "s")) 119 | 120 | def load_file(self, root, file_name): 121 | exit_status = 0 122 | 123 | file_path = os.path.join(root, file_name) 124 | print("Processing: %s" % file_path) 125 | 126 | # Run the script to prepare the GML if one is defined, otherwise just 127 | # copy the existing file to the tmp directory 128 | prep_file_name = os.path.splitext(file_name)[0] 129 | prep_file_path = os.path.join(self.tmp_dir, prep_file_name) 130 | if self.debug: 131 | print("Prepared file: %s" % prep_file_path) 132 | if self.prep_cmd: 133 | prep_args = shlex.split(Template(self.prep_cmd).safe_substitute(file_path='\'' + file_path + '\'')) 134 | if self.debug: 135 | print("Prep command: %s" % " ".join(prep_args)) 136 | with open(prep_file_path, 'w') as f: 137 | exit_status = subprocess.call(prep_args, stdout=f, stderr=sys.stderr) 138 | if exit_status != 0: 139 | return False 140 | else: 141 | shutil.copy(file_path, prep_file_path) 142 | 143 | # Copy over the template gfs file used by ogr2ogr 144 | # to read the GML attributes, determine the geometry type etc. 145 | # Using a template so we have control over the geometry type 146 | # for each table 147 | if self.gfs_file: 148 | shutil.copy(self.gfs_file, os.path.join(self.tmp_dir, prep_file_name + '.gfs')) 149 | 150 | # Run ogr2ogr to do the actual load 151 | print("Loading: %s" % file_path) 152 | ogr_args = shlex.split(self.ogr_cmd.safe_substitute(out_dir='\'' + self.out_dir + '\'', output_dir='\'' + self.out_dir + '\'', base_file_name='\'' + prep_file_name + '\'', file_path='\'' + prep_file_path + '\'', gfs_file='\'' + self.gfs_file + '\'')) 153 | if self.debug: 154 | print("OGR command: %s" % " ".join(ogr_args)) 155 | exit_status = subprocess.call(ogr_args, stderr=sys.stderr) 156 | if exit_status != 0: 157 | return False 158 | 159 | # If there is a post command defined then run it, 160 | # commonly used to do some post processing of the 161 | # output created by ogr2ogr 162 | if self.post_cmd: 163 | post_cmd = Template(self.post_cmd) 164 | post_args = shlex.split(post_cmd.safe_substitute(out_dir='\'' + self.out_dir + '\'', output_dir='\'' + self.out_dir + '\'', base_file_name='\'' + prep_file_name + '\'', file_path='\'' + prep_file_path + '\'')) 165 | if self.debug: 166 | print("Post command: %s" % " ".join(post_args)) 167 | exit_status = subprocess.call(post_args, stderr=sys.stderr) 168 | if exit_status != 0: 169 | return False 170 | if not self.debug: 171 | # Clean up by deleting the temporary prepared file 172 | os.remove(prep_file_path) 173 | 174 | return True 175 | 176 | 177 | def main(): 178 | if len(sys.argv) < 2: 179 | print("usage: python loader.py loader.config [key=value]") 180 | exit(1) 181 | config_file = sys.argv[1] 182 | if os.path.exists(config_file): 183 | # Build a dict of configuration expanding 184 | # any environment variables found in the values 185 | config = {} 186 | with open(config_file, 'r') as f: 187 | for line in f.readlines(): 188 | line = line.replace('\n', '').strip() 189 | if len(line) and line[0:1] != '#': 190 | parts = line.split('=', 1) 191 | config[parts[0]] = os.path.expandvars(parts[1]) 192 | # Build a dict of arguments passed on the command line that 193 | # override those in the config file, no need to expand environment 194 | # variables as the shell will take care of it 195 | overrides = dict([arg.split('=', 1) for arg in sys.argv[2:]]) 196 | config.update(overrides) 197 | # Kick off the loader with the specified configuration 198 | try: 199 | loader = Loader() 200 | loader.run(config) 201 | except (MissingConfigError, ConfigError) as ex: 202 | print(ex) 203 | exit(1) 204 | except (CreateTempDirError, RemoveTempDirError) as ex: 205 | print("%s: %s" % (ex.strerror, ex.filename)) 206 | exit(1) 207 | else: 208 | print("Could not find config file: %s" % config_file) 209 | 210 | if __name__ == '__main__': 211 | main() 212 | -------------------------------------------------------------------------------- /python/osmm_topo_style/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AstunTechnology/Loader/f992f3ff60f408fcd84bf9e3d2d31eadb18189ad/python/osmm_topo_style/__init__.py -------------------------------------------------------------------------------- /python/osmm_topo_style/area_style.py: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------------------------------------------- 2 | # Name: Topographic Area Style 3 | # Purpose: 4 | # 5 | # Author: sbatterby 6 | # 7 | # Created: 05/02/2016 8 | # Copyright: (c) sbatterby 2016 9 | #------------------------------------------------------------------------------------------------------------------- 10 | 11 | import arcpy 12 | import os 13 | import logging 14 | 15 | logger = logging.getLogger("style_debug") 16 | 17 | 18 | #------------------------------------------------------------------------------------------------------------------- 19 | # Calculates the style code value 20 | def CalculateStyleCode(row): 21 | descTerm = row[3] 22 | descGroup = row[4] 23 | make = row[5] 24 | returnVal = 99 25 | 26 | if descTerm is None: 27 | descTerm = "" 28 | 29 | if descGroup is None: 30 | descGroup = "" 31 | 32 | if (descTerm == "Multi Surface"): 33 | returnVal = 1 34 | elif (descTerm == "Archway"): 35 | returnVal = 2 36 | elif (descTerm is not None and descTerm.find("Bridge") > -1 and (descGroup.find("Road Or Track") > -1 or descGroup.find("Roadside") > -1)): 37 | returnVal = 3 38 | elif (descTerm is not None and descTerm.find("Bridge") > -1 and descGroup.find("Rail") > -1): 39 | returnVal = 4 40 | elif (descTerm is not None and descTerm.find("Bridge") > -1): 41 | returnVal = 5 42 | elif (descTerm is not None and descTerm.find("Level Crossing") > -1): 43 | returnVal = 6 44 | elif (descTerm == "Traffic Calming"): 45 | returnVal = 7 46 | elif (descTerm == "Pylon"): 47 | returnVal = 8 48 | elif (descTerm == "Track"): 49 | returnVal = 9 50 | elif (descTerm == "Step"): 51 | returnVal = 10 52 | elif (descTerm == "Canal"): 53 | returnVal = 11 54 | elif (descTerm == "Footbridge"): 55 | returnVal = 12 56 | 57 | # Natural Environment Descriptive Term Rules 58 | elif (descTerm is not None and (descTerm.find("Nonconiferous Trees") > -1 or descTerm.find("Nonconiferous Trees (Scattered)") > -1) and (descTerm.find("Coniferous Trees") > -1 or descTerm.find("Coniferous Trees (Scattered)") > -1)): 59 | returnVal = 13 60 | elif (descTerm is not None and descTerm.find("Nonconiferous Trees") > -1 or descTerm.find("Nonconiferous Trees (Scattered)") > -1): 61 | returnVal = 14 62 | elif (descTerm is not None and descTerm.find("Coniferous Trees") > -1 or descTerm.find("Coniferous Trees (Scattered)") > -1): 63 | returnVal = 15 64 | elif (descTerm is not None and descTerm.find("Agricultural Land") > -1): 65 | returnVal = 16 66 | elif (descTerm.find("Orchard") > -1): 67 | returnVal = 17 68 | elif (descTerm.find("Coppice Or Osiers") > -1): 69 | returnVal = 18 70 | elif (descTerm.find("Scrub") > -1): 71 | returnVal = 19 72 | elif (descTerm.find("Boulders") > -1 or descTerm.find("Boulders (Scattered)") > -1): 73 | returnVal = 20 74 | elif (descTerm.find("Rock") > -1 or descTerm.find("Rock (Scattered)") > -1): 75 | returnVal = 21 76 | elif (descTerm.find("Scree") > -1): 77 | returnVal = 22 78 | elif (descTerm.find("Rough Grassland") > -1): 79 | returnVal = 23 80 | elif (descTerm.find("Heath") > -1): 81 | returnVal = 24 82 | elif (descTerm.find("Marsh Reeds Or Saltmarsh") > -1 or descTerm.find("Saltmarsh") > -1): 83 | returnVal = 25 84 | elif (descTerm.find("Sand") > -1): 85 | returnVal = 26 86 | elif (descTerm.find("Mud") > -1): 87 | returnVal = 27 88 | elif (descTerm.find("Shingle") > -1): 89 | returnVal = 28 90 | elif (descTerm.find("Marsh") > -1): 91 | returnVal = 29 92 | elif (descTerm.find("Reeds") > -1): 93 | returnVal = 30 94 | elif (descTerm.find("Foreshore") > -1): 95 | returnVal = 31 96 | elif (descTerm.find("Slope") > -1): 97 | returnVal = 32 98 | elif (descTerm.find("Cliff") > -1): 99 | returnVal = 33 100 | 101 | # Descriptive group rules 102 | elif (descGroup.find("Building") > -1): 103 | returnVal = 34 104 | elif (descGroup.find("General Surface") > -1 and make == "Natural"): 105 | returnVal = 35 106 | elif (descGroup.find("General Surface") > -1 and (make == "Manmade" or make == "Unknown")): 107 | returnVal = 36 108 | elif (descGroup.find("Road Or Track") > -1 and make == "Manmade"): 109 | returnVal = 37 110 | elif (descGroup.find("Roadside") > -1 and make == "Natural"): 111 | returnVal = 38 112 | elif (descGroup.find("Roadside") > -1 and (make == "Manmade" or make == "Unknown")): 113 | returnVal = 39 114 | elif (descGroup.find("Inland Water") > -1): 115 | returnVal = 40 116 | elif (descGroup.find("Path") > -1): 117 | returnVal = 41 118 | elif (descGroup.find("Rail") > -1 and (make == "Manmade" or make == "Unknown")): 119 | returnVal = 42 120 | elif (descGroup.find("Rail") > -1 and make == "Natural"): 121 | returnVal = 43 122 | elif (descGroup.find("Structure") > -1): 123 | returnVal = 44 124 | elif (descGroup == "Glasshouse"): 125 | returnVal = 45 126 | elif (descGroup.find("Landform") > -1 and make == "Natural"): 127 | returnVal = 46 128 | elif (descGroup.find("Tidal Water") > -1): 129 | returnVal = 47 130 | elif (descGroup.find("Landform") > -1 and make == "Manmade"): 131 | returnVal = 48 132 | else: 133 | returnVal = 99 134 | 135 | logger.debug("Style Code:"+ str(returnVal)) 136 | 137 | return returnVal 138 | #------------------------------------------------------------------------------------------------------------------- 139 | 140 | 141 | #------------------------------------------------------------------------------------------------------------------- 142 | # Calculates the style description value 143 | def CalculateStyleDescription(row): 144 | descTerm = row[3] 145 | descGroup = row[4] 146 | make = row[5] 147 | returnVal = "Unclassified" 148 | 149 | if descTerm is None: 150 | descTerm = "" 151 | 152 | if descGroup is None: 153 | descGroup = "" 154 | 155 | if (descTerm == "Multi Surface"): 156 | returnVal = "Multi Surface Fill" 157 | elif (descTerm == "Archway"): 158 | returnVal = "Archway Fill" 159 | elif (descTerm.find("Bridge") > -1 and (descGroup.find("Road Or Track") > -1 or descGroup.find("Roadside") > -1)): 160 | returnVal = "Road Bridge Fill" 161 | elif (descTerm.find("Bridge") > -1 and descGroup.find("Rail") > -1): 162 | returnVal = "Rail Bridge Fill" 163 | elif (descTerm.find("Bridge") > -1): 164 | returnVal = "Bridge Fill" 165 | elif (descTerm.find("Level Crossing") > -1): 166 | returnVal = "Level Crossing Fill" 167 | elif (descTerm.find("Traffic Calming") > -1): 168 | returnVal = "Traffic Calming Fill" 169 | elif (descTerm.find("Pylon") > -1): 170 | returnVal = "Pylon Fill" 171 | elif (descTerm.find("Track") > -1): 172 | returnVal = "Track Fill" 173 | elif (descTerm.find("Step") > -1): 174 | returnVal = "Step Fill" 175 | elif (descTerm.find("Canal") > -1): 176 | returnVal = "Canal Fill" 177 | elif (descTerm.find("Footbridge") > -1): 178 | returnVal = "Footbridge Fill" 179 | 180 | # Natural Environment Descriptive Term Rules 181 | elif ((descTerm.find("Nonconiferous Trees") > -1 or descTerm.find("Nonconiferous Trees (Scattered)") > -1) and (descTerm.find("Coniferous Trees") > -1 or descTerm.find("Coniferous Trees (Scattered)") > -1)): 182 | returnVal = "Mixed Woodland Fill" 183 | elif (descTerm.find("Nonconiferous Trees") > -1 or descTerm.find("Nonconiferous Trees (Scattered)") > -1): 184 | returnVal = "Nonconiferous Tree Fill" 185 | elif (descTerm.find("Coniferous Trees") > -1 or descTerm.find("Coniferous Trees (Scattered)") > -1): 186 | returnVal = "Coniferous Tree Fill" 187 | elif (descTerm.find("Agricultural Land") > -1): 188 | returnVal = "Agricultural Land Fill" 189 | elif (descTerm.find("Orchard") > -1): 190 | returnVal = "Orchard Fill" 191 | elif (descTerm.find("Coppice Or Osiers") > -1): 192 | returnVal = "Coppice Or Osiers Fill" 193 | elif (descTerm.find("Scrub") > -1): 194 | returnVal = "Scrub Fill" 195 | elif (descTerm.find("Boulders") > -1 or descTerm.find("Boulders (Scattered)") > -1): 196 | returnVal = "Boulders Fill" 197 | elif (descTerm.find("Rock") > -1 or descTerm.find("Rock (Scattered)") > -1): 198 | returnVal = "Rock Fill" 199 | elif (descTerm.find("Scree") > -1): 200 | returnVal = "Scree Fill" 201 | elif (descTerm.find("Rough Grassland") > -1): 202 | returnVal = "Rough Grassland Fill" 203 | elif (descTerm.find("Heath") > -1): 204 | returnVal = "Heath Fill" 205 | elif (descTerm.find("Marsh Reeds Or Saltmarsh") > -1 or descTerm.find("Saltmarsh") > -1): 206 | returnVal = "Marsh Fill" 207 | elif (descTerm.find("Sand") > -1): 208 | returnVal = "Sand Fill" 209 | elif (descTerm.find("Mud") > -1): 210 | returnVal = "Mud Fill" 211 | elif (descTerm.find("Shingle") > -1): 212 | returnVal = "Shingle Fill" 213 | elif (descTerm.find("Marsh") > -1): 214 | returnVal = "Marsh Fill" 215 | elif (descTerm.find("Reeds") > -1): 216 | returnVal = "Reeds Fill" 217 | elif (descTerm.find("Foreshore") > -1): 218 | returnVal = "Foreshore Fill" 219 | elif (descTerm.find("Slope") > -1): 220 | returnVal = "Slope Fill" 221 | elif (descTerm.find("Cliff") > -1): 222 | returnVal = "Cliff Fill" 223 | 224 | # Descriptive group rules 225 | elif (descGroup.find("Building") > -1): 226 | returnVal = "Building Fill" 227 | elif (descGroup.find("General Surface") > -1 and make == "Natural"): 228 | returnVal = "Natural Fill" 229 | elif (descGroup.find("General Surface") > -1 and (make == "Manmade" or make == "Unknown")): 230 | returnVal = "Manmade Fill" 231 | elif (descGroup.find("Road Or Track") > -1 and make == "Manmade"): 232 | returnVal = "Road Or Track Fill" 233 | elif (descGroup.find("Roadside") > -1 and make == "Natural"): 234 | returnVal = "Roadside Natural Fill" 235 | elif (descGroup.find("Roadside") > -1 and (make == "Manmade" or make == "Unknown")): 236 | returnVal = "Roadside Manmade Fill" 237 | elif (descGroup.find("Inland Water") > -1): 238 | returnVal = "Inland Water Fill" 239 | elif (descGroup.find("Path") > -1): 240 | returnVal = "Path Fill" 241 | elif (descGroup.find("Rail") > -1 and (make == "Manmade" or make == "Unknown")): 242 | returnVal = "Rail Manmade Fill" 243 | elif (descGroup.find("Rail") > -1 and make == "Natural"): 244 | returnVal = "Rail Natural Fill" 245 | elif (descGroup.find("Structure") > -1): 246 | returnVal = "Structure Fill" 247 | elif (descGroup == "Glasshouse"): 248 | returnVal = "Glasshouse Fill" 249 | elif (descGroup.find("Landform") > -1 and make == "Natural"): 250 | returnVal = "Landform Natural Fill" 251 | elif (descGroup.find("Tidal Water") > -1): 252 | returnVal = "Tidal Water Fill" 253 | elif (descGroup.find("Landform") > -1 and make == "Manmade"): 254 | returnVal = "Landform Manmade Fill" 255 | 256 | else: 257 | returnVal = "Unclassified" 258 | 259 | 260 | logger.debug("Style Description:"+ returnVal) 261 | 262 | return returnVal; 263 | #------------------------------------------------------------------------------------------------------------------- 264 | -------------------------------------------------------------------------------- /python/osmm_topo_style/bnd_style.py: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | # Name: Boundary Line Style 3 | # Purpose: 4 | # 5 | # Author: sbatterby 6 | # 7 | # Created: 09/02/2016 8 | # Copyright: (c) sbatterby 2016 9 | #------------------------------------------------------------------------------- 10 | 11 | import arcpy 12 | import os 13 | import logging 14 | 15 | logger = logging.getLogger("style_debug") 16 | 17 | 18 | #------------------------------------------------------------------------------- 19 | # Calculates the style code value 20 | def CalculateStyleCode(row): 21 | featureCode = row[3] 22 | returnVal = 99 23 | 24 | if (featureCode == 10136): 25 | returnVal = 1 26 | elif (featureCode == 10131): 27 | returnVal = 2 28 | elif (featureCode == 10128): 29 | returnVal = 3 30 | elif (featureCode == 10127): 31 | returnVal = 4 32 | elif (featureCode == 10135): 33 | returnVal = 5 34 | else: 35 | returnVal = 99 36 | 37 | logger.debug("Style Code:"+ str(returnVal)) 38 | 39 | return returnVal 40 | #------------------------------------------------------------------------------- 41 | 42 | 43 | #------------------------------------------------------------------------------- 44 | # Calculates the style description value 45 | def CalculateStyleDescription(row): 46 | featureCode = row[3] 47 | returnVal = "Unclassified" 48 | 49 | if (featureCode == 10136): 50 | returnVal = "Parish Boundary" 51 | elif (featureCode == 10131): 52 | returnVal = "District Boundary" 53 | elif (featureCode == 10128): 54 | returnVal = "Electoral Boundary" 55 | elif (featureCode == 10127): 56 | returnVal = "County Boundary" 57 | elif (featureCode == 10135): 58 | returnVal = "Parliamentary Boundary" 59 | else: 60 | returnVal = "Unclassified" 61 | 62 | 63 | logger.debug("Style Description:"+ returnVal) 64 | 65 | return returnVal; 66 | #------------------------------------------------------------------------------- -------------------------------------------------------------------------------- /python/osmm_topo_style/line_style.py: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | # Name: Topographic Line style 3 | # Purpose: Calculates the style description and code for lines. 4 | # 5 | # Author: sbatterby 6 | # 7 | # Created: 04/02/2016 8 | # Copyright: (c) sbatterby 2016 9 | #------------------------------------------------------------------------------- 10 | import arcpy 11 | import os 12 | import logging 13 | 14 | logger = logging.getLogger("style_debug") 15 | 16 | 17 | #------------------------------------------------------------------------------- 18 | # Calculates the style code value 19 | def CalculateStyleCode(row): 20 | descTerm = row[3] 21 | descGroup = row[4] 22 | make = row[5] 23 | physicalPres = row[6] 24 | returnVal = 99 25 | 26 | if descTerm is None: 27 | descTerm = "" 28 | 29 | if descGroup is None: 30 | descGroup = "" 31 | 32 | if (descTerm == "Polygon Closing Link"): 33 | returnVal = 1 34 | elif (descTerm == "Inferred Property Closing Link"): 35 | returnVal = 2 36 | elif (descTerm == "Bottom Of Slope"): 37 | returnVal = 3 38 | elif (descTerm == "Top Of Slope"): 39 | returnVal = 4 40 | elif (descTerm == "Step"): 41 | returnVal = 5 42 | elif (descTerm is not None and descTerm.find("Mean High Water (Springs)") > -1): 43 | returnVal = 6 44 | elif (descTerm == "Traffic Calming"): 45 | returnVal = 7 46 | elif (descTerm == "Standard Gauge Track"): 47 | returnVal = 8 48 | elif (descTerm == "Bottom Of Cliff"): 49 | returnVal = 9 50 | elif (descTerm == "Top Of Cliff"): 51 | returnVal = 10 52 | elif (descTerm == "Mean Low Water (Springs)"): 53 | returnVal = 11 54 | elif (descTerm == "Unmade Path Alignment"): 55 | returnVal = 12 56 | elif (descTerm is not None and descTerm.find("Overhead Construction") > -1): 57 | returnVal = 13 58 | elif (descTerm == "Culvert"): 59 | returnVal = 14 60 | elif (descTerm == "Pylon"): 61 | returnVal = 15 62 | elif (descTerm == "Ridge Or Rock Line"): 63 | returnVal = 16 64 | elif (descTerm == "Narrow Gauge"): 65 | returnVal = 17 66 | elif (descTerm == "Buffer"): 67 | returnVal = 18 68 | elif (descTerm == "Tunnel Edge"): 69 | returnVal = 19 70 | elif (descTerm is not None and descTerm.find("Line Of Posts") > -1): 71 | returnVal = 20 72 | elif (descTerm == "Drain"): 73 | returnVal = 21 74 | elif (descTerm == "Normal Tidal Limit"): 75 | returnVal = 22 76 | 77 | 78 | # Descriptive group rules 79 | elif (descGroup is not None and descGroup.find("General Feature") > -1 and physicalPres != "Edge / Limit"): 80 | returnVal = 23 81 | elif (descGroup is not None and descGroup.find("Building") > -1 and descTerm == "Outline" and physicalPres == "Obstructing"): 82 | returnVal = 24 83 | elif (descGroup is not None and descGroup.find("General Feature") > -1 and physicalPres == "Edge / Limit"): 84 | returnVal = 25 85 | elif (descGroup == "Road Or Track"): 86 | returnVal = 26 87 | elif (descGroup is not None and descGroup.find("Building") > -1 and descTerm == "Division" and physicalPres == "Obstructing"): 88 | returnVal = 27 89 | elif (descGroup == "Inland Water"): 90 | returnVal = 28 91 | elif (descGroup is not None and descGroup.find("General Surface") > -1 and make == "Natural"): 92 | returnVal = 29 93 | elif (descGroup is not None and descGroup.find("Building") > -1 and descTerm == "Outline" and physicalPres == "Overhead"): 94 | returnVal = 30 95 | elif (descGroup == "Landform" and make == "Natural"): 96 | returnVal = 31 97 | elif (descGroup == "Historic Interest"): 98 | returnVal = 32 99 | elif (descGroup == "Landform" and make == "Manmade"): 100 | returnVal = 33 101 | else: 102 | returnVal = 99 103 | 104 | logger.debug("Style Code:"+ str(returnVal)) 105 | 106 | return returnVal 107 | #------------------------------------------------------------------------------- 108 | 109 | 110 | #------------------------------------------------------------------------------- 111 | # Calculates the style description value 112 | def CalculateStyleDescription(row): 113 | descTerm = row[3] 114 | descGroup = row[4] 115 | make = row[5] 116 | physicalPres = row[6] 117 | returnVal = "Unclassified" 118 | 119 | if descTerm is None: 120 | descTerm = "" 121 | 122 | if descGroup is None: 123 | descGroup = "" 124 | 125 | if (descTerm == "Polygon Closing Link"): 126 | returnVal = "Polygon Closing Line" 127 | elif (descTerm == "Inferred Property Closing Link"): 128 | returnVal = "Property Closing Line" 129 | elif (descTerm == "Bottom Of Slope"): 130 | returnVal = "Bottom Of Slope Line" 131 | elif (descTerm == "Top Of Slope"): 132 | returnVal = "Top Of Slope Line" 133 | elif (descTerm == "Step"): 134 | returnVal = "Step Line" 135 | elif (descTerm is not None and descTerm.find("Mean High Water (Springs)") > -1): 136 | returnVal = "Mean High Water Line" 137 | elif (descTerm == "Traffic Calming"): 138 | returnVal = "Traffic Calming Line" 139 | elif (descTerm == "Standard Gauge Track"): 140 | returnVal = "Standard Gauge Track Line" 141 | elif (descTerm == "Bottom Of Cliff"): 142 | returnVal = "Bottom Of Cliff Line" 143 | elif (descTerm == "Top Of Cliff"): 144 | returnVal = "Top Of Cliff Line" 145 | elif (descTerm == "Mean Low Water (Springs)"): 146 | returnVal = "Mean Low Water Line" 147 | elif (descTerm == "Unmade Path Alignment"): 148 | returnVal = "Path Line" 149 | elif (descTerm is not None and descTerm.find("Overhead Construction") > -1): 150 | returnVal = "Overhead Construction Line" 151 | elif (descTerm == "Culvert"): 152 | returnVal = "Culvert Line" 153 | elif (descTerm == "Pylon"): 154 | returnVal = "Pylon Line" 155 | elif (descTerm == "Ridge Or Rock Line"): 156 | returnVal = "Ridge Or Rock Line" 157 | elif (descTerm == "Narrow Gauge"): 158 | returnVal = "Narrow Gauge Line" 159 | elif (descTerm == "Buffer"): 160 | returnVal = "Railway Buffer Line" 161 | elif (descTerm == "Tunnel Edge"): 162 | returnVal = "Tunnel Edge Line" 163 | elif (descTerm is not None and descTerm.find("Line Of Posts") > -1): 164 | returnVal = "Line Of Posts Line" 165 | elif (descTerm == "Drain"): 166 | returnVal = "Drain Line" 167 | elif (descTerm == "Normal Tidal Limit"): 168 | returnVal = "Normal Tidal Limit Line" 169 | # Descriptive group rules 170 | elif (descGroup is not None and descGroup.find("General Feature") > -1 and physicalPres != "Edge / Limit"): 171 | returnVal = "Default Line" 172 | elif (descGroup is not None and descGroup.find("Building") > -1 and descTerm == "Outline" and physicalPres == "Obstructing"): 173 | returnVal = "Building Outline Line" 174 | elif (descGroup is not None and descGroup.find("General Feature") > -1 and physicalPres == "Edge / Limit"): 175 | returnVal = "Edge Line" 176 | elif (descGroup == "Road Or Track"): 177 | returnVal = "Road Or Track Line" 178 | elif (descGroup is not None and descGroup.find("Building") > -1 and descTerm == "Division" and physicalPres == "Obstructing"): 179 | returnVal = "Building Division Line" 180 | elif (descGroup == "Inland Water"): 181 | returnVal = "Inland Water Line" 182 | elif (descGroup is not None and descGroup.find("General Surface") > -1 and make == "Natural"): 183 | returnVal = "General Surface Natural Line" 184 | elif (descGroup is not None and descGroup.find("Building") > -1 and descTerm == "Outline" and physicalPres == "Overhead"): 185 | returnVal = "Building Overhead Line" 186 | elif (descGroup == "Landform" and make == "Natural"): 187 | returnVal = "Landform Natural Line" 188 | elif (descGroup == "Historic Interest"): 189 | returnVal = "Historic Interest Line" 190 | elif (descGroup == "Landform" and make == "Manmade"): 191 | returnVal = "Landform Manmade Line" 192 | else: 193 | returnVal = "Unclassified" 194 | 195 | logger.debug("Style Description:"+ returnVal) 196 | 197 | return returnVal; 198 | #------------------------------------------------------------------------------- 199 | 200 | 201 | 202 | 203 | 204 | -------------------------------------------------------------------------------- /python/osmm_topo_style/pnt_style.py: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | # Name: Point Style 3 | # Purpose: 4 | # 5 | # Author: sbatterby 6 | # 7 | # Created: 09/02/2016 8 | # Copyright: (c) sbatterby 2016 9 | # Licence: 10 | #------------------------------------------------------------------------------- 11 | 12 | import arcpy 13 | import os 14 | import logging 15 | 16 | logger = logging.getLogger("style_debug") 17 | 18 | 19 | 20 | #------------------------------------------------------------------------------- 21 | # Calculates the style code value 22 | def CalculateStyleCode(row): 23 | descGroup = row[3] 24 | descTerm = row[4] 25 | returnVal = 99 26 | 27 | if descTerm is None: 28 | descTerm = "" 29 | 30 | if descGroup is None: 31 | descGroup = "" 32 | 33 | if (descTerm == "Spot Height"): 34 | returnVal = 1 35 | elif (descTerm == "Emergency Telephone"): 36 | returnVal = 2 37 | elif (descTerm.find("Site Of Heritage") > -1): 38 | returnVal = 3 39 | elif (descTerm.find("Culvert") > -1): 40 | returnVal = 4 41 | elif (descTerm == "Positioned Nonconiferous Tree"): 42 | returnVal = 5 43 | elif (descGroup.find("Inland Water") > -1): 44 | returnVal = 6 45 | elif (descGroup.find("Roadside") > -1): 46 | returnVal = 7 47 | elif (descTerm.find("Overhead Construction") > -1): 48 | returnVal = 8 49 | elif (descGroup.find("Rail") > -1): 50 | returnVal = 9 51 | elif (descTerm == "Positioned Coniferous Tree"): 52 | returnVal = 10 53 | elif (descTerm == "Boundary Post Or Stone"): 54 | returnVal = 11 55 | elif (descTerm == "Triangulation Point Or Pillar"): 56 | returnVal = 12 57 | elif (descGroup == "Historic Interest"): 58 | returnVal = 13 59 | elif (descGroup == "Landform" or descTerm == "Positioned Boulder"): 60 | returnVal = 14 61 | elif (descGroup.find("Tidal Water") > -1): 62 | returnVal = 15 63 | elif (descGroup.find("Structure") > -1): 64 | returnVal = 16 65 | else: 66 | returnVal = 99 67 | 68 | logger.debug("Style Code:"+ str(returnVal)) 69 | 70 | return returnVal 71 | #------------------------------------------------------------------------------- 72 | 73 | 74 | #------------------------------------------------------------------------------- 75 | # Calculates the style description value 76 | def CalculateStyleDescription(row): 77 | descGroup = row[3] 78 | descTerm = row[4] 79 | returnVal = "Unclassified" 80 | 81 | if descTerm is None: 82 | descTerm = "" 83 | 84 | if descGroup is None: 85 | descGroup = "" 86 | 87 | if (descTerm == "Spot Height"): 88 | returnVal = "Spot Height Point" 89 | elif (descTerm == "Emergency Telephone"): 90 | returnVal = "Emergency Telephone Point" 91 | elif (descTerm.find("Site Of Heritage") > -1): 92 | returnVal = "Site Of Heritage Point" 93 | elif (descTerm.find("Culvert") > -1): 94 | returnVal = "Culvert Point" 95 | elif (descTerm == "Positioned Nonconiferous Tree"): 96 | returnVal = "Positioned Nonconiferous Tree Point" 97 | elif (descGroup.find("Inland Water") > -1): 98 | returnVal = "Inland Water Point" 99 | elif (descGroup.find("Roadside") > -1): 100 | returnVal = "Roadside Point" 101 | elif (descTerm.find("Overhead Construction") > -1): 102 | returnVal = "Overhead Construction Point" 103 | elif (descGroup.find("Rail") > -1): 104 | returnVal = "Rail Point" 105 | elif (descTerm == "Positioned Coniferous Tree"): 106 | returnVal = "Positioned Coniferous Tree Point" 107 | elif (descTerm == "Boundary Post Or Stone"): 108 | returnVal = "Boundary Post Point" 109 | elif (descTerm == "Triangulation Point Or Pillar"): 110 | returnVal = "Triangulation Point Or Pillar Point" 111 | elif (descGroup == "Historic Interest"): 112 | returnVal = "Historic Point" 113 | elif (descGroup == "Landform" or descTerm == "Positioned Boulder"): 114 | returnVal = "Landform Point" 115 | elif (descGroup.find("Tidal Water") > -1): 116 | returnVal = "Tidal Water Point" 117 | elif (descGroup.find("Structure") > -1): 118 | returnVal = "Structure Point" 119 | else: 120 | returnVal = "Unclassified" 121 | 122 | 123 | logger.debug("Style Description:"+ returnVal) 124 | 125 | return returnVal; 126 | #------------------------------------------------------------------------------- 127 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /python/osmm_topo_style/sym_style.py: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | # Name: Cartographic symbol style 3 | # Purpose: 4 | # 5 | # Author: sbatterby 6 | # 7 | # Created: 08/02/2016 8 | # Copyright: (c) sbatterby 2016 9 | #------------------------------------------------------------------------------- 10 | 11 | import arcpy 12 | import os 13 | import logging 14 | 15 | logger = logging.getLogger("style_debug") 16 | 17 | 18 | #------------------------------------------------------------------------------- 19 | # Calculates the style code value 20 | def CalculateStyleCode(row): 21 | featureCode = row[3] 22 | returnVal = 99 23 | 24 | if (featureCode == 10091): 25 | returnVal = 1 26 | elif (featureCode == 10082): 27 | returnVal = 2 28 | elif (featureCode == 10130): 29 | returnVal = 3 30 | elif (featureCode == 10066 or featureCode == 10170): 31 | returnVal = 4 32 | elif (featureCode == 10165): 33 | returnVal = 5 34 | elif (featureCode == 10177): 35 | returnVal = 6 36 | else: 37 | returnVal = 99 38 | 39 | logger.debug("Style Code:"+ str(returnVal)) 40 | 41 | return returnVal 42 | #------------------------------------------------------------------------------- 43 | 44 | 45 | #------------------------------------------------------------------------------- 46 | # Calculates the style description value 47 | def CalculateStyleDescription(row): 48 | featureCode = row[3] 49 | returnVal = "Unclassified" 50 | 51 | 52 | if (featureCode == 10091): 53 | returnVal = "Culvert Symbol" 54 | elif (featureCode == 10082): 55 | returnVal = "Direction Of Flow Symbol" 56 | elif (featureCode == 10130): 57 | returnVal = "Boundary Half Mereing Symbol" 58 | elif (featureCode == 10066 or featureCode == 10170): 59 | returnVal = "Bench Mark Symbol" 60 | elif (featureCode == 10165): 61 | returnVal = "Railway Switch Symbol" 62 | elif (featureCode == 10177): 63 | returnVal = "Road Related Flow Symbol" 64 | else: 65 | returnVal = "Unclassified" 66 | 67 | 68 | logger.debug("Style Description:"+ returnVal) 69 | 70 | return returnVal; 71 | #------------------------------------------------------------------------------- -------------------------------------------------------------------------------- /python/prep_policekml.py: -------------------------------------------------------------------------------- 1 | # Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 2 | # Licensed under [MIT License](https://git.io/fAxH0). 3 | 4 | """ 5 | prep_kml class used to manipulate police.uk KML data, used with prepgml4ogr.py 6 | """ 7 | import os 8 | from lxml import etree 9 | 10 | 11 | class prep_kml(): 12 | 13 | def __init__(self, inputfile): 14 | self.inputfile = inputfile 15 | self.infile = os.path.basename(inputfile) 16 | self.feat_types = ['Placemark'] 17 | 18 | def get_feat_types(self): 19 | return self.feat_types 20 | 21 | def prepare_feature(self, feat_str): 22 | 23 | # Parse the xml string into something useful 24 | feat_elm = etree.fromstring(feat_str) 25 | feat_elm = self._prepare_feat_elm(feat_elm) 26 | 27 | return etree.tostring(feat_elm, encoding='UTF-8', pretty_print=True).decode('utf_8') 28 | 29 | def _prepare_feat_elm(self, feat_elm): 30 | 31 | feat_elm = self._add_filename_elm(feat_elm) 32 | 33 | return feat_elm 34 | 35 | def _add_filename_elm(self, feat_elm): 36 | 37 | elm = etree.SubElement(feat_elm, "name") 38 | elm.text = self.infile[:-4] 39 | 40 | elm = etree.SubElement(feat_elm, "description") 41 | elm.text = os.path.dirname(self.inputfile).split('/')[-1] 42 | 43 | return feat_elm 44 | -------------------------------------------------------------------------------- /python/prepgml4ogr.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Loader. Copyright (c) Astun Technology Ltd. (http://astuntechnology.com). 3 | # Licensed under [MIT License](https://git.io/fAxH0). 4 | 5 | ''' SAX parser implementation to prepare an Ordnance Survey 6 | GML file (.gml or .gz) so that it is ready to be loaded by OGR 1.9 7 | or above. 8 | The parser promotes the fid attribute to a child element. 9 | Output is via stdout and is UTF-8 encoded. 10 | 11 | usage: python prepgml4ogr.py file.gml 12 | ''' 13 | 14 | import sys 15 | import os.path 16 | import gzip 17 | import zipfile 18 | from xml.sax import make_parser 19 | from xml.sax.handler import ContentHandler 20 | from xml.sax import saxutils 21 | 22 | 23 | class gmlhandler(ContentHandler): 24 | 25 | def __init__(self, preparer): 26 | # The class that will prepare the features 27 | self.preparer = preparer 28 | # Flag to indicate if we have encountered the first element yet 29 | self.first_elm = True 30 | self.feat = None 31 | self.recording = False 32 | 33 | def startElement(self, name, attrs): 34 | if self.first_elm: 35 | # Output the xml declaration prior to the first element, 36 | # done here instead of in startDocument to allow us to avoid 37 | # outputting the declaration when we try and parse non XML content 38 | # as can happen when we parse all files in a zip archive 39 | self.first_elm = False 40 | output('') 41 | try: 42 | name = name.split(':')[1] 43 | except IndexError: 44 | pass 45 | # Determine if we are interested 46 | # in starting to record the raw 47 | # XML string so we can prepare 48 | # the feature when the feature ends 49 | if name in self.preparer.feat_types: 50 | self.buffer = [] 51 | self.recording = True 52 | # Process the attributes 53 | tmp = '<' + name 54 | for (name, value) in attrs.items(): 55 | try: 56 | name = name.split(':')[1] 57 | except IndexError: 58 | pass 59 | tmp += ' %s=%s' % (name, saxutils.quoteattr(value)) 60 | tmp += '>' 61 | if self.recording: 62 | self.buffer.append(tmp) 63 | else: 64 | output(tmp) 65 | return 66 | 67 | def characters(self, ch): 68 | if len(ch.strip()) > 0: 69 | if self.recording: 70 | self.buffer.append(saxutils.escape(ch)) 71 | else: 72 | output(saxutils.escape(ch)) 73 | 74 | def endElement(self, name): 75 | try: 76 | name = name.split(':')[1] 77 | except IndexError: 78 | pass 79 | if self.recording: 80 | self.buffer.append('') 81 | else: 82 | output('') 83 | if name in self.preparer.feat_types: 84 | self.recording = False 85 | output(self.preparer.prepare_feature(''.join(self.buffer))) 86 | self.buffer = [] 87 | 88 | 89 | def output(str): 90 | try: 91 | sys.stdout.write(str.encode('utf_8', 'xmlcharrefreplace').decode('utf_8')) 92 | except UnicodeEncodeError: 93 | sys.stdout.write(str.encode('utf_8', 'xmlcharrefreplace')) 94 | 95 | 96 | class prep_gml(): 97 | 98 | def __init__(self, inputfile): 99 | self.feat_types = [] 100 | 101 | def get_feat_types(self): 102 | return self.feat_types 103 | 104 | def prepare_feature(self, feat_str): 105 | return feat_str 106 | 107 | 108 | def main(): 109 | if len(sys.argv) < 2: 110 | print('usage: python prepgml4ogr.py file [[prep_module.]prep_class]') 111 | sys.exit(1) 112 | 113 | inputfile = sys.argv[1] 114 | if os.path.exists(inputfile): 115 | 116 | # Create an instance of a preparer 117 | # class which is used to prepare 118 | # features as they are read 119 | prep_class = 'prep_gml' 120 | try: 121 | prep_class = sys.argv[2] 122 | except IndexError: 123 | pass 124 | prep_class = get_preparer(prep_class) 125 | preparer = prep_class(inputfile) 126 | 127 | parser = make_parser() 128 | parser.setContentHandler(gmlhandler(preparer)) 129 | 130 | if os.path.splitext(inputfile)[1].lower() == '.zip': 131 | archive = zipfile.ZipFile(inputfile, 'r') 132 | for filename in archive.namelist(): 133 | file = archive.open(filename) 134 | try: 135 | parser.parse(file) 136 | except: 137 | # Ignore any files that can't be parsed 138 | pass 139 | else: 140 | if os.path.splitext(inputfile)[1].lower() == '.gz': 141 | file = gzip.open(inputfile, 'r') 142 | else: 143 | # Assume non compressed gml, xml or no extension 144 | file = open(inputfile, 'r') 145 | parser.parse(file) 146 | 147 | else: 148 | print('Could not find input file: ' + inputfile) 149 | 150 | 151 | def get_preparer(prep_class): 152 | parts = prep_class.split('.') 153 | if len(parts) > 1: 154 | prep_module = parts[0] 155 | prep_module = __import__(prep_module) 156 | prep_class = getattr(prep_module, parts[1]) 157 | else: 158 | prep_class = globals()[prep_class] 159 | return prep_class 160 | 161 | if __name__ == '__main__': 162 | main() 163 | -------------------------------------------------------------------------------- /python/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | 3 | setup(name='Loader', 4 | version='1.3.0', 5 | description='A loader for geographic data in GML', 6 | url='https://github.com/AstunTechnology/Loader', 7 | author='Matt Walker', 8 | author_email='mattwalker@astuntechnology.com', 9 | license='MIT', 10 | packages=find_packages(), 11 | long_description='A loader for geographic data in GML that needs some preparation before loading via ogr2ogr.', 12 | long_description_content_type="text/plain", 13 | python_requires='>=3.6', 14 | install_requires=['lxml'], 15 | zip_safe=False) 16 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # A loader for geographic data in GML and KML # 2 | (that needs some preparation before loading via ogr2ogr) 3 | 4 | Author: Astun Technology Ltd. 5 | 6 | Contact: support [at] astuntechnology.com 7 | 8 | A GML and KML loader written in Python that makes use of [OGR 1.9](http://www.gdal.org/ogr/). Source data can be in GML or KML format (including compressed files in GZ or ZIP format) and can be output to any of the [formats supported by OGR](http://www.gdal.org/ogr/ogr_formats.html). The source data can be prepared using a simple Python to both make it suitable for loading with OGR (useful with complex feature types) or to add value by deriving attributes. 9 | 10 | The loader was originally written to load Ordnance Survey OS MasterMap Topographic Layer data in GML/GZ format but has since been used to load other GML and KML data. 11 | 12 | ## Dependencies ## 13 | 14 | * OGR 1.9 15 | * OGR is part of the [GDAL](http://www.gdal.org/ogr/) suite of tools for translating and manipulation geospatial data. 16 | 17 | * Python 2.6+ or 3 18 | * Python 2.6 or above (including 3) is required. Most modern *Linux* operating systems will already have 2.6 or above. 19 | * Python lxml module for parsing and manipulating XML 20 | 21 | __Installation details are available on the [project wiki](https://github.com/AstunTechnology/Loader/wiki)__ 22 | 23 | ## Usage ## 24 | 25 | First configure Loader by editing `loader.config` specifying: 26 | 27 | ## Changes 28 | 29 | See [CHANGELOG.md](./CHANGELOG.md). 30 | 31 | ### Basic configuration ### 32 | 33 | * `src_dir` 34 | * The directory containing your source files or an individual file. All supported files in the specified directory and it's descendants will be loaded. 35 | * `out_dir` 36 | * The directory used to store the translated data if writing to a file based format such as ESRI Shape, MapInfo TAB etc. 37 | * `tmp_dir` 38 | * The directory used to store temporary working files during loading. 39 | * `ogr_cmd` 40 | * The ogr2ogr command that will be used to load the data. Here you can specify the destination format and any associated settings (for example database connection details if you are writing to PostGIS). 41 | * `prep_cmd` 42 | * The command used to prepare the source data so it is suitable for loading with OGR, choose one that is suitable for your source data such as prep_osgml.prep_osmm_topo for OS MasterMap Topo. 43 | * `post_cmd` 44 | * An optional command to be run once OGR has created it's output. Called once per file, useful for loading SQL dump files etc. 45 | * `gfs_file` 46 | * OGR .gfs file used to define the feature attributes and geometry type of the features read from the GML again choose a suitable gfs file for your source data such as ../gfs/osmm_topo_postgres.gfs for loading OS MasterMap Topo into PostgreSQL. 47 | 48 | See `python/loader.config` for further explanation and details of available tokens. Environment variables can be used with any of the options by using a token of the form: `$HOME`, `${HOME}` or `%TEMP%` (Windows only) 49 | 50 | Then run from the command-line: 51 | 52 | python loader.py loader.config 53 | 54 | Additional arguments can be passed to override the values in the config file (useful when running more than one instance of the loader) for example to specify a different source directory (`src_dir`): 55 | 56 | python loader.py loader.config src_dir=./data/tq 57 | 58 | __Some configuration examples are available on the [project wiki](https://github.com/AstunTechnology/Loader/wiki)__ 59 | 60 | ## To-do ## 61 | 62 | * Data 63 | 64 | * OS OSMM Water Network Layer 65 | * Improve support for elements that require an external code list by fetching the code list when it's available 66 | * Support for nil attributes such as: ``, `, `` 67 | * Add example to wiki 68 | 69 | * OS MasterMap ITN 70 | * Add `roadpartiallinkinformation,` `roadpartialrouteinformation` feature types 71 | 72 | * Core `loader.py` 73 | * Specify gfs file via command-line using `GML_GFS_TEMPLATE path_to_template.gfs` 74 | * Add exception and message when source data is not found 75 | * Identify errors with subprocess calls and raise 76 | * Use standard logging instead of print 77 | * Parallel processing, either: 78 | * Run `loader.py` instances in parallel one per core each processing a single input file 79 | * A single `loader.py` process which spawns one process per feature type 80 | * Would allow using `--config GML_READ_MODE SEQUENTIAL_LAYERS` as each `ogr2ogr` instance would only be loading a single feature type 81 | * When loading PostgreSQL features could potentially be piped: `prepgml4ogr | ogr2ogr | psql` 82 | 83 | * Potential improvements due to changes in OGR 84 | * Use `--config GML_GFS_TEMPLATE path/to/file.gfs` to specify template instead of copying template file for each source file (requires GDAL 1.9.0) 85 | * Use `--config GML_READ_MODE SEQUENTIAL_LAYERS` with GML files that include multiple feature types that appear sequentially to avoid the GML being scanned multiple times (requires GDAL 1.9.0) 86 | * Make use of ability to use GML attributes as feature attributes using the element@attribute syntax in the GFS file (and remove relevant prep logic that creates an element to hold the attribute values) (requires GDAL 1.11.0) 87 | * Use `/vsigzip/` to read gz directly 88 | 89 | ## Authors 90 | 91 | See [AUTHORS.md](./AUTHORS.md). 92 | 93 | ## License 94 | 95 | MIT, Copyright (c) 2017 Astun Technology Ltd. (http://astuntechnology.com). See [LICENSE.txt](./LICENSE.txt) for full terms. 96 | 97 | The logic to apply `style_code` and `style_description` values to OSMM Topography Layer data is derived from the ESRI UK [OSMM-Styling](https://github.com/EsriUK/OSMM-Styling) project licensed under Apache-2.0. 98 | --------------------------------------------------------------------------------