- def test_tracepoints
- point = create(:trace, :visibility => "public", :latitude => 1, :longitude => 1) do |trace|
- create(:tracepoint, :trace => trace, :latitude => 1 * GeoRecord::SCALE, :longitude => 1 * GeoRecord::SCALE)
- end
- minlon = point.longitude - 0.001
- minlat = point.latitude - 0.001
- maxlon = point.longitude + 0.001
- maxlat = point.latitude + 0.001
- bbox = "#{minlon},#{minlat},#{maxlon},#{maxlat}"
- get :trackpoints, :params => { :bbox => bbox }
- assert_response :success
- assert_select "gpx[version='1.0'][creator='OpenStreetMap.org']", :count => 1 do
- assert_select "trk" do
- assert_select "trkseg"
- end
- end
- end
-
- def test_tracepoints_trackable
- point = create(:trace, :visibility => "trackable", :latitude => 51.51, :longitude => -0.14) do |trace|
- create(:tracepoint, :trace => trace, :trackid => 1, :latitude => (51.510 * GeoRecord::SCALE).to_i, :longitude => (-0.140 * GeoRecord::SCALE).to_i)
- create(:tracepoint, :trace => trace, :trackid => 2, :latitude => (51.511 * GeoRecord::SCALE).to_i, :longitude => (-0.141 * GeoRecord::SCALE).to_i)
- end
- minlon = point.longitude - 0.002
- minlat = point.latitude - 0.002
- maxlon = point.longitude + 0.002
- maxlat = point.latitude + 0.002
- bbox = "#{minlon},#{minlat},#{maxlon},#{maxlat}"
- get :trackpoints, :params => { :bbox => bbox }
- assert_response :success
- assert_select "gpx[version='1.0'][creator='OpenStreetMap.org']", :count => 1 do
- assert_select "trk", :count => 1 do
- assert_select "trk > trkseg", :count => 2 do |trksegs|
- trksegs.each do |trkseg|
- assert_select trkseg, "trkpt", :count => 1 do |trkpt|
- assert_select trkpt[0], "time", :count => 1
- end
- end
- end
- end
- end
- end
-
- def test_tracepoints_identifiable
- point = create(:trace, :visibility => "identifiable", :latitude => 51.512, :longitude => 0.142) do |trace|
- create(:tracepoint, :trace => trace, :latitude => (51.512 * GeoRecord::SCALE).to_i, :longitude => (0.142 * GeoRecord::SCALE).to_i)
- end
- minlon = point.longitude - 0.002
- minlat = point.latitude - 0.002
- maxlon = point.longitude + 0.002
- maxlat = point.latitude + 0.002
- bbox = "#{minlon},#{minlat},#{maxlon},#{maxlat}"
- get :trackpoints, :params => { :bbox => bbox }
- assert_response :success
- assert_select "gpx[version='1.0'][creator='OpenStreetMap.org']", :count => 1 do
- assert_select "trk", :count => 1 do
- assert_select "trk>name", :count => 1
- assert_select "trk>desc", :count => 1
- assert_select "trk>url", :count => 1
- assert_select "trkseg", :count => 1 do
- assert_select "trkpt", :count => 1 do
- assert_select "time", :count => 1
- end
- end
- end
- end
- end
-