From: Richard Fairhurst Date: Sat, 1 Dec 2007 10:32:35 +0000 (+0000) Subject: move preset tags and colours into config files X-Git-Tag: live~8015 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/0ab2db397981e45b5d75f2c65fcc448c958e2f06?hp=8225f0a6ea7cb1fd7007b8503fba7571e2b0d9fb move preset tags and colours into config files --- diff --git a/app/controllers/amf_controller.rb b/app/controllers/amf_controller.rb index 6aa64f6a7..e39a4ceb2 100644 --- a/app/controllers/amf_controller.rb +++ b/app/controllers/amf_controller.rb @@ -90,121 +90,17 @@ class AmfController < ApplicationController # return presets,presetmenus and presetnames arrays def getpresets + RAILS_DEFAULT_LOGGER.info(" Message: getpresets") + + # Read preset menus presets={} presetmenus={}; presetmenus['point']=[]; presetmenus['way']=[]; presetmenus['POI']=[] presetnames={}; presetnames['point']={}; presetnames['way']={}; presetnames['POI']={} presettype='' presetcategory='' - RAILS_DEFAULT_LOGGER.info(" Message: getpresets") - - # File.open("config/potlatch/presets.txt") do |file| - - # Temporary patch to get around filepath problem - # To remove this patch and make the code nice again: - # 1. uncomment above line - # 2. fix the path in the above line - # 3. delete this here document, and the following line (StringIO....) - - txt=<<-EOF -way/road -motorway: highway=motorway,ref=(type road number) -trunk road: highway=trunk,ref=(type road number),name=(type road name) -primary road: highway=primary,ref=(type road number),name=(type road name) -secondary road: highway=secondary,ref=(type road number),name=(type road name) -tertiary road: highway=tertiary,ref=,name=(type road name) -residential road: highway=residential,ref=,name=(type road name) -unclassified road: highway=unclassified,ref=,name=(type road name) - -way/footway -footpath: highway=footway,foot=yes -bridleway: highway=bridleway,foot=yes -byway: highway=unsurfaced,foot=yes -permissive path: highway=footway,foot=permissive - -way/cycleway -cycle lane: highway=cycleway,cycleway=lane,ncn_ref= -cycle track: highway=cycleway,cycleway=track,ncn_ref= -cycle lane (NCN): highway=cycleway,cycleway=lane,name=(type name here),ncn_ref=(type route number) -cycle track (NCN): highway=cycleway,cycleway=track,name=(type name here),ncn_ref=(type route number) - -way/waterway -canal: waterway=canal,name=(type name here) -navigable river: waterway=river,boat=yes,name=(type name here) -navigable drain: waterway=drain,boat=yes,name=(type name here) -derelict canal: waterway=derelict_canal,name=(type name here) -unnavigable river: waterway=river,boat=no,name=(type name here) -unnavigable drain: waterway=drain,boat=no,name=(type name here) -stream: waterway=stream,boat=no,name=(type name here) - -way/railway -railway: railway=rail -tramway: railway=tram -light railway: railway=light_rail -preserved railway: railway=preserved -disused railway tracks: railway=disused -course of old railway: railway=abandoned - -way/natural -lake: natural=water,landuse= -forest: landuse=forest,natural= - -point/road -mini roundabout: highway=mini_roundabout -traffic lights: highway=traffic_signals - -point/footway -bridge: highway=bridge -gate: highway=gate -stile: highway=stile -cattle grid: highway=cattle_grid - -point/cycleway -gate: highway=gate - -point/waterway -lock gate: waterway=lock_gate -weir: waterway=weir -aqueduct: waterway=aqueduct -winding hole: waterway=turning_point -mooring: waterway=mooring - -point/railway -station: railway=station -viaduct: railway=viaduct -level crossing: railway=crossing - -point/natural -peak: natural=peak - -POI/road -car park: amenity=parking -petrol station: amenity=fuel - -POI/cycleway -bike park: amenity=bicycle_parking - -POI/place -city: place=city,name=(type name here),is_in=(type region or county) -town: place=town,name=(type name here),is_in=(type region or county) -suburb: place=suburb,name=(type name here),is_in=(type region or county) -village: place=village,name=(type name here),is_in=(type region or county) -hamlet: place=hamlet,name=(type name here),is_in=(type region or county) - -POI/tourism -attraction: tourism=attraction,amenity=,religion=,denomination= -church: tourism=,amenity=place_of_worship,name=(type name here),religion=christian,denomination=(type denomination here) -hotel: tourism=hotel,amenity=,religion=,denomination= -other religious: tourism=,amenity=place_of_worship,name=(type name here),religion=(type religion),denomination= -post box: amenity=post_box,tourism=,name=,religion=,denomination= -post office: amenity=post_office,tourism=,name=,religion=,denomination= -pub: tourism=,amenity=pub,name=(type name here),religion=,denomination= - -POI/natural -peak: natural=peak -EOF - - StringIO.open(txt) do |file| +# StringIO.open(txt) do |file| + File.open("#{RAILS_ROOT}/config/potlatch/presets.txt") do |file| file.each_line {|line| t=line.chomp if (t=~/(\w+)\/(\w+)/) then @@ -222,7 +118,21 @@ EOF end } end - [presets,presetmenus,presetnames] + + # Read colours/styling + colours={}; casing={}; areas={} + File.open("#{RAILS_ROOT}/config/potlatch/colours.txt") do |file| + file.each_line {|line| + t=line.chomp + if (t=~/(\w+)\t+([^\t]+)\t+([^\t]+)\t+([^\t]+)/) then + tag=$1 + if ($2!='-') then colours[tag]=$2.hex end + if ($3!='-') then casing[tag]=$3.hex end + if ($4!='-') then areas[tag]=$4.hex end + end + } + end + [presets,presetmenus,presetnames,colours,casing,areas] end # ----- whichways(left,bottom,right,top) diff --git a/config/potlatch/colours.txt b/config/potlatch/colours.txt new file mode 100644 index 000000000..c54247cb1 --- /dev/null +++ b/config/potlatch/colours.txt @@ -0,0 +1,31 @@ +# Potlatch colours file +# each line must be tab-separated: tag, stroke colour, casing?, fill colour +# ** TODO: act on key=value, not just one or the other + +motorway 0x809BC0 1 - +motorway_link 0x809BC0 1 - +trunk 0x7FC97F 1 - +trunk_link 0x7FC97F 1 - +primary 0xE46D71 1 - +primary_link 0xE46D71 1 - +secondary 0xFDBF6F 1 - +tertiary 0xFEFECB 1 - +unclassified 0xE8E8E8 1 - +residential 0xE8E8E8 1 - +footway 0xFF6644 - - +cycleway 0xFF6644 - - +bridleway 0xFF6644 - - +rail 0x000001 - - +river 0x8888FF - - +canal 0x8888FF - - +stream 0x8888FF - - +leisure - - 0x8CD6B5 +amenity - - 0xADCEB5 +shop - - 0xADCEB5 +tourism - - 0xF7CECE +historic - - 0xF7F7DE +ruins - - 0xF7F7DE +landuse - - 0x444444 +military - - 0xD6D6D6 +natural - - 0xADD6A5 +sport - - 0x8CD6B5 diff --git a/config/potlatch/presets.txt b/config/potlatch/presets.txt index 5d696da43..369395253 100644 --- a/config/potlatch/presets.txt +++ b/config/potlatch/presets.txt @@ -3,13 +3,14 @@ motorway: highway=motorway,ref=(type road number) trunk road: highway=trunk,ref=(type road number),name=(type road name) primary road: highway=primary,ref=(type road number),name=(type road name) secondary road: highway=secondary,ref=(type road number),name=(type road name) -residential road: highway=residential,name=(type road name) -unclassified road: highway=unclassified,name=(type road name) +tertiary road: highway=tertiary,ref=,name=(type road name) +residential road: highway=residential,ref=,name=(type road name) +unclassified road: highway=unclassified,ref=,name=(type road name) way/footway footpath: highway=footway,foot=yes -bridleway: highway=bridleway,foot=yes,horse=yes,bicycle=yes -byway: highway=byway,foot=yes,horse=yes,bicycle=yes,motorcar=yes +bridleway: highway=bridleway,foot=yes +byway: highway=unsurfaced,foot=yes permissive path: highway=footway,foot=permissive way/cycleway @@ -25,6 +26,7 @@ navigable drain: waterway=drain,boat=yes,name=(type name here) derelict canal: waterway=derelict_canal,name=(type name here) unnavigable river: waterway=river,boat=no,name=(type name here) unnavigable drain: waterway=drain,boat=no,name=(type name here) +stream: waterway=stream,boat=no,name=(type name here) way/railway railway: railway=rail @@ -34,6 +36,10 @@ preserved railway: railway=preserved disused railway tracks: railway=disused course of old railway: railway=abandoned +way/natural +lake: natural=water,landuse= +forest: landuse=forest,natural= + point/road mini roundabout: highway=mini_roundabout traffic lights: highway=traffic_signals @@ -58,3 +64,32 @@ point/railway station: railway=station viaduct: railway=viaduct level crossing: railway=crossing + +point/natural +peak: natural=peak + +POI/road +car park: amenity=parking +petrol station: amenity=fuel + +POI/cycleway +bike park: amenity=bicycle_parking + +POI/place +city: place=city,name=(type name here),is_in=(type region or county) +town: place=town,name=(type name here),is_in=(type region or county) +suburb: place=suburb,name=(type name here),is_in=(type region or county) +village: place=village,name=(type name here),is_in=(type region or county) +hamlet: place=hamlet,name=(type name here),is_in=(type region or county) + +POI/tourism +attraction: tourism=attraction,amenity=,religion=,denomination= +church: tourism=,amenity=place_of_worship,name=(type name here),religion=christian,denomination=(type denomination here) +hotel: tourism=hotel,amenity=,religion=,denomination= +other religious: tourism=,amenity=place_of_worship,name=(type name here),religion=(type religion),denomination= +post box: amenity=post_box,tourism=,name=,religion=,denomination= +post office: amenity=post_office,tourism=,name=,religion=,denomination= +pub: tourism=,amenity=pub,name=(type name here),religion=,denomination= + +POI/natural +peak: natural=peak diff --git a/public/potlatch/potlatch.swf b/public/potlatch/potlatch.swf index bfbdc2c1d..9bde5d429 100755 Binary files a/public/potlatch/potlatch.swf and b/public/potlatch/potlatch.swf differ