Skip to content

Instantly share code, notes, and snippets.

@ashquarky
Last active February 25, 2020 10:35
Show Gist options
  • Save ashquarky/bcaddee7a5d0dae5191a2124960e24ea to your computer and use it in GitHub Desktop.
Save ashquarky/bcaddee7a5d0dae5191a2124960e24ea to your computer and use it in GitHub Desktop.
Osmosis TagTransform file to convert TfNSW Cycleways data into OSM-ready tags
<?xml version="1.0"?>
<!--
Things to note:
- You may or may not want name= and alt_name= from this dataset, as name= has other sources
and standards (St. vs Street); while alt_name seems to be naming sidewalks after the
assosciated road
- name= and alt_name= are *stripped by default*. Scroll down and uncomment the appropriate
lines to output them.
- foot=designated on highway=cycleway is not accompanied by bicycle=designated by default
- SURFACE=Spray Seal and SURFACE=AC are translated as surface=asphalt
- MAINTAINER=Council is deleted, filters included for adapting to your local council of choice
- TfNSW's WIDTH= tags seem a bit strange. I've attempted to automate width= vs. cycleway:width=;
make sure it's reasonable before applying
- DIFFICULTY= is translated as cycleway:difficulty:tfnsw. It's unclear what their criteria is.
For this reason, it's stripped by default, but again, can be enabled if you want.
-->
<translations>
<translation>
<name>Drop unusable TfNSW Cycleways tags</name>
<match mode="or">
<!-- construction details without OSM tagging equivalents -->
<tag k="BASE" v=".*"/>
<tag k="EXPANSION_" v=".*"/>
<tag k="PAVEMENT" v=".*"/>
<tag k="REINFORCEM" v=".*"/>
<tag k="LINEMARKIN" v=".*"/>
<!-- TfNSW internal data -->
<tag k="SHAPE_Leng" v=".*"/>
<tag k="UPDATED_BY" v=".*"/>
<tag k="WBS_PROJEC" v=".*"/>
<!-- Unclear what these are -->
<tag k="INRDRES" v=".*"/>
<tag k="ISDIRECTIO" v=".*"/>
<!-- these aren't really helpful
NOTE "Convert TfNSW Cycleways PLANS= to ref:rms=" will output
useless ref:rms=Yes if this is removed or moved below -->
<tag k="PLANS" v="No"/>
<tag k="PLANS" v="Yes"/>
</match>
<output>
<copy-unmatched/>
</output>
</translation>
<translation>
<name>Convert TfNSW Cycleways NAME= to name=</name>
<match mode="or">
<tag match_id="name" k="NAME" v=".*"/>
</match>
<output>
<copy-unmatched/>
<!-- uncomment this line to enable name= -->
<!-- <tag from_match="name" k="name" v="{0}"/> -->
</output>
</translation>
<translation>
<name>Convert TfNSW Cycleways ALT_NAME= to alt_name=</name>
<match mode="or">
<tag match_id="name" k="ALT_NAME" v=".*"/>
</match>
<output>
<copy-unmatched/>
<!-- uncomment this line to enable alt_name= -->
<!-- <tag from_match="name" k="alt_name" v="{0}"/> -->
</output>
</translation>
<translation>
<name>Special cases for TfNSW Cycleways MAINTAINER= to operator=</name>
<match mode="or">
<tag match_id="council" k="MAINTAINER" v="Council"/>
<tag match_id="rms" k="MAINTAINER" v="RMS"/>
<tag match_id="private" k="MAINTAINER" v="Private"/>
<tag match_id="uni" k="MAINTAINER" v=".*University.*"/>
</match>
<output>
<copy-unmatched/>
<!-- Council filtered out unless the following is uncommented -->
<!-- You could adapt this for the LGA local to where you're mapping -->
<!--<tag from_match="council" k="operator" v="City of Newcastle"/>
<tag from_match="council" k="operator:wikidata" v="Q820325"/>-->
<tag from_match="council" k="operator:type" v="government"/>
<tag from_match="rms" k="operator" v="Roads and Maritime Services"/>
<tag from_match="rms" k="operator:wikidata" v="Q540967"/>
<tag from_match="rms" k="operator:type" v="government"/>
<tag from_match="private" k="operator:type" v="private"/>
<tag from_match="uni" k="operator" v="{0}"/>
<tag from_match="uni" k="operator:type" v="university"/>
</output>
</translation>
<translation>
<name>Convert TfNSW Cycleways MAINTAINER= to operator=</name>
<match mode="or">
<tag match_id="op" k="MAINTAINER" v=".*"/>
</match>
<output>
<copy-unmatched/>
<tag from_match="op" k="operator" v="{0}"/>
</output>
</translation>
<translation>
<name>Convert TfNSW Cycleways DIFFICULTY= to cycleway:difficulty:tfnsw=</name>
<match mode="or">
<tag match_id="high" k="DIFFICULTY" v="High"/>
<tag match_id="med" k="DIFFICULTY" v="Medium"/>
<tag match_id="low" k="DIFFICULTY" v="Low"/>
<tag match_id="unk" k="DIFFICULTY" v="Unknown"/>
</match>
<output>
<copy-unmatched/>
<!-- uncomment the following to enable cycleway:difficulty:tfnsw= tags -->
<!--<tag from_match="high" k="cycleway:difficulty:tfnsw" v="high"/>-->
<!--<tag from_match="med" k="cycleway:difficulty:tfnsw" v="medium"/>-->
<!--<tag from_match="low" k="cycleway:difficulty:tfnsw" v="low"/>-->
</output>
</translation>
<translation>
<name>Convert TfNSW Cycleways off-road CLASS= and WIDTH= tags to OSM</name>
<match mode="or">
<tag match_id="path" k="CLASS" v="2"/>
<tag match_id="shared_path" k="CLASS" v="3"/>
<tag match_id="split_path" k="CLASS" v="4"/>
<tag match_id="unknown" k="CLASS" v="8"/>
<tag match_id="no_bikes" k="CLASS" v="9"/>
</match>
<find>
<tag match_id="width" k="WIDTH" v=".*"/>
</find>
<output>
<copy-unmatched/>
<tag from_match="path" k="highway" v="cycleway"/>
<tag from_match="path" k="foot" v="no"/>
<tag from_match="shared_path" k="highway" v="cycleway"/>
<!--<tag from_match="shared_path" k="bicycle" v="designated"/>-->
<tag from_match="shared_path" k="foot" v="designated"/>
<tag from_match="shared_path" k="segregated" v="no"/>
<tag from_match="split_path" k="highway" v="cycleway"/>
<!--<tag from_match="shared_path" k="bicycle" v="designated"/>-->
<tag from_match="split_path" k="foot" v="designated"/>
<tag from_match="split_path" k="segregated" v="yes"/>
<!-- CLASS=8 (unknown) stripped out in <copy-unmatched/> -->
<tag from_match="no_bikes" k="bicycle" v="no"/>
<!-- off-road WIDTH= tags refer to the width of the whole element -->
<tag from_match="width" k="width" v="{0} m"/>
<tag from_match="width" k="source:width" v="TfNSW Cycleways"/>
</output>
</translation>
<translation>
<name>Convert TfNSW Cycleways on-road CLASS= and WIDTH= tags to OSM</name>
<match mode="or">
<tag match_id="lane" k="CLASS" v="1"/>
<tag match_id="shoulder" k="CLASS" v="5"/>
<tag match_id="fw_shoulder" k="CLASS" v="6"/>
<tag match_id="shared_lane" k="CLASS" v="7"/>
</match>
<find>
<tag match_id="width" k="WIDTH" v=".*"/>
</find>
<output>
<copy-unmatched/>
<tag from_match="lane" k="cycleway" v="lane"/>
<tag from_match="shoulder" k="cycleway" v="shoulder"/>
<tag from_match="fw_shoulder" k="cycleway" v="shoulder"/>
<!-- highway=motorway can imply bicycle=no, see Australian Tagging Guidelines on wiki -->
<tag from_match="fw_shoulder" k="bicycle" v="yes"/>
<tag from_match="shared_lane" k="cycleway" v="shared_lane"/>
<!-- on-road WIDTH= tags *only* refer to the lane or shoulder's width -->
<tag from_match="width" k="cycleway:width" v="{0} m"/>
<tag from_match="width" k="source:cycleway:width" v="TfNSW Cycleways"/>
</output>
</translation>
<translation>
<name>Convert TfNSW Cycleways source dates to source:date=</name>
<match mode="or">
<tag match_id="date" k="OBJECTRELI" v=".*"/>
</match>
<output>
<copy-unmatched/>
<tag from_match="date" k="source:date" v="{0}"/>
<tag k="source" v="TfNSW Cycleways"/>
</output>
</translation>
<translation>
<name>Convert TfNSW Cycleways construction dates to start_date=</name>
<match mode="or">
<tag match_id="date" k="CONST_DATE" v=".*"/>
</match>
<output>
<copy-unmatched/>
<tag from_match="date" k="start_date" v="{0}"/>
</output>
</translation>
<translation>
<name>Convert TfNSW Cycleways OBJECTID= to ref:tfnsw=</name>
<match mode="or">
<tag match_id="ref" k="OBJECTID" v=".*"/>
</match>
<output>
<copy-unmatched/>
<tag from_match="ref" k="ref:tfnsw" v="{0}"/>
</output>
</translation>
<translation>
<name>Convert TfNSW Cycleways PLANS= to ref:rms=</name>
<match mode="and">
<tag match_id="has_plans" k="PLANS" v=".*"/>
</match>
<output>
<copy-unmatched/>
<!-- PLANS=yes and PLANS=no filtered out in previous stage -->
<tag from_match="has_plans" k="ref:rms" v="{0}"/>
</output>
</translation>
<translation>
<name>Convert TfNSW Cycleways LIGHTING= to lit=</name>
<match mode="or">
<tag match_id="lit" k="LIGHTING" v="Y"/>
<tag match_id="unlit" k="LIGHTING" v="N"/>
<tag match_id="unk" k="LIGHTING" v="U"/>
</match>
<output>
<copy-unmatched/>
<tag from_match="lit" k="lit" v="yes"/>
<tag from_match="lit" k="lit" v="no"/>
<!-- LIGHTING=U filtered out by <copy-unmatched/> -->
</output>
</translation>
<translation>
<name>Convert TfNSW Cycleways GRADE= to incline=</name>
<match mode="or">
<tag match_id="up" k="GRADE" v="Steep Up"/>
<tag match_id="down" k="GRADE" v="Steep Down"/>
<tag match_id="no" k="GRADE" v="Not Steep"/>
<tag match_id="unk" k="GRADE" v="Unknown"/>
</match>
<output>
<copy-unmatched/>
<tag from_match="up" k="incline" v="up"/>
<tag from_match="down" k="incline" v="down"/>
<!-- "Not Steep" is different to incline=no -->
</output>
</translation>
<translation>
<name>Convert TfNSW Cycleways SURFACE= to surface=</name>
<match mode="or">
<tag match_id="concrete" k="SURFACE" v="Concrete"/>
<tag match_id="ac" k="SURFACE" v="AC"/>
<tag match_id="spray_seal" k="SURFACE" v="Spray Seal"/>
<tag match_id="block_paving" k="SURFACE" v="Block Paving"/>
<tag match_id="unsealed" k="SURFACE" v="Unsealed"/>
<tag match_id="unknown" k="SURFACE" v="Unknown"/>
<tag match_id="timber" k="SURFACE" v="Timber"/>
<tag match_id="steel" k="SURFACE" v="Steel"/>
<tag match_id="fibreglass" k="SURFACE" v="Fibreglass"/>
</match>
<output>
<copy-unmatched/>
<tag from_match="concrete" k="surface" v="concrete"/>
<tag from_match="ac" k="surface" v="asphalt"/>
<tag from_match="spray_seal" k="surface" v="asphalt"/>
<tag from_match="block_paving" k="surface" v="paving_stones"/>
<tag from_match="unsealed" k="surface" v="unpaved"/>
<!-- SURFACE=Unknown filtered out by <copy-unmatched/> -->
<tag from_match="timber" k="surface" v="wood"/>
<tag from_match="steel" k="surface" v="metal"/>
<tag from_match="fibreglass" k="surface" v="fibreglass"/>
</output>
</translation>
<translation>
<name>Convert TfNSW Cycleways STATUS= to proposed= and construction=</name>
<description>Note the TfNSW data is somewhat old. It may be preferable to filter out everything but STATUS=Existing before this filter runs. STATUS=Unknown is treated as STATUS=Existing.</description>
<match mode="or">
<tag match_id="existing" k="STATUS" v="Existing"/>
<tag match_id="funded" k="STATUS" v="Funded"/>
<tag match_id="proposed" k="STATUS" v="Proposed"/>
<tag match_id="unknown" k="STATUS" v="Unknown"/>
</match>
<output>
<copy-unmatched/>
<!-- STATUS=Existing stripped out in <copy-unmatched/> -->
<tag from_match="funded" k="construction" v="cycleway"/>
<tag from_match="proposed" k="proposed" v="cycleway"/>
<!-- STATUS=Unknown stripped out in <copy-unmatched/> -->
</output>
</translation>
</translations>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment