Initial support for only_* restrictions

This commit is contained in:
John Firebaugh
2014-05-19 15:53:46 -07:00
parent 67e7380980
commit 8b6ce214a2
5 changed files with 115 additions and 44 deletions
+4 -2
View File
@@ -27,6 +27,8 @@
"icon-restriction-yes": [50, 80],
"icon-restriction-no": [95, 80],
"icon-restriction-yes-u": [140, 80],
"icon-restriction-no-u": [185, 80]
"icon-restriction-only": [140, 80],
"icon-restriction-yes-u": [185, 80],
"icon-restriction-no-u": [230, 80],
"icon-restriction-only-u": [275, 80]
}
+37 -15
View File
@@ -13,7 +13,7 @@
width="800"
height="560"
id="svg12393"
inkscape:version="0.48.2 r9819"
inkscape:version="0.48.4 r"
sodipodi:docname="sprite.svg">
<sodipodi:namedview
pagecolor="#ffffff"
@@ -27,12 +27,12 @@
inkscape:window-width="1440"
inkscape:window-height="856"
id="namedview392"
showgrid="false"
inkscape:zoom="1"
inkscape:cx="244.75771"
inkscape:cy="110.55845"
inkscape:window-x="305"
inkscape:window-y="95"
showgrid="true"
inkscape:zoom="2.8284271"
inkscape:cx="186.53252"
inkscape:cy="447.46176"
inkscape:window-x="276"
inkscape:window-y="71"
inkscape:window-maximized="0"
inkscape:current-layer="svg12393"
showguides="true"
@@ -84,7 +84,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@@ -1941,14 +1941,15 @@
</g>
<g
id="g4190"
transform="matrix(0,1,1,0,71.9905,-80.00893)">
transform="matrix(0,1,1,0,116.9905,-80.00893)">
<path
style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;opacity:0.5;color:#000000;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:8;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Sans;-inkscape-font-specification:Sans"
d="M 156 80 C 147.21084 80.00001 140 87.21083 140 96 C 140.00001 104.78916 147.21083 112 156 112 C 164.78916 111.99999 172 104.78917 172 96 C 171.99999 87.21084 164.78917 80 156 80 z "
d="m 156,80 c -8.78916,1e-5 -16,7.21083 -16,16 1e-5,8.78916 7.21083,16 16,16 8.78916,-1e-5 16,-7.21083 16,-16 -1e-5,-8.78916 -7.21083,-16 -16,-16 z"
id="path4163"
transform="matrix(0,1,1,0,80.00893,-71.9905)" />
transform="matrix(0,1,1,0,80.00893,-71.9905)"
inkscape:connector-curvature="0" />
<path
style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#8cd05f;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.25000000000000000;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Sans;-inkscape-font-specification:Sans"
style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#8cd05f;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.25;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Sans;-inkscape-font-specification:Sans"
d="m 176.00893,72.0095 c -6.62739,0 -11.99999,5.37261 -12,12 0,6.62739 5.37261,11.99999 12,12 6.62739,0 11.99999,-5.37261 12,-12 0,-6.62739 -5.37261,-11.99999 -12,-12 z"
id="path11970"
inkscape:connector-curvature="0" />
@@ -1961,7 +1962,7 @@
</g>
<g
id="g4206"
transform="matrix(0,1,1,0,122,-115)">
transform="matrix(0,1,1,0,167,-115)">
<path
sodipodi:nodetypes="sssss"
inkscape:connector-curvature="0"
@@ -1980,7 +1981,7 @@
style="opacity:0.5;color:#000000;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
</g>
<g
transform="matrix(0,1,-1,0,225,203)"
transform="matrix(0,1,-1,0,135,203)"
id="g3350">
<path
style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;opacity:0.5;color:#000000;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:8;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Sans;-inkscape-font-specification:Sans"
@@ -1989,7 +1990,7 @@
inkscape:connector-curvature="0"
sodipodi:nodetypes="ssccccccsscccccss" />
<path
style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#7092ff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.25000000000000000;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Sans;-inkscape-font-specification:Sans"
style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#7092ff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.25;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Sans;-inkscape-font-specification:Sans"
d="m -111,-45 -8,9.01282 1,1 4,0 0,10.59375 c -2.92023,1.19221 -4.99998,4.05725 -5,7.40625 4e-5,4.41829 3.58172,7.98721 8,7.98718 4.41827,10e-6 8,-3.5689 8,-7.98718 2e-5,-3.36351 -2.05966,-6.25472 -5,-7.4375 l 0,-10.5625 4,0 1,-1 z"
id="path3354"
inkscape:connector-curvature="0"
@@ -2011,4 +2012,25 @@
id="tspan3360"
x="254.91199"
y="126.18999">ONLY</tspan></text>
<g
id="g4190-7"
transform="matrix(0,1,1,0,206.9905,-80.00893)">
<path
style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;opacity:0.5;color:#000000;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:8;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Sans;-inkscape-font-specification:Sans"
d="m 156,80 c -8.78916,1e-5 -16,7.21083 -16,16 1e-5,8.78916 7.21083,16 16,16 8.78916,-1e-5 16,-7.21083 16,-16 -1e-5,-8.78916 -7.21083,-16 -16,-16 z"
id="path4163-9"
transform="matrix(0,1,1,0,80.00893,-71.9905)"
inkscape:connector-curvature="0" />
<path
style="font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-indent:0;text-align:start;text-decoration:none;line-height:normal;letter-spacing:normal;word-spacing:normal;text-transform:none;direction:ltr;block-progression:tb;writing-mode:lr-tb;text-anchor:start;baseline-shift:baseline;color:#000000;fill:#7092ff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.25000000000000000;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Sans;-inkscape-font-specification:Sans"
d="m 176.00893,72.0095 c -6.62739,0 -11.99999,5.37261 -12,12 0,6.62739 5.37261,11.99999 12,12 6.62739,0 11.99999,-5.37261 12,-12 0,-6.62739 -5.37261,-11.99999 -12,-12 z"
id="path11970-3"
inkscape:connector-curvature="0" />
<path
sodipodi:nodetypes="cccccccccccccccccccccc"
d="m 184.00894,85.00953 -2.99999,-4e-5 -3e-5,-2.99998 -0.99997,-2.00006 -1.00001,-0.99998 -2.00002,-0.99997 -3.00003,3e-5 -1.99994,0.99998 -1.00004,0.99999 -0.99998,2.00003 -1e-5,4.99996 1.00004,1.00001 0.99996,1e-5 1,-1 2e-5,-4.99996 0.99999,-1.00004 2.99997,0 1.00003,0.99999 -1e-5,3 -3.00003,-3e-5 4.50003,5.00003 z"
id="path2997-6-6-8"
style="opacity:0.5;color:#000000;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
inkscape:connector-curvature="0" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 173 KiB

