various gpx bits

This commit is contained in:
Steve Coast 2006-12-01 15:59:13 +00:00
parent ece8999dcd
commit fac305e87b
11 changed files with 154 additions and 17 deletions

View file

@ -40,12 +40,7 @@ class ApiController < ApplicationController
# get missing nodes if there are any
nodes += Node.find(missing_nodes) if missing_nodes.length > 0
doc = XML::Document.new
doc.encoding = 'UTF-8'
root = XML::Node.new 'osm'
root['version'] = API_VERSION
root['generator'] = 'OpenStreetMap server'
doc.root = root
doc = get_xml_doc
# get ways
# find which ways are needed
@ -59,15 +54,15 @@ class ApiController < ApplicationController
end
nodes.each do |node|
root << node.to_xml_node()
doc.root << node.to_xml_node()
end
segments.each do |segment|
root << segment.to_xml_node()
doc.root << segment.to_xml_node()
end
ways.each do |way|
root << way.to_xml_node()
doc.root << way.to_xml_node()
end
render :text => doc.to_s

View file

@ -15,8 +15,6 @@ class TraceController < ApplicationController
File.open(filename, "w") { |f| f.write(@params['trace']['gpx_file'].read) }
@params['trace']['name'] = @params['trace']['gpx_file'].original_filename.gsub(/[^a-zA-Z0-9.]/, '_') # This makes sure filenames are sane
#@params['trace']['data'] = @params['trace']['gpx_file'].read
# @params['trace']['mime_type'] = @params['trace']['gpx_file'].content_type.chomp
@params['trace'].delete('gpx_file') # let's remove the field from the hash, because there's no such field in the DB anyway.
@trace = Trace.new(@params['trace'])
@trace.inserted = false

View file

@ -0,0 +1,2 @@
class TracepointController < ApplicationController
end

View file

@ -0,0 +1,2 @@
module TracepointHelper
end

View file

@ -21,4 +21,18 @@ class Notifier < ActionMailer::Base
@body['pass'] = pass
end
def gpx_success(trace)
@recipients = user.email
@from = 'abuse@openstreetmap.org'
@subject = '[OpenStreetMap] GPX Import success'
@body['trace_name'] = trace.name
@body['trace_points'] = trace.size
end
def gpx_failure(trace)
@recipients = user.email
@from = 'abuse@openstreetmap.org'
@subject = '[OpenStreetMap] GPX Import failure'
@body['trace_name'] = trace.name
end
end

9
app/models/tracepoint.rb Normal file
View file

@ -0,0 +1,9 @@
class Tracepoint < ActiveRecord::Base
set_table_name 'gps_points'
validates_numericality_of :latitude
validates_numericality_of :longitude
belongs_to :user
belongs_to :trace, :foreign_key => 'gpx_id'
end

View file

@ -0,0 +1,7 @@
Hi,
It looks like your GPX file
<%= @trace_name %>
failed to import :-(

View file

@ -0,0 +1,7 @@
Hi,
It looks like your GPX file
<%= @trace_name %>
loaded successfully with <%= @trace_points %> points.