From OpenStreetMap Wiki
Jump to navigation Jump to search

The Dutch government allowed us to grab a copy of the official zone table for public transport. The following code is used to apply this on the dataset.

select osm_id, zonenr from planet_osm_point, ov_zones where railway in ('halt', 'station', 'metro_station', 'station', 'tramstop') and ST_WITHIN(transform(way, 28992), the_geom);

cat /tmp/zones | while read i; do
	NODE=`echo $i | sed "s/[ ]*\([0-9]*\) | .*/\1/g"`
#ZONE=`echo $i | sed "s/.* |[ ]*\([0-9]\+\)/\1/g"`
#echo $NODE $ZONE

Remove any nodes that already have their 'zone' tag.

ls -1 | while read NODE; do
	head -n $(( `wc -l $NODE | sed "s/\([0-9]\+\) .*/\1/g"` - 2 )) $NODE > update/$NODE
	echo "    <tag k=\"zone\" v=\"`grep $NODE /tmp/zones | sed "s/.* |[ ]*\([0-9]\+\)/\1/g"`\"/></node></osm>" >> update/$NODE

Make a changeset:

      <tag k="created_by" v="ZoneImport"/>
      <tag k="comment" v="This commit updates all zone information for The Netherlands and near by town in Germany"/>
      <tag k="uri" v="" />

Upload it:

curl -u "username:password" -i -o /tmp/output.txt -T ./changeset

Grab the changesetid from /tmp/output.txt

cd update
for i in $(find . -type f); do sed 's/changeset=".*" user/changeset="NEWCHANGESETID" user/g' $i > $i-tmp; mv $i-tmp $i; done
ls -1 | while read NODE; do
 curl -u "username:password -i -T ./$NODE$NODE

And finally close it

curl -u "username:password" -i -T ./changeset