-
Notifications
You must be signed in to change notification settings - Fork 74
/
line-to-area-cases.js
219 lines (198 loc) · 10.9 KB
/
line-to-area-cases.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
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 () {
describe('shear wall (AA011) OSM to OGR translations', function() {
it('should handle OSM to TDSv40', function() {
var trans2tds40 = server.handleInputs({
osm: "<osm version='0.6' generator='JOSM'><way id='-39158' visible='true'><nd ref='-39156' /><nd ref='-39157' /><tag k='natural' v='shear_wall' /></way></osm>",
method: 'POST',
translation: 'TDSv40',
path: '/translateTo'
});
xml2js.parseString(trans2tds40, function(err, result) {
if (err) console.log(err);
assert.equal(result.osm.way[0].tag[0].$.k, "F_CODE");
assert.equal(result.osm.way[0].tag[0].$.v, "AA011");
});
});
it('should handle OSM to TDSv61', function() {
var trans2tds61 = server.handleInputs({
osm: "<osm version='0.6' generator='JOSM'><way id='-39158' visible='true'><nd ref='-39156' /><nd ref='-39157' /><tag k='natural' v='shear_wall' /></way></osm>",
method: 'POST',
translation: 'TDSv61',
path: '/translateTo'
});
xml2js.parseString(trans2tds61, function(err, result) {
if (err) console.log(err);
assert.equal(result.osm.way[0].tag[0].$.k, "F_CODE");
assert.equal(result.osm.way[0].tag[0].$.v, "AA011");
});
});
// BD100 is Structural Pile.
// AA011 is not a valid MGCP F_CODE
it('should not find OSM to MGCP translation', function() {
var trans2mgcp = server.handleInputs({
osm: "<osm version='0.6' generator='JOSM'><way id='-39158' visible='true'><nd ref='-39156' /><nd ref='-39157' /><tag k='structural_pile' v='yes' /></way></osm>",
method: 'POST',
translation: 'MGCP',
path: '/translateTo'
});
xml2js.parseString(trans2mgcp, function(err, result) {
if (err) console.log(err);
assert.equal(result.osm.way[0].tag[0].$.k, "error");
assert.equal(result.osm.way[0].tag[0].$.v, "Line geometry is not valid for BD100 in MGCP TRD4");
});
});
it('should handle OSM to GGDMv30', function() {
var trans2ggdmv30 = server.handleInputs({
osm: "<osm version='0.6' generator='JOSM'><way id='-39158' visible='true'><nd ref='-39156' /><nd ref='-39157' /><tag k='natural' v='shear_wall' /></way></osm>",
method: 'POST',
translation: 'GGDMv30',
path: '/translateTo'
});
xml2js.parseString(trans2ggdmv30, function(err, result) {
if (err) console.log(err);
assert.equal(result.osm.way[0].tag[0].$.k, "F_CODE");
assert.equal(result.osm.way[0].tag[0].$.v, "AA011")
})
})
});
describe('excavating machine (AF050) OSM to OGR translation', function() {
it('should handle OSM to TDSv40', function() {
var trans2tds40 = server.handleInputs({
osm: "<osm version='0.6' generator='JOSM'> <way id='-39012' visible='true'><nd ref='-39010' /><nd ref='-39011' /><tag k='ele:max' v='324' /><tag k='man_made' v='excavating_machine' /><tag k='uuid' v='{9c1b7b24-c3c9-4ef1-aaf0-1d279f4f232d}' /></way></osm>",
method: 'POST',
translation: 'TDSv40',
path: '/translateTo'
});
xml2js.parseString(trans2tds40, function(err, result) {
if (err) console.log(err);
assert.equal(result.osm.way[0].tag[0].$.k, "F_CODE");
assert.equal(result.osm.way[0].tag[0].$.v, "AF050");
});
});
it('should handle OSM to TDSv61', function() {
var trans2tds61 = server.handleInputs({
osm: "<osm version='0.6' generator='JOSM'> <way id='-39012' visible='true'><nd ref='-39010' /><nd ref='-39011' /><tag k='ele:max' v='324' /><tag k='man_made' v='excavating_machine' /><tag k='uuid' v='{9c1b7b24-c3c9-4ef1-aaf0-1d279f4f232d}' /></way></osm>",
method: 'POST',
translation: 'TDSv61',
path: '/translateTo'
});
xml2js.parseString(trans2tds61, function(err, result) {
if (err) console.log(err);
assert.equal(result.osm.way[0].tag[0].$.k, "F_CODE");
assert.equal(result.osm.way[0].tag[0].$.v, "AF050");
});
});
// AF050 is not a valid MGCP F_CODE
it('should handle OSM to MGCP', function() {
var trans2mgcp = server.handleInputs({
osm: "<osm version='0.6' generator='JOSM'> <way id='-39012' visible='true'><nd ref='-39010' /><nd ref='-39011' /><tag k='ele:max' v='324' /><tag k='landuse' v='quarry' /><tag k='uuid' v='{9c1b7b24-c3c9-4ef1-aaf0-1d279f4f232d}' /></way></osm>",
method: 'POST',
translation: 'MGCP',
path: '/translateTo'
});
xml2js.parseString(trans2mgcp, function(err, result) {
if (err) console.log(err);
assert.equal(result.osm.way[0].tag[0].$.k, "error");
assert.equal(result.osm.way[0].tag[0].$.v, "Line geometry is not valid for AA012 in MGCP TRD4");
});
});
it('should handle OSM to GGDMv30', function() {
var trans2ggdmv30 = server.handleInputs({
osm: "<osm version='0.6' generator='JOSM'> <way id='-39012' visible='true'><nd ref='-39010' /><nd ref='-39011' /><tag k='ele:max' v='324' /><tag k='man_made' v='excavating_machine' /><tag k='uuid' v='{9c1b7b24-c3c9-4ef1-aaf0-1d279f4f232d}' /></way></osm>",
method: 'POST',
translation: 'GGDMv30',
path: '/translateTo'
});
xml2js.parseString(trans2ggdmv30, function(err, result) {
if (err) console.log(err);
assert.equal(result.osm.way[0].tag[0].$.k, "F_CODE");
assert.equal(result.osm.way[0].tag[0].$.v, "AF050")
})
})
})
describe('watercourse_crossing (AQ111) OSM to OGR translation', function() {
it('should handle OSM to TDSv40', function() {
var trans2tds40 = server.handleInputs({
osm: "<osm version='0.6' generator='JOSM'><way id='-39104' visible='true'><nd ref='-39102' /><nd ref='-39103' /><nd ref='-39105' /><tag k='man_made' v='watercourse_crossing' /><tag k='uuid' v='{10ffeed9-b866-412d-8d77-2378d2147a03}' /></way></osm>",
method: 'POST',
translation: 'TDSv40',
path: '/translateTo'
});
xml2js.parseString(trans2tds40, function(err, result) {
if (err) console.log(err);
assert.equal(result.osm.way[0].tag[0].$.k, "F_CODE");
assert.equal(result.osm.way[0].tag[0].$.v, "AQ111");
});
});
it('should handle OSM to TDSv61', function() {
var trans2tds61 = server.handleInputs({
osm: "<osm version='0.6' generator='JOSM'><way id='-39104' visible='true'><nd ref='-39102' /><nd ref='-39103' /><nd ref='-39105' /><tag k='man_made' v='watercourse_crossing' /><tag k='uuid' v='{10ffeed9-b866-412d-8d77-2378d2147a03}' /></way></osm>",
method: 'POST',
translation: 'TDSv61',
path: '/translateTo'
});
xml2js.parseString(trans2tds61, function(err, result) {
if (err) console.log(err);
assert.equal(result.osm.way[0].tag[0].$.k, "error");
assert.equal(result.osm.way[0].tag[0].$.v, 'Line geometry is not valid for AQ111 in TDSv61');
});
});
it('should handle OSM to GGDMv30', function() {
var trans2ggdmv30 = server.handleInputs({
osm: "<osm version='0.6' generator='JOSM'><way id='-39104' visible='true'><nd ref='-39102' /><nd ref='-39103' /><nd ref='-39105' /><tag k='man_made' v='watercourse_crossing' /><tag k='uuid' v='{10ffeed9-b866-412d-8d77-2378d2147a03}' /></way></osm>",
method: 'POST',
translation: 'GGDMv30',
path: '/translateTo'
});
xml2js.parseString(trans2ggdmv30, function(err, result) {
if (err) console.log(err);
assert.equal(result.osm.way[0].tag[0].$.k, "error");
assert.equal(result.osm.way[0].tag[0].$.v, "Line geometry is not valid for AQ111 in GGDMv30");
})
})
})
describe('conveyer:type=bucket: (AF021) OSM to OGR translation', function() {
it('should handle OSM to TDSv40', function() {
var trans2tds40 = server.handleInputs({
osm: '<osm version="0.6" generator="hootenanny" srs="+epsg:4326" schema="OSM"><bounds minlat="0" minlon="0" maxlat="0" maxlon="0"/><way visible="true" id="-39098" timestamp="1970-01-01T00:00:00Z" version="1"><tag k="conveyer:type" v="bucket:"/></way></osm>',
method: 'POST',
translation: 'TDSv40',
path: '/translateTo'
});
xml2js.parseString(trans2tds40, function(err, result) {
if (err) console.log(err);
});
});
it('should handle OSM to TDSv61', function() {
var trans2tds40 = server.handleInputs({
osm: '<osm version="0.6" generator="hootenanny" srs="+epsg:4326" schema="OSM"><bounds minlat="0" minlon="0" maxlat="0" maxlon="0"/><way visible="true" id="-39098" timestamp="1970-01-01T00:00:00Z" version="1"><tag k="conveyer:type" v="bucket:"/></way></osm>',
method: 'POST',
translation: 'TDSv61',
path: '/translateTo'
});
xml2js.parseString(trans2tds40, function(err, result) {
if (err) console.log(err);
});
});
it('should handle OSM to TDSv61', function() {
var trans2tds40 = server.handleInputs({
osm: '<osm version="0.6" generator="hootenanny" srs="+epsg:4326" schema="OSM"><bounds minlat="0" minlon="0" maxlat="0" maxlon="0"/><way visible="true" id="-39098" timestamp="1970-01-01T00:00:00Z" version="1"><tag k="conveyer:type" v="bucket:"/></way></osm>',
method: 'POST',
translation: 'MGCP',
path: '/translateTo'
});
xml2js.parseString(trans2tds40, function(err, result) {
if (err) console.log(err);
});
});
})
});