From fdd5d2d7791f9138c339c9f18bcaa8946bd18d0c Mon Sep 17 00:00:00 2001 From: Harry Wood Date: Wed, 8 Apr 2009 16:55:22 +0000 Subject: [PATCH] new support for box=yes param on the homepage, and then link to this from various changeset display --- app/views/browse/_changeset_details.rhtml | 17 +++++++++---- app/views/changeset/_changeset.rhtml | 11 ++++----- app/views/changeset/list.rhtml | 2 +- app/views/changeset/list_bbox.rhtml | 17 +++++++------ app/views/changeset/list_user.rhtml | 4 ++++ app/views/site/index.rhtml | 8 +++++-- public/javascripts/map.js | 29 +++++++++++++++++++++++ 7 files changed, 67 insertions(+), 21 deletions(-) diff --git a/app/views/browse/_changeset_details.rhtml b/app/views/browse/_changeset_details.rhtml index 5b724012a..07f076e21 100644 --- a/app/views/browse/_changeset_details.rhtml +++ b/app/views/browse/_changeset_details.rhtml @@ -37,18 +37,25 @@ Bounding box: <% if changeset_details.max_lat.nil? or changeset_details.min_lat.nil? or changeset_details.max_lon.nil? or changeset_details.min_lon.nil? %> No bounding box has been stored for this changeset. - <% else %> + <% + else + minlon = changeset_details.min_lon/GeoRecord::SCALE.to_f + minlat = changeset_details.min_lat/GeoRecord::SCALE.to_f + maxlon = changeset_details.max_lon/GeoRecord::SCALE.to_f + maxlat = changeset_details.max_lat/GeoRecord::SCALE.to_f + %> - + - - + + + - +
<%= changeset_details.max_lat/GeoRecord::SCALE.to_f -%><%=maxlat -%>
<%= changeset_details.min_lon/GeoRecord::SCALE.to_f -%><%= changeset_details.max_lon/GeoRecord::SCALE.to_f -%><%=minlon -%>(box)<%=maxlon -%>
<%= changeset_details.min_lon/GeoRecord::SCALE.to_f -%><%= minlon -%>
diff --git a/app/views/changeset/_changeset.rhtml b/app/views/changeset/_changeset.rhtml index 049be5d33..a149a72e9 100644 --- a/app/views/changeset/_changeset.rhtml +++ b/app/views/changeset/_changeset.rhtml @@ -33,13 +33,12 @@ <% if changeset.min_lat.nil? %> (no edits) <% else - lat1 = changeset.min_lat/GeoRecord::SCALE.to_f - lat2 = changeset.max_lat/GeoRecord::SCALE.to_f - lon1 = changeset.min_lon/GeoRecord::SCALE.to_f - lon2 = changeset.max_lon/GeoRecord::SCALE.to_f + minlon = changeset.min_lon/GeoRecord::SCALE.to_f + minlat = changeset.min_lat/GeoRecord::SCALE.to_f + maxlon = changeset.max_lon/GeoRecord::SCALE.to_f + maxlat = changeset.max_lat/GeoRecord::SCALE.to_f %> - (<%= format("%0.3f",lat1) -%>,<%= format("%0.3f",lon1) -%>) to - (<%= format("%0.3f",lat2) -%>,<%= format("%0.3f",lon2) -%>) + (<%= format("%0.3f",minlon) -%>,<%= format("%0.3f",minlat) -%>,<%= format("%0.3f",maxlon) -%>,<%= format("%0.3f",maxlat) -%>) <% end %> diff --git a/app/views/changeset/list.rhtml b/app/views/changeset/list.rhtml index aa0d92758..4ac5082e1 100644 --- a/app/views/changeset/list.rhtml +++ b/app/views/changeset/list.rhtml @@ -16,4 +16,4 @@

For more changesets, select a user and view their edits, or see the editing 'history' of a specific area.

- +
diff --git a/app/views/changeset/list_bbox.rhtml b/app/views/changeset/list_bbox.rhtml index 63e54e11d..e1cf9aedb 100644 --- a/app/views/changeset/list_bbox.rhtml +++ b/app/views/changeset/list_bbox.rhtml @@ -1,16 +1,16 @@

History

