mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-31 01:09:22 +02:00
Add Entity#geometry, use in inspector
Fixes the icon for areas, but breaks it for vertices. Needs a big-vertex sprite.
This commit is contained in:
@@ -3,5 +3,9 @@ iD.Node = iD.Entity.extend({
|
||||
|
||||
extent: function() {
|
||||
return [this.loc, this.loc];
|
||||
},
|
||||
|
||||
geometry: function() {
|
||||
return this._poi ? 'point' : 'vertex';
|
||||
}
|
||||
});
|
||||
|
||||
@@ -36,5 +36,9 @@ iD.Way = iD.Entity.extend({
|
||||
this.tags.area !== 'no' &&
|
||||
!this.tags.highway &&
|
||||
!this.tags.barrier);
|
||||
},
|
||||
|
||||
geometry: function() {
|
||||
return this.isArea() ? 'area' : 'line';
|
||||
}
|
||||
});
|
||||
|
||||
@@ -61,18 +61,13 @@ iD.Inspector = function() {
|
||||
var h2 = selection.append('h2');
|
||||
|
||||
h2.append('span')
|
||||
.attr('class', function(d) {
|
||||
var icons = { way: 'line', node: 'point' };
|
||||
return 'icon big icon-pre-text big-' + icons[d.type];
|
||||
});
|
||||
.attr('class', 'icon big icon-pre-text big-' + entity.geometry());
|
||||
|
||||
h2.append('span')
|
||||
.text(entity.friendlyName());
|
||||
|
||||
selection.append('a')
|
||||
.attr('href', function() {
|
||||
return 'http://www.openstreetmap.org/browse/' + entity.type + '/' + entity.osmId();
|
||||
})
|
||||
.attr('href', 'http://www.openstreetmap.org/browse/' + entity.type + '/' + entity.osmId())
|
||||
.text('View on OSM');
|
||||
|
||||
if (entity.type === 'way') {
|
||||
@@ -82,7 +77,7 @@ iD.Inspector = function() {
|
||||
.on('click', function() { event.changeWayDirection(entity); });
|
||||
}
|
||||
|
||||
if (entity.type === 'node' && !entity._poi) {
|
||||
if (entity.geometry() === 'vertex') {
|
||||
selection.append('a')
|
||||
.attr('href', '#')
|
||||
.text('Split Way')
|
||||
|
||||
@@ -36,4 +36,14 @@ describe('iD.Node', function () {
|
||||
expect(iD.Node({loc: [0, 0]}).intersects([[100, 90], [180, -90]])).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#geometry", function () {
|
||||
it("returns 'vertex' if the node is not a point", function () {
|
||||
expect(iD.Node().geometry()).to.equal('vertex');
|
||||
});
|
||||
|
||||
it("returns 'point' if the node is a point", function () {
|
||||
expect(iD.Node({_poi: true}).geometry()).to.equal('point');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -110,4 +110,14 @@ describe('iD.Way', function() {
|
||||
expect(iD.Way({tags: { highway: 'residential' }, nodes: ['n1', 'n1']}).isArea()).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#geometry", function() {
|
||||
it("returns 'line' when the way is not an area", function () {
|
||||
expect(iD.Way().geometry()).to.equal('line');
|
||||
});
|
||||
|
||||
it("returns 'area' when the way is an area", function () {
|
||||
expect(iD.Way({tags: { area: 'yes' }}).geometry()).to.equal('area');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user