openstreetmap / openstreetmap-website

The Rails application that powers OpenStreetMap
https://www.openstreetmap.org/
GNU General Public License v2.0
2.08k stars 906 forks source link

allow to export notes through osm.org #427

Open richlv opened 10 years ago

richlv commented 10 years ago

notes have a great potential to collect feedback from 'normal users', but that works if somebody actually works on them. right now, placing notes on a portable device involves an api download, which is not convenient and not even within the reach of many mappers. it would be great if osm.org would allow to export currently visible notes as a gpx (for an upload to a gps device, for example) - this could be in the export tab or whatever, as long as it is a simple click-result operation

richlv commented 10 years ago

actually, it would be also very nice to be able to get gpx of an individual note. as an example, right now i'm interested in 3 diagonal notes in the middle of an area where getting a bbox would throw 8 or so other notes at me. if this can't be handled in the same issue, i'd be glad to create a new one :)

tomhughes commented 10 years ago

You can already do both these things! Try:

http://api.openstreetmap.org/api/0.6/notes.gpx?bbox=-0.7965087890625,51.117316848748956,0.318603515625,51.84935276370605

and

http://api.openstreetmap.org/api/0.6/notes/4.gpx

richlv commented 10 years ago

hmm, i might be missing something here... but how can i get to such a url from osm.org interface ? i'm thinking of a "casual mapper" who would like to go to osm.org, see notes and then just drop them off in their gps unit for review

tomhughes commented 10 years ago

I never said you could - it's an API so is normally exposed in documentation rather than directly.

That's not to say we couldn't add those links, though I'm not sure how you would choose which of the four supported formats to offer, or where you would actually put the links.

All I was saying is that the technology already exists.

richlv commented 10 years ago

link for downloading the visible notes could be in 'export' section; link for downloading individual notes could be in the note popup.

the main idea is to make notes easy to work on by mappers who actually want to go out and verify them :)

richlv commented 10 years ago

i wanted to go and check several notes "on the ground" yesterday, but i was in a hurry, so getting them on my gps was too cumbersome... which reminded me about this issue ;)

a) placement - for individual notes, let's place a link in the note popup itself, at the top of it - somewhere where the permalink icon is currently

b) 4 different formats refer to XML, RSS, json or GPX (as per the api docs) the primary goal is to allow contributors to go out and check on the notes, so gpx should be available in any case. we can also have a dropdown like for the 'edit' "tab", with the default being gpx.

there's another issue of the gps output being pretty bad, but i'll create a new issue about that soon ;)

edit : it's #457 about gpx output containing css and other useless info

marcows commented 8 years ago

Here is a rudimentary patch, which adds a drop-down list into the 'Export' site. Now you can select between different formats, OSM XML being the default as before, additionally Notes in the four supported formats.

This also has the beneficial side effect that now one knows that OSM XML data will be exported. This wasn't clear to me before pressing the Export button to start the download.

I don't have the time and surely am lacking some web development skills to bring it forward in the near future, but maybe it is a starting point for someone else.

diff --git a/app/controllers/export_controller.rb b/app/controllers/export_controller.rb
index bd020f2..ee9f8d3 100644
--- a/app/controllers/export_controller.rb
+++ b/app/controllers/export_controller.rb
@@ -13,6 +13,22 @@ class ExportController < ApplicationController
       # redirect to API map get
       redirect_to "http://api.openstreetmap.org/api/#{API_VERSION}/map?bbox=#{bbox}"

+    elsif format == "notes_rss"
+      # redirect to API notes get
+      redirect_to "http://api.openstreetmap.org/api/#{API_VERSION}/notes.rss?bbox=#{bbox}&limit=10000"
+
+    elsif format == "notes_xml"
+      # redirect to API notes get
+      redirect_to "http://api.openstreetmap.org/api/#{API_VERSION}/notes.xml?bbox=#{bbox}&limit=10000"
+
+    elsif format == "notes_json"
+      # redirect to API notes get
+      redirect_to "http://api.openstreetmap.org/api/#{API_VERSION}/notes.json?bbox=#{bbox}&limit=10000"
+
+    elsif format == "notes_gpx"
+      # redirect to API notes get
+      redirect_to "http://api.openstreetmap.org/api/#{API_VERSION}/notes.gpx?bbox=#{bbox}&limit=10000"
+
     elsif format == "mapnik"
       # redirect to a special 'export' cgi script
       format = params[:mapnik_format]
diff --git a/app/views/site/export.html.erb b/app/views/site/export.html.erb
index 6bf3365..68ef08e 100644
--- a/app/views/site/export.html.erb
+++ b/app/views/site/export.html.erb
@@ -6,7 +6,6 @@
 </h2>

 <%= form_tag({:controller => "export", :action => "finish"}, :class => "export_form") do %>
-  <%= hidden_field_tag 'format', 'osm' %>

   <div class='export_area_inputs'>
     <div class='export_boxy' style="border: 1px solid #ccc;">
@@ -29,6 +28,17 @@
     </p>
   </div>

+  <div>
+    <label for="format">Data type:</label>
+    <select id="format" name="format">
+      <option value="osm">Map data (OSM XML)</option>
+      <option value="notes_rss">Notes (RSS)</option>
+      <option value="notes_xml">Notes (XML)</option>
+      <option value="notes_json">Notes (JSON)</option>
+      <option value="notes_gpx">Notes (GPX)</option>
+    </select>
+  </div>
+
   <div id="export_commit">
     <div class="export_button">
       <%= submit_tag t('export.start.export_button') %>

Before (original): Export original

After (with selection): Export with selection

tomhughes commented 8 years ago

I really don't see this as a good approach - export is, and has been for many years, for exporting maps and I don't think we should overload it with other things.

tomhughes commented 8 years ago

Sorry, didn't realise this was an existing ticket. Have reopened it now.

marcows commented 8 years ago

Given that we have two check boxes for "Map Notes" and "Map Data" in the "Layers" side bar directly among each other, I don't see why the similarity between these two kinds of raw data should not be picked up on the "Export" site.

danstowell commented 8 years ago

fwiw I quite like the suggested modification. It adds zero extra clicks to existing workflows, but makes notes data available for point-and-click users, and as marcows points out it gives a visual clue about what it is you'll be downloading.

tomhughes commented 8 years ago

To be honest I had forgotten that panel was only for data export now - given that it probably does make more sense.

@marcows - if you want to propose a change it's better to open a proper PR and reference this issue than to paste the patch into this ticket.

marcows commented 8 years ago

I deliberately did not because I didn't plan to continue working on it and wanted to avoid having an unfinished pull request floating around. But maybe it actually is better even in this case, so I will probably catch up on this at home.