From: Tom Hughes Date: Wed, 28 May 2008 16:37:31 +0000 (+0000) Subject: Merge 7744:7922 from trunk. X-Git-Tag: live~7767^2~7 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/88105d9c643519e02082ba9cc5044bb0dfdcb7b9?hp=18777b41ea4aa1364dbf33e86e6cb65762b53296 Merge 7744:7922 from trunk. --- diff --git a/app/controllers/amf_controller.rb b/app/controllers/amf_controller.rb index 421444869..4eda7b00a 100644 --- a/app/controllers/amf_controller.rb +++ b/app/controllers/amf_controller.rb @@ -638,8 +638,8 @@ class AmfController < ApplicationController # which means the SWF needs to allocate new ids # - if it's an invisible node, we can reuse the old node id - # get node list from specified version of way, - # and the _current_ lat/long/tags of each node + # ----- get node list from specified version of way, + # and the _current_ lat/long/tags of each node row=ActiveRecord::Base.connection.select_one("SELECT timestamp FROM ways WHERE version=#{version} AND id=#{id}") waytime=row['timestamp'] @@ -654,31 +654,31 @@ class AmfController < ApplicationController EOF rows=ActiveRecord::Base.connection.select_all(sql) - # if historic (full revert), get the old version of each node - # - if it's in another way now, generate a new id - # - if it's not in another way, use the old ID + # ----- if historic (full revert), get the old version of each node + # - if it's in another way now, generate a new id + # - if it's not in another way, use the old ID + if historic then rows.each_index do |i| sql=<<-EOF SELECT latitude*0.0000001 AS latitude,longitude*0.0000001 AS longitude,tags,cwn.id AS currentway FROM nodes n - LEFT JOIN current_way_nodes cwn - ON cwn.node_id=n.id + LEFT JOIN current_way_nodes cwn + ON cwn.node_id=n.id AND cwn.id!=#{id} WHERE n.id=#{rows[i]['id']} AND n.timestamp<="#{waytime}" - AND cwn.id!=#{id} - ORDER BY n.timestamp DESC + ORDER BY n.timestamp DESC LIMIT 1 EOF row=ActiveRecord::Base.connection.select_one(sql) - unless row.nil? then - nx=row['longitude'].to_f - ny=row['latitude'].to_f + nx=row['longitude'].to_f + ny=row['latitude'].to_f + if (!row.nil?) if (row['currentway'] && (nx!=rows[i]['longitude'].to_f or ny!=rows[i]['latitude'].to_f or row['tags']!=rows[i]['tags'])) then rows[i]['id']=-1 end - rows[i]['longitude']=nx - rows[i]['latitude' ]=ny - rows[i]['tags' ]=row['tags'] - end + end + rows[i]['longitude']=nx + rows[i]['latitude' ]=ny + rows[i]['tags' ]=row['tags'] end end rows diff --git a/app/models/relation.rb b/app/models/relation.rb index 61344bdfb..cedfaf656 100644 --- a/app/models/relation.rb +++ b/app/models/relation.rb @@ -202,22 +202,49 @@ class Relation < ActiveRecord::Base end def preconditions_ok? + # These are hastables that store an id in the index of all + # the nodes/way/relations that have already been added. + # Once we know the id of the node/way/relation exists + # we check to see if it is already existing in the hashtable + # if it does, then we return false. Otherwise + # we add it to the relevant hash table, with the value true.. + # Thus if you have nodes with the ids of 50 and 1 already in the + # relation, then the hash table nodes would contain: + # => {50=>true, 1=>true} + nodes = Hash.new + ways = Hash.new + relations = Hash.new self.members.each do |m| if (m[0] == "node") n = Node.find(:first, :conditions => ["id = ?", m[1]]) unless n and n.visible return false end + if nodes[m[1]] + return false + else + nodes[m[1]] = true + end elsif (m[0] == "way") w = Way.find(:first, :conditions => ["id = ?", m[1]]) unless w and w.visible and w.preconditions_ok? return false end + if ways[m[1]] + return false + else + ways[m[1]] = true + end elsif (m[0] == "relation") e = Relation.find(:first, :conditions => ["id = ?", m[1]]) unless e and e.visible and e.preconditions_ok? return false end + if relations[m[1]] + return false + else + relations[m[1]] = true + end else return false end diff --git a/app/views/export/start.rjs b/app/views/export/start.rjs index 2babcc982..47cf9ce6b 100644 --- a/app/views/export/start.rjs +++ b/app/views/export/start.rjs @@ -246,7 +246,9 @@ page << <View Larger Map'; + var layers = getMapLayers(); + + html += '
View Larger Map'; $("export_html_text").value = html; diff --git a/app/views/message/new.rhtml b/app/views/message/new.rhtml index 214df8d31..d7bb18f8e 100644 --- a/app/views/message/new.rhtml +++ b/app/views/message/new.rhtml @@ -22,7 +22,7 @@ - <%= submit_tag 'Send', :action => 'new' %> + <%= submit_tag 'Send' %> <% end %> diff --git a/app/views/site/_search.rhtml b/app/views/site/_search.rhtml index f18587f73..5b4e74b34 100644 --- a/app/views/site/_search.rhtml +++ b/app/views/site/_search.rhtml @@ -38,13 +38,8 @@ <% form_remote_tag(:loading => "startSearch()", :complete => "endSearch()", :url => { :controller => :geocoder, :action => :search }) do %> - - - - - - -
<%= text_field_tag :query, h(params[:query]) %><%= submit_tag 'Go' %>
+ <%= text_field_tag :query, h(params[:query]) %> + <%= submit_tag "Go" %> <% end %>

