mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 09:12:52 +00:00
Clarify how connections have graphs, don't build big arrays in memory
This commit is contained in:
@@ -63,9 +63,7 @@
|
||||
Imagery <a href="http://opengeodata.org/microsoft-imagery-details">© 2012</a> Bing, GeoEye, Getmapping, Intermap, Microsoft.</p>
|
||||
</div>
|
||||
<script>
|
||||
var connection = new iD.Connection("http://www.overpass-api.de/api/xapi?");
|
||||
var graph = new iD.Graph();
|
||||
connection.graph(graph);
|
||||
var connection = new iD.Connection(new iD.Graph());
|
||||
|
||||
var m = d3.select('#map');
|
||||
// Initialise map
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
iD.Connection = function() {
|
||||
iD.Connection = function(graph) {
|
||||
// summary: The data store, including methods to fetch data from (and, eventually, save data to)
|
||||
// an OSM API server.
|
||||
var nextNode = -1,
|
||||
nextWay = -1,
|
||||
nextRelation = -1,
|
||||
graph = {},
|
||||
apiURL = 'http://www.openstreetmap.org/api/0.6/';
|
||||
|
||||
var connection = {};
|
||||
@@ -99,12 +98,7 @@ iD.Connection = function() {
|
||||
};
|
||||
}
|
||||
|
||||
connection.graph = function(x) {
|
||||
if (!arguments.length) return graph;
|
||||
graph = x;
|
||||
return connection;
|
||||
};
|
||||
|
||||
connection.graph = graph;
|
||||
connection.all = all;
|
||||
connection.loadFromAPI = loadFromAPI;
|
||||
connection.loadFromURL = loadFromURL;
|
||||
|
||||
@@ -18,8 +18,14 @@ iD.Map = function(obj) {
|
||||
var inspector = iD.Inspector();
|
||||
|
||||
var linegen = d3.svg.line()
|
||||
.x(function(d) { return projection(d)[0]; })
|
||||
.y(function(d) { return projection(d)[1]; });
|
||||
.x(function(d) {
|
||||
var node = connection.graph.index[d];
|
||||
return projection([node.lon, node.lat])[0];
|
||||
})
|
||||
.y(function(d) {
|
||||
var node = connection.graph.index[d];
|
||||
return projection([node.lon, node.lat])[1];
|
||||
});
|
||||
|
||||
var zoombehavior = d3.behavior.zoom()
|
||||
.translate(projection.translate())
|
||||
@@ -112,10 +118,7 @@ iD.Map = function(obj) {
|
||||
}
|
||||
|
||||
function nodeline(d) {
|
||||
return linegen(d.children.map(function(n) {
|
||||
var node = connection.graph().index[n];
|
||||
return [node.lon, node.lat];
|
||||
}));
|
||||
return linegen(d.children);
|
||||
}
|
||||
|
||||
// This is an unfortunate hack that should be improved.
|
||||
|
||||
Reference in New Issue
Block a user