mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-28 19:01:31 +02:00
@@ -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: [] };
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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
@@ -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;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user