<% if @bbox!=nil - lon1 = @bbox[0] - lat1 = @bbox[1] - lon2 = @bbox[2] - lat2 = @bbox[3] + minlon = @bbox[0] + minlat = @bbox[1] + maxlon = @bbox[2] + maxlat = @bbox[3] %>

Changesets within the area: -(<%= format("%0.3f",lat1) -%>,<%= format("%0.3f",lon1) -%>) to -(<%= format("%0.3f",lat2) -%>,<%= format("%0.3f",lon2) -%>) + (<%= format("%0.3f",minlon) -%>,<%= format("%0.3f",minlat) -%>,<%= format("%0.3f",maxlon) -%>,<%= format("%0.3f",maxlat) -%>) +

<% if @edits.nil? or @edits.empty? %> @@ -32,6 +32,9 @@ Changesets within the area: <%= render :partial => 'changeset_paging_nav' %> + +

For all changes everywhere see <%= link_to("Recent Changes", :controller => "browse", :action => "changesets") %>

+ <% end @@ -47,4 +50,4 @@ else end %>
-
+ diff --git a/app/views/changeset/list_user.rhtml b/app/views/changeset/list_user.rhtml index 2f3ca04ce..386423a56 100644 --- a/app/views/changeset/list_user.rhtml +++ b/app/views/changeset/list_user.rhtml @@ -16,3 +16,7 @@ <%= render :partial => 'changeset_paging_nav' %> <% end %> + +

For changes by all users see <%= link_to("Recent Changes", :controller => "browse", :action => "changesets") %>

+
+ diff --git a/app/views/site/index.rhtml b/app/views/site/index.rhtml index 35509f4e0..66f69960b 100644 --- a/app/views/site/index.rhtml +++ b/app/views/site/index.rhtml @@ -45,6 +45,7 @@ if params['minlon'] and params['minlat'] and params['maxlon'] and params['maxlat minlat = h(params['minlat']) maxlon = h(params['maxlon']) maxlat = h(params['maxlat']) + box = true if params['box']=="yes" end # Decide on a lat lon to initialise the map with. Various ways of doing this @@ -109,13 +110,16 @@ end var bbox = new OpenLayers.Bounds(<%= minlon %>, <%= minlat %>, <%= maxlon %>, <%= maxlat %>); setMapExtent(bbox); + <% if box %> + box = addBoxToMap(bbox); + <% end %> <% else %> var centre = new OpenLayers.LonLat(<%= lon %>, <%= lat %>); var zoom = <%= zoom %>; - <% if params['scale'] and params['scale'].length > 0 then %> + <% if params['scale'] and params['scale'].length > 0 then %> zoom = scaleToZoom(<%= params['scale'].to_f() %>); - <% end %> + <% end %> setMapCenter(centre, zoom); <% end %> diff --git a/public/javascripts/map.js b/public/javascripts/map.js index a25564f0d..a52cd0a70 100644 --- a/public/javascripts/map.js +++ b/public/javascripts/map.js @@ -1,6 +1,7 @@ var epsg4326 = new OpenLayers.Projection("EPSG:4326"); var map; var markers; +var vectors; var popup; var nonamekeys = { @@ -82,6 +83,17 @@ function createMap(divName, options) { projection: "EPSG:900913" }); map.addLayer(markers); + + vectors = new OpenLayers.Layer.Vector("Vectors", { + displayInLayerSwitcher: false, + numZoomLevels: numZoomLevels, + maxExtent: new OpenLayers.Bounds(-20037508,-20037508,20037508,20037508), + maxResolution: 156543, + units: "m", + projection: "EPSG:900913" + }); + map.addLayer(vectors); + return map; } @@ -106,6 +118,19 @@ function addMarkerToMap(position, icon, description) { return marker; } +function addBoxToMap(boxbounds) { + box = new OpenLayers.Feature.Vector( + boxbounds.toGeometry().transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()) ); + + box.style = { + 'strokeWidth': 3, + 'strokeColor': '#0000ff', + 'fillOpacity': 0, + }; + vectors.addFeatures(box); + return box; +} + function openMapPopup(marker, description) { closeMapPopup(); @@ -129,6 +154,10 @@ function removeMarkerFromMap(marker){ markers.removeMarker(marker); } +function removeBoxFromMap(box){ + vectors.removeFeature(box); +} + function getMapCenter(center, zoom) { return map.getCenter().clone().transform(map.getProjectionObject(), epsg4326); } -- 2.39.5