Merge 7744:7922 from trunk.

This commit is contained in:
Tom Hughes 2008-05-28 16:37:31 +00:00
commit 88105d9c64
12 changed files with 160 additions and 51 deletions

View 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

View 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

View 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;

View file

@ -22,7 +22,7 @@
</tr>
<tr>
<th></th>
<td><%= submit_tag 'Send', :action => 'new' %></td>
<td><%= submit_tag 'Send' %></td>
</tr>
</table>
<% end %>

View file

@ -38,13 +38,8 @@
<% 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>

View file

@ -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;

View 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>

View file

@ -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) {

View 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,34 +126,38 @@ 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 layerConfig;
}
function setMapLayers(layerConfig) {
var l = 0;
for (var layers = map.getLayersBy("isBaseLayer", true), i = 0; i < layers.length; i++) {
var c = layerConfig.charAt(l++);
if (c == "B") {
map.setBaseLayer(layers[i]);
}
}
return layers;
}
while (layerConfig.charAt(l) == "B" || layerConfig.charAt(l) == "0") {
l++;
}
function setMapLayers(layers) {
for (var i=0; i < layers.length; i++) {
var layer = map.layers[i];
for (var layers = map.getLayersBy("isBaseLayer", false), i = 0; i < layers.length; i++) {
var c = layerConfig.charAt(l++);
if (layer) {
var c = layers.charAt(i);
if (c == "B") {
map.setBaseLayer(layer);
} else if ( (c == "T") || (c == "F") ) {
layer.setVisibility(c == "T");
}
}
layers[i].setVisibility(c == "T");
}
}

View 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
*

Binary file not shown.

View 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
}