class AmfController < ApplicationController
+#=begin
require 'stringio'
-# to log:
-# RAILS_DEFAULT_LOGGER.error("Args: #{args[0]}, #{args[1]}, #{args[2]}, #{args[3]}")
+ # to log:
+ # RAILS_DEFAULT_LOGGER.error("Args: #{args[0]}, #{args[1]}, #{args[2]}, #{args[3]}")
# ====================================================================
# Main AMF handler
end
+ private
# ====================================================================
# Remote calls
presettype=''
presetcategory=''
- File.open("config/potlatch/presets.txt") do |file|
+# 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)
+residential road: highway=residential,name=(type road name)
+unclassified road: highway=unclassified,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
+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)
+
+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
+
+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
+EOF
+
+StringIO.open(txt) do |file|
file.each_line {|line|
t=line.chomp
if (t=~/(\w+)\/(\w+)/) then
waylist.each {|a|
ways<<a.wayid.to_i
}
- ways
+
+ pointlist=ActiveRecord::Base.connection.select_all("SELECT current_nodes.id,current_nodes.tags "+
+ " FROM current_nodes "+
+ " LEFT OUTER JOIN current_segments cs1 ON cs1.node_a=current_nodes.id "+
+ " LEFT OUTER JOIN current_segments cs2 ON cs2.node_b=current_nodes.id "+
+ " WHERE (latitude BETWEEN "+(args[1].to_f-0.01).to_s+" AND "+(args[3].to_f+0.01).to_s+") "+
+ " AND (longitude BETWEEN "+(args[0].to_f-0.01).to_s+" AND "+(args[2].to_f-0.01).to_s+") "+
+ " AND cs1.id IS NULL AND cs2.id IS NULL "+
+ " AND current_nodes.visible=1")
+ points=[]
+ pointlist.each {|a|
+ points<<[a['id'],tag2array(a['tags'])]
+ }
+ [ways,points]
end
# ----- getway (objectname, way, baselong, basey, masterscale)
def createuniquesegments(way,uqs_name)
sql=<<-EOF
CREATE TEMPORARY TABLE #{uqs_name}
- SELECT a.segment_id,COUNT(a.segment_id) AS ct
- FROM current_way_segments AS a, current_way_segments AS b
- WHERE a.segment_id=b.segment_id
- AND a.id=#{way}
- GROUP BY a.segment_id
- HAVING ct=1
+ SELECT a.segment_id
+ FROM (SELECT DISTINCT segment_id FROM current_way_segments
+ WHERE id = #{way}) a
+ LEFT JOIN current_way_segments b
+ ON b.segment_id = a.segment_id
+ AND b.id != #{way}
+ WHERE b.segment_id IS NULL
EOF
ActiveRecord::Base.connection.execute(sql)
end
b.gsub!('#%',';;;')
b.gsub!('===','#%')
k,v=b.split('=')
+ if k.nil? then k='' end
+ if v.nil? then v='' end
tags[k.gsub('#%','=')]=v.gsub('#%','=')
end
tags
180/Math::PI * (2*Math.atan(Math.exp(a*Math::PI/180))-Math::PI/2)
end
-
+#=end
end