]> git.openstreetmap.org Git - rails.git/commitdiff
Merge 7744:7922 from trunk.
authorTom Hughes <tom@compton.nu>
Wed, 28 May 2008 16:37:31 +0000 (16:37 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 28 May 2008 16:37:31 +0000 (16:37 +0000)
12 files changed:
app/controllers/amf_controller.rb
app/models/relation.rb
app/views/export/start.rjs
app/views/message/new.rhtml
app/views/site/_search.rhtml
app/views/site/edit.rhtml
app/views/site/index.rhtml
public/export/embed.html
public/javascripts/map.js
public/openlayers/OpenStreetMap.js
public/potlatch/potlatch.swf
public/stylesheets/site.css

index 4214448696d6fb2d85f7f37fb1b0daec83ca30dd..4eda7b00aa27456b246ee1b4d16ce39f4abba712 100644 (file)
@@ -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
index 61344bdfb62021fad69b67c72cf4e97d0b59219f..cedfaf656250e25b01f148b8c8175f13153e035b 100644 (file)
@@ -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
index 2babcc982e2d78ac5df6380d10836b21cfe94736..47cf9ce6bf21feddbcec4cc630233677fd30205c 100644 (file)
@@ -246,7 +246,9 @@ page << <<EOJ
     bounds.transform(epsg4326, epsg900913);
     var zoom = map.getZoomForExtent(bounds);
     
-    html += '<br /><small><a href="http://#{SERVER_URL}/?lat='+center.lat+'&lon='+center.lon+'&zoom='+zoom+markerUrl+'">View Larger Map</a></small>';
+    var layers = getMapLayers();
+
+    html += '<br /><small><a href="http://#{SERVER_URL}/?lat='+center.lat+'&lon='+center.lon+'&zoom='+zoom+'&layers='+layers+markerUrl+'">View Larger Map</a></small>';
 
     $("export_html_text").value = html;
 
index 214df8d31fd8f1de8130d335559d12590b961277..d7bb18f8e59461492982ab5ec2ccea114a2b5499 100644 (file)
@@ -22,7 +22,7 @@
     </tr>
     <tr>
       <th></th>
-      <td><%= submit_tag 'Send', :action => 'new' %></td>
+      <td><%= submit_tag 'Send' %></td>
     </tr>
   </table>
 <% end %>
index f18587f737e2478dd4e0d77256f1d06a0df95930..5b4e74b34f4b130c072b3f6754155c773a47db0c 100644 (file)
     <% form_remote_tag(:loading => "startSearch()",
                        :complete => "endSearch()",
                        :url => { :controller => :geocoder, :action => :search }) do %>
-      <table>
-        <tr>
-          <td><%= text_field_tag :query, h(params[:query]) %></td>
-          <td></td>
-          <td><%= submit_tag 'Go' %></td>
-        </tr>
-      </table>
+      <%= text_field_tag :query, h(params[:query]) %>
+      <%= submit_tag "Go" %>
     <% end %>
     </span>
     <p id="search_active">Searching...</p>
index ac54cb5e5f74c101f962b92fdb3c32657e479bd6..afd33e4ae1cbb1371dfec634cfae140374d6ea57 100644 (file)
 
     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;
index bd114a6b36e54c640dc1221261de6ccec5f37e2a..656db99c80008a3b8757d061bf25d12f52dad4d1 100644 (file)
@@ -8,6 +8,14 @@
 <%= render :partial => 'key' %>
 <%= render :partial => 'search' %>
 
+<noscript>
+  <div id="noscript">
+    <p>You are either using a browser that doesn't support javascript, or you have disabled javascript.</p>
+    <p>OpenStreetMap uses javascript for its slippy map.</p>
+    <p>You may want to try the <a href="http://tah.openstreetmap.org/Browse/">Tiles@Home static tile browser</a> if you are unable to enable javascript.</p>
+  </div>
+</noscript>
+
 <div id="map">
 <div id="permalink"><a href="/" id="permalinkanchor">Permalink</a></div>
 </div> 
index ae82eb54a9361af21ce84fb484d43aeb875c237a..af45a6b1f99cea1eb631c0e19a6863d76763a128 100644 (file)
                    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) {
index 9b144c560a5093f6d0852137f7e948dc079dc991..2bdba6229b589b8d52ae3a96fd8e21e5d8b361d9 100644 (file)
@@ -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) {
index d6bc397d132ae517433ae494ad5956a0cc18cef1..69e8840b2a33e5152da97bbc1a0d824cc225f416 100644 (file)
@@ -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>
+ */
+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
  *
index 9f86b17bd30895e11a358720cf807d8b4100458f..8c3d0c9153c364a0c7efcc83c9eed2144e898d5a 100755 (executable)
Binary files a/public/potlatch/potlatch.swf and b/public/potlatch/potlatch.swf differ
index 2ede490efc557377171b7deecc156fa285495741..df04b7c99d7721a2d9856ff54ec75047df66ea4d 100644 (file)
@@ -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
+}