-
Notifications
You must be signed in to change notification settings - Fork 74
/
tests_to_fix.js
98 lines (71 loc) · 3.08 KB
/
tests_to_fix.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
var assert = require('assert'),
http = require('http'),
xml2js = require('xml2js'),
fs = require('fs'),
httpMocks = require('node-mocks-http'),
osmtogeojson = require('osmtogeojson'),
DOMParser = new require('@xmldom/xmldom').DOMParser
parser = new DOMParser();
var server = require('../TranslationServer.js');
describe('TranslationServer', function () {
var cases = {
GB055: {aeroway: 'runway'},
// AP030: {highway: 'road'},
AL013: {building: 'yes'},
// BH070: {ford: 'yes'},
BH140: {water: 'river'}
}
Object.keys(cases).forEach(k => {
var fcode = k;
var tag = cases[k];
var tagKey = Object.keys(tag)[0];
it('should translate ' + fcode + ' from tdsv61 -> osm -> tdsv61', function() {
var data = '<osm version="0.6" upload="true" generator="hootenanny">\
<node id="-10" lat="0.68307256979" lon="18.45073925651" />\
<node id="-11" lat="0.68341620728" lon="18.45091527847" />\
<node id="-12" lat="0.68306209303" lon="18.45157116983" />\
<node id="-13" lat="0.68270797876" lon="18.45141400736" />\
<way id="-19" >\
<nd ref="-10" /><nd ref="-11" /><nd ref="-12" /><nd ref="-13" /><nd ref="-10" />\
<tag k="F_CODE" v="' + fcode + '"/>\
</way>\
</osm>';
var osm_xml = server.handleInputs({
osm: data,
method: 'POST',
translation: 'TDSv61',
path: '/translateFrom'
});
// console.log(osm_xml);
var xml = parser.parseFromString(osm_xml);
var gj = osmtogeojson(xml);
assert.equal(xml.getElementsByTagName("osm")[0].getAttribute("schema"), "OSM");
var tags = gj.features[0].properties;
assert.equal(tags[tagKey], tag[tagKey]);
var tds_xml = server.handleInputs({
osm: osm_xml,
method: 'POST',
translation: 'TDSv61',
path: '/translateTo'
});
// console.log(tds_xml);
xml = parser.parseFromString(tds_xml);
gj = osmtogeojson(xml);
assert.equal(xml.getElementsByTagName("osm")[0].getAttribute("schema"), "TDSv61");
var tags = gj.features[0].properties;
assert.equal(tags["F_CODE"], fcode);
osm_xml = server.handleInputs({
osm: tds_xml,
method: 'POST',
translation: 'TDSv61',
path: '/translateFrom'
});
// console.log(osm_xml);
var xml = parser.parseFromString(osm_xml);
var gj = osmtogeojson(xml);
assert.equal(xml.getElementsByTagName("osm")[0].getAttribute("schema"), "OSM");
var tags = gj.features[0].properties;
assert.equal(tags[tagKey], tag[tagKey]);
});
});
});