After

Width:  |  Height:  |  Size: 176 KiB

+6
View File
@@ -58,6 +58,12 @@ iD.geo.Intersection = function(graph, vertexId) {
v && v.id === turn.via.node &&
t && t.id === turn.to.way) {
turn.restriction = relation.id;
} else if (/^only_/.test(relation.tags.restriction) &&
f && f.id === turn.from.way &&
v && v.id === turn.via.node &&
t && t.id !== turn.to.way) {
turn.restriction = relation.id;
turn.indirect_restriction = true;
}
});
+24 -23
View File
@@ -1,22 +1,21 @@
iD.svg.Turns = function(projection) {
return function(surface, graph, turns) {
function key(turn) {
return iD.Entity.key(graph.entity(turn.from.node)) + ',' +
iD.Entity.key(graph.entity(turn.via.node)) + ',' +
iD.Entity.key(graph.entity(turn.to.node)) + ',' +
turn.restriction;
function icon(turn) {
if (!turn.restriction)
return '#icon-restriction-yes';
var restriction = graph.entity(turn.restriction).tags.restriction;
return '#icon-restriction-' +
(!turn.indirect_restriction && /^only_/.test(restriction) ? 'only' : 'no') +
(turn.u ? '-u' : '');
}
var groups = surface.select('.layer-hit').selectAll('g.turn')
.data(turns, key);
.data(turns);
// Enter
var enter = groups.enter().append('g')
.attr('class', 'turn')
.classed('restricted', function (turn) {
return turn.restriction;
});
.attr('class', 'turn');
var nEnter = enter.filter(function (turn) { return !turn.u; });
@@ -27,8 +26,7 @@ iD.svg.Turns = function(projection) {
nEnter.append('use')
.attr('transform', 'translate(-12, -12)')
.attr('clip-path', 'url(#clip-square-45)')
.attr('xlink:href', function(turn) { return '#icon-restriction-' + (turn.restriction ? 'no' : 'yes'); });
.attr('clip-path', 'url(#clip-square-45)');
var uEnter = enter.filter(function (turn) { return turn.u; });
@@ -37,21 +35,24 @@ iD.svg.Turns = function(projection) {
uEnter.append('use')
.attr('transform', 'translate(-16, -16)')
.attr('clip-path', 'url(#clip-square-32)')
.attr('xlink:href', function(turn) { return '#icon-restriction-' + (turn.restriction ? 'no' : 'yes') + '-u'; });
.attr('clip-path', 'url(#clip-square-32)');
// Update
groups.attr('transform', function (turn) {
var v = graph.entity(turn.via.node),
t = graph.entity(turn.to.node),
a = iD.geo.angle(v, t, projection),
p = projection(v.loc),
r = turn.u ? 0 : 60;
groups
.attr('transform', function (turn) {
var v = graph.entity(turn.via.node),
t = graph.entity(turn.to.node),
a = iD.geo.angle(v, t, projection),
p = projection(v.loc),
r = turn.u ? 0 : 60;
return 'translate(' + (r * Math.cos(a) + p[0]) + ',' + (r * Math.sin(a) + p[1]) + ')' +
'rotate(' + a * 180 / Math.PI + ')';
});
return 'translate(' + (r * Math.cos(a) + p[0]) + ',' + (r * Math.sin(a) + p[1]) + ')' +
'rotate(' + a * 180 / Math.PI + ')';
});
groups.select('use')
.attr('xlink:href', icon);
groups.select('rect');
groups.select('circle');
+44 -4
View File
@@ -328,9 +328,49 @@ describe("iD.geo.Intersection", function() {
restriction: 'r'
});
});
});
// 'no' vs 'only'
// Self-intersections
// Incomplete relations
it("restricts turns affected by an only_* restriction relation", function() {
// u====*~~~~v
// |
// w
var graph = iD.Graph([
iD.Node({id: 'u'}),
iD.Node({id: 'v'}),
iD.Node({id: 'w'}),
iD.Node({id: '*'}),
iD.Way({id: '=', nodes: ['u', '*'], tags: {highway: 'residential'}}),
iD.Way({id: '~', nodes: ['v', '*'], tags: {highway: 'residential'}}),
iD.Way({id: '-', nodes: ['w', '*'], tags: {highway: 'residential'}}),
iD.Relation({id: 'r', tags: {type: 'restriction', restriction: 'only_right_turn'}, members: [
{id: '=', role: 'from', type: 'way'},
{id: '-', role: 'to', type: 'way'},
{id: '*', role: 'via', type: 'node'}
]})
]),
turns = iD.geo.Intersection(graph, '*').turns('u');
expect(turns.length).to.eql(3);
expect(turns[0]).to.eql({
from: {node: 'u', way: '='},
via: {node: '*'},
to: {node: 'v', way: '~'},
restriction: 'r',
indirect_restriction: true
});
expect(turns[1]).to.eql({
from: {node: 'u', way: '='},
via: {node: '*'},
to: {node: 'w', way: '-'},
restriction: 'r'
});
expect(turns[2]).to.eql({
from: {node: 'u', way: '='},
via: {node: '*'},
to: {node: 'u', way: '='},
restriction: 'r',
indirect_restriction: true,
u: true
});
});
});
});