Files
iD/test/rendering.html
John Firebaugh 5ea855e18d Replace Graph#fetch with Graph#childNodes
Having two kinds of Ways (fetched and non-fetched)
introduced some accidental complexity. This brings things
more in line with how parentWays/parentRelations work.

Fixes #73.
2013-01-25 15:10:44 -05:00

128 lines
4.6 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>Rendering Tests</title>
<link rel="stylesheet" href="../css/map.css">
</head>
<body>
<!-- include source files here... -->
<script src='../js/lib/lodash.js'></script>
<script src='../js/lib/d3.v3.js'></script>
<script src='../js/id/id.js'></script>
<script src='../js/id/util.js'></script>
<script src="../js/id/geo.js"></script>
<script src="../js/id/geo/extent.js"></script>
<script src="../js/id/svg.js"></script>
<script src="../js/id/svg/areas.js"></script>
<script src="../js/id/svg/lines.js"></script>
<script src="../js/id/svg/member_classes.js"></script>
<script src="../js/id/svg/midpoints.js"></script>
<script src="../js/id/svg/multipolygons.js"></script>
<script src="../js/id/svg/points.js"></script>
<script src="../js/id/svg/surface.js"></script>
<script src="../js/id/svg/tag_classes.js"></script>
<script src="../js/id/svg/vertices.js"></script>
<script src='../js/id/graph/entity.js'></script>
<script src='../js/id/graph/graph.js'></script>
<script src='../js/id/graph/history.js'></script>
<script src='../js/id/graph/node.js'></script>
<script src='../js/id/graph/relation.js'></script>
<script src='../js/id/graph/way.js'></script>
<table>
<thead>
<tr><th></th><th colspan="3">z16</th><th colspan="3">z17</th></tr>
<tr><th></th><th>Base</th><th>Hover</th><th>Selected</th><th>Base</th><th>Hover</th><th>Selected</th></tr>
</thead>
<tbody class="highways">
</tbody>
</table>
<script>
var zooms = [16, 17],
modes = ['base', 'hover', 'selected'],
tags = [
{},
{highway: 'motorway'},
{highway: 'trunk'},
{highway: 'primary'},
{highway: 'secondary'},
{highway: 'tertiary'},
{highway: 'residential'},
{highway: 'service'},
{highway: 'track'},
{highway: 'road'},
{highway: 'unclassified'},
{highway: 'living_street'},
{highway: 'pedestrian'},
{highway: 'path'},
{highway: 'footway'},
{highway: 'cycleway'},
{highway: 'bridleway'},
{highway: 'steps'},
{highway: 'proposed'},
{highway: 'construction', construction: 'motorway'},
{highway: 'construction', construction: 'trunk'},
{railway: 'rail'},
{railway: 'abandoned'},
{railway: 'subway'},
{waterway: 'stream'},
{waterway: 'river'},
{waterway: 'ditch'},
{power: 'line'},
{boundary: 'administrative'},
{boundary: 'protected_area'},
{boundary: 'national_park'}];
var row = d3.select('.highways').selectAll('tr')
.data(tags)
.enter().append('tr');
row.append('th')
.html(function (d) { return _.map(d, function (value, key) { return key + "=" + value;}).join("<br>"); });
var projection = Object,
filter = d3.functor(true),
a = iD.Node({loc: [15, 15]}),
b = iD.Node({loc: [185, 15]}),
way = iD.Way({nodes: [a.id, b.id]}),
vertices = iD.svg.Vertices(projection),
lines = iD.svg.Lines(projection),
midpoints = iD.svg.Midpoints(projection);
row.selectAll('td')
.data(function (d) {
return _.flatten(zooms.map(function (z) {
return modes.map(function (m) {
return { zoom: z, mode: m, tags: d };
});
}));
})
.enter()
.append('td')
.append('svg')
.attr('width', 200)
.attr('height', 30)
.attr('data-zoom', function (d) { return d.zoom; })
.call(iD.svg.Surface())
.each(function (d) {
var highway = way.update({tags: d.tags}),
graph = iD.Graph([a, b, highway]);
d3.select(this)
.attr('class', d.mode === 'selected' ? 'mode-select' : 'mode-browse')
.call(vertices, graph, [a, b], filter)
.call(lines, graph, [highway], filter)
.call(midpoints, graph, [highway], filter)
.selectAll('.line')
.classed(d.mode, d.mode !== 'base');
});
</script>
</body>
</html>