readers/tfl_common.rb
# Snap to the nearest point on the given way
Snap to the nearest point on the given way
Snap to the nearest point on the given way
def snap(lat,lon,way_id)
		sql = <<-SQL
		SELECT ST_X(ST_ClosestPoint(ST_Transform(way,4326),ST_SetSRID(ST_MakePoint($1,$2),4326))) AS lon,
		       ST_Y(ST_ClosestPoint(ST_Transform(way,4326),ST_SetSRID(ST_MakePoint($1,$2),4326))) AS lat,
			   ST_LineLocatePoint(ST_Transform(way,4326),ST_SetSRID(ST_MakePoint($1,$2),4326)) AS prop
	    FROM planet_osm_line WHERE osm_id=$3
		SQL
		res = $conn.exec_params(sql,[lon,lat,way_id])[0]
		[res['lat'].to_f, res['lon'].to_f, res['prop'].to_f]
	end
def snap ( lat , lon , way_id ) sql = <<-SQL 
		SELECT ST_X(ST_ClosestPoint(ST_Transform(way,4326),ST_SetSRID(ST_MakePoint($1,$2),4326))) AS lon,
		       ST_Y(ST_ClosestPoint(ST_Transform(way,4326),ST_SetSRID(ST_MakePoint($1,$2),4326))) AS lat,
			   ST_LineLocatePoint(ST_Transform(way,4326),ST_SetSRID(ST_MakePoint($1,$2),4326)) AS prop
	    FROM planet_osm_line WHERE osm_id=$3
		 SQL res = $conn . exec_params ( sql , [ lon , lat , way_id ] ) [ 0 ] [ res [ 'lat' ] . to_f , res [ 'lon' ] . to_f , res [ 'prop' ] . to_f ] end
Snap to the nearest point on the given way
Snap to the nearest point on the given way
lat
<not_specific>
lon
<not_specific>
way_id
<not_specific>