X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/a83030dab7512c4b2848e777f7a7dbff456774b3..cdb42d2a6ce539be3f3e50edebb88240dfd16e04:/app/controllers/api_controller.rb diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index f9b48cb1c..d97feace2 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -30,7 +30,9 @@ class ApiController < ApplicationController end # get all the points - points = Tracepoint.bbox(bbox).offset(offset).limit(TRACEPOINTS_PER_PAGE).order("gpx_id DESC, trackid ASC, timestamp ASC") + ordered_points = Tracepoint.bbox(bbox).joins(:trace).where(:gpx_files => { :visibility => %w[trackable identifiable] }).order("gpx_id DESC, trackid ASC, timestamp ASC") + unordered_points = Tracepoint.bbox(bbox).joins(:trace).where(:gpx_files => { :visibility => %w[public private] }).order("gps_points.latitude", "gps_points.longitude", "gps_points.timestamp") + points = ordered_points.union_all(unordered_points).offset(offset).limit(TRACEPOINTS_PER_PAGE) doc = XML::Document.new doc.encoding = XML::Encoding::UTF_8 @@ -67,7 +69,7 @@ class ApiController < ApplicationController if gpx_file.identifiable? track << (XML::Node.new("name") << gpx_file.name) track << (XML::Node.new("desc") << gpx_file.description) - track << (XML::Node.new("url") << url_for(:controller => "trace", :action => "view", :display_name => gpx_file.user.display_name, :id => gpx_file.id)) + track << (XML::Node.new("url") << url_for(:controller => "traces", :action => "show", :display_name => gpx_file.user.display_name, :id => gpx_file.id)) end else # use the anonymous track segment if the user hasn't allowed