Replace Entity.{lat,lon} with Entity.loc

Fixes #189
This commit is contained in:
John Firebaugh
2012-12-04 22:29:57 -05:00
parent ce4c6c4fec
commit 551a2df24e
12 changed files with 57 additions and 72 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ describe('GeoJSON', function() {
describe('#mapping', function() {
it('should be able to map a node to geojson', function() {
expect(iD.format.GeoJSON.mapping({ type: 'node', lat: 38, lon: -77 }).geometry.type).to.equal('Point');
expect(iD.format.GeoJSON.mapping({ type: 'node', loc: [-77, 38] }).geometry.type).to.equal('Point');
});
it('should be able to map a way to geojson', function() {
var way = { type: 'way', nodes: [] };
+3 -3
View File
@@ -7,7 +7,7 @@ describe('XML', function() {
describe('#rep', function() {
it('converts a node to jxon', function() {
expect(iD.format.XML.rep({ id: 'n-1', type: 'node', lat: 38, lon: -77 }))
expect(iD.format.XML.rep({ id: 'n-1', type: 'node', loc: [-77, 38] }))
.to.eql({ node : { '@id': '-1', '@lat': 38, '@lon': -77, '@version': 0, tag: [ ] } });
});
it('converts a way to jxon', function() {
@@ -18,8 +18,8 @@ describe('XML', function() {
describe('#mapping', function() {
it('serializes a node to xml', function() {
expect(iD.format.XML.mapping({ id: 'n-1', type: 'node', lat: 38, lon: -77 }))
.to.equal('<node id="-1" lat="38" lon="-77" version="0"/>');
expect(iD.format.XML.mapping({ id: 'n-1', type: 'node', loc: [-77, 38] }))
.to.equal('<node id="-1" lon="-77" lat="38" version="0"/>');
});
it('serializes a way to xml', function() {
+6 -10
View File
@@ -4,8 +4,7 @@ describe('Graph', function() {
it('entity', function() {
var entities = { 'n-1': {
type: 'node',
lat: 30,
lon: -80,
loc: [-80, 30],
id: 'n-1'
}
};
@@ -23,8 +22,7 @@ describe('Graph', function() {
it('#remove', function() {
var entities = { 'n-1': {
type: 'node',
lat: 30,
lon: -80,
loc: [-80, 30],
id: 'n-1'
}
};
@@ -36,21 +34,19 @@ describe('Graph', function() {
it('#replace', function() {
var entities = { 'n-1': {
type: 'node',
lat: 30,
lon: -80,
loc: [-80, 30],
id: 'n-1'
}
};
var replacement = {
type: 'node',
lat: 40,
lon: -80,
loc: [-80, 40],
id: 'n-1'
};
var graph = iD.Graph(entities, 'first graph');
var g2 = graph.replace(replacement, 'Removed node');
expect(graph.entity('n-1').lat).to.equal(30);
expect(g2.entity('n-1').lat).to.equal(40);
expect(graph.entity('n-1').loc[1]).to.equal(30);
expect(g2.entity('n-1').loc[1]).to.equal(40);
});
});
+8 -8
View File
@@ -25,26 +25,26 @@ describe('Util', function() {
describe('geo', function() {
describe('#interp', function() {
it('interpolates halfway', function() {
var a = { lat: 0, lon: 0 },
b = { lat: 10, lon: 10 };
expect(iD.util.geo.interp(a, b, 0.5)).to.eql({ lat: 5, lon: 5});
var a = [0, 0],
b = [10, 10];
expect(iD.util.geo.interp(a, b, 0.5)).to.eql([5, 5]);
});
it('interpolates to one side', function() {
var a = { lat: 0, lon: 0 },
b = { lat: 10, lon: 10 };
expect(iD.util.geo.interp(a, b, 0)).to.eql({ lat: 0, lon: 0});
var a = [0, 0],
b = [10, 10];
expect(iD.util.geo.interp(a, b, 0)).to.eql([0, 0]);
});
});
describe('#nodeIntersect', function() {
it('correctly says that a node is in an extent', function() {
expect(iD.util.geo.nodeIntersect({
lat: 0, lon: 0
loc: [0, 0]
}, [[-180, 90],
[180, -90]])).to.be.true;
});
it('correctly says that a node is outside of an extent', function() {
expect(iD.util.geo.nodeIntersect({
lat: 0, lon: 0
loc: [0, 0]
}, [[100, 90],
[180, -90]])).to.be.false;
});