Searching...

diff --git a/app/views/site/edit.rhtml b/app/views/site/edit.rhtml index ac54cb5e5..afd33e4ae 100644 --- a/app/views/site/edit.rhtml +++ b/app/views/site/edit.rhtml @@ -105,7 +105,29 @@ resizeMap(); } + + function maximiseMap() { + $("left").style.display = "none"; + $("greeting").style.display = "none"; + $("tabnav").style.display = "none"; + + $("content").style.top = "10px"; + $("content").style.left = "10px"; + + handleResize(); + } + function minimiseMap() { + $("left").style.display = ""; + $("greeting").style.display = ""; + $("tabnav").style.display = ""; + + $("content").style.top = "35px"; + $("content").style.left = "192px"; + + handleResize(); + } + handleResize(); window.onload = handleResize; diff --git a/app/views/site/index.rhtml b/app/views/site/index.rhtml index bd114a6b3..656db99c8 100644 --- a/app/views/site/index.rhtml +++ b/app/views/site/index.rhtml @@ -8,6 +8,14 @@ <%= render :partial => 'key' %> <%= render :partial => 'search' %> + + diff --git a/public/export/embed.html b/public/export/embed.html index ae82eb54a..af45a6b1f 100644 --- a/public/export/embed.html +++ b/public/export/embed.html @@ -37,13 +37,20 @@ attribution: attribution }); map.addLayer(mapnik); - } else { + } else if (args.layer == "osmarender") { var osmarender = new OpenLayers.Layer.OSM.Osmarender("Osmarender", { displayOutsideMaxExtent: true, wrapDateLine: true, attribution: attribution }); map.addLayer(osmarender); + } else if (args.layer == "cycle map") { + var cyclemap = new OpenLayers.Layer.OSM.CycleMap("Cycle Map", { + displayOutsideMaxExtent: true, + wrapDateLine: true, + attribution: attribution + }); + map.addLayer(cyclemap); } if (args.marker) { diff --git a/public/javascripts/map.js b/public/javascripts/map.js index 9b144c560..2bdba6229 100644 --- a/public/javascripts/map.js +++ b/public/javascripts/map.js @@ -36,6 +36,12 @@ function createMap(divName, options) { }); map.addLayer(osmarender); + var cyclemap = new OpenLayers.Layer.OSM.CycleMap("Cycle Map", { + displayOutsideMaxExtent: true, + wrapDateLine: true + }); + map.addLayer(cyclemap); + var maplint = new OpenLayers.Layer.OSM.Maplint("Maplint", { displayOutsideMaxExtent: true, wrapDateLine: true @@ -120,35 +126,39 @@ function getEventPosition(event) { } function getMapLayers() { - var layers = ""; + var layerConfig = ""; - for (var i=0; i< this.map.layers.length; i++) { - var layer = this.map.layers[i]; + for (var layers = map.getLayersBy("isBaseLayer", true), i = 0; i < layers.length; i++) { + layerConfig += layers[i] == map.baseLayer ? "B" : "0"; + } - if (layer.isBaseLayer) { - layers += (layer == this.map.baseLayer) ? "B" : "0"; - } else { - layers += (layer.getVisibility()) ? "T" : "F"; - } + for (var layers = map.getLayersBy("isBaseLayer", false), i = 0; i < layers.length; i++) { + layerConfig += layers[i].getVisibility() ? "T" : "F"; } - return layers; + return layerConfig; } -function setMapLayers(layers) { - for (var i=0; i < layers.length; i++) { - var layer = map.layers[i]; +function setMapLayers(layerConfig) { + var l = 0; - if (layer) { - var c = layers.charAt(i); + for (var layers = map.getLayersBy("isBaseLayer", true), i = 0; i < layers.length; i++) { + var c = layerConfig.charAt(l++); - if (c == "B") { - map.setBaseLayer(layer); - } else if ( (c == "T") || (c == "F") ) { - layer.setVisibility(c == "T"); - } + if (c == "B") { + map.setBaseLayer(layers[i]); } } + + while (layerConfig.charAt(l) == "B" || layerConfig.charAt(l) == "0") { + l++; + } + + for (var layers = map.getLayersBy("isBaseLayer", false), i = 0; i < layers.length; i++) { + var c = layerConfig.charAt(l++); + + layers[i].setVisibility(c == "T"); + } } function scaleToZoom(scale) { diff --git a/public/openlayers/OpenStreetMap.js b/public/openlayers/OpenStreetMap.js index d6bc397d1..69e8840b2 100644 --- a/public/openlayers/OpenStreetMap.js +++ b/public/openlayers/OpenStreetMap.js @@ -155,6 +155,34 @@ OpenLayers.Layer.OSM.Osmarender = OpenLayers.Class(OpenLayers.Layer.OSM, { CLASS_NAME: "OpenLayers.Layer.OSM.Osmarender" }); +/** + * Class: OpenLayers.Layer.OSM.CycleMap + * + * Inherits from: + * - + */ +OpenLayers.Layer.OSM.CycleMap = OpenLayers.Class(OpenLayers.Layer.OSM, { + /** + * Constructor: OpenLayers.Layer.OSM.CycleMap + * + * Parameters: + * name - {String} + * options - {Object} Hashtable of extra options to tag onto the layer + */ + initialize: function(name, options) { + var url = [ + "http://a.thunderflames.org/tiles/cycle/", + "http://b.thunderflames.org/tiles/cycle/", + "http://c.thunderflames.org/tiles/cycle/" + ]; + options = OpenLayers.Util.extend({ numZoomLevels: 17 }, options); + var newArguments = [name, url, options]; + OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments); + }, + + CLASS_NAME: "OpenLayers.Layer.OSM.CycleMap" +}); + /** * Class: OpenLayers.Layer.OSM.Maplint * diff --git a/public/potlatch/potlatch.swf b/public/potlatch/potlatch.swf index 9f86b17bd..8c3d0c915 100755 Binary files a/public/potlatch/potlatch.swf and b/public/potlatch/potlatch.swf differ diff --git a/public/stylesheets/site.css b/public/stylesheets/site.css index 2ede490ef..df04b7c99 100644 --- a/public/stylesheets/site.css +++ b/public/stylesheets/site.css @@ -354,13 +354,16 @@ hides rule from IE5-Mac \*/ padding: 0px; } -.optionalbox input { +#search_field form { width: 100%; } -.optionalbox td { - margin: 0px; - padding: 0px; +#search_field input[type="text"] { + width: 116px; +} + +#search_field input[type="submit"] { + width: 26px; } .search_form { @@ -639,3 +642,10 @@ input[type="submit"] { width: 100%; text-align: center; } + +#noscript { + z-index:20000000; + position:absolute; + top:15px; + left:15px +}