node.js gives completely different result
- Dominant language
- JavaScript
- Stars
- 1.3k
- Forks
- 322
- PR merge metrics
- No merged PRs in 30d
Description
tj.kml(kml); gives different result in node.js and different result in browser.
ExtendedData comes out correct in browser but its messed up in node.js.
Here is my code for node.js.
`var tj = require('toGeoJSON'),
xpath = require('xpath'),
DOMParser = require('xmldom').DOMParser;
const fs = require('fs');
filePath = 'Bore.kml'
fs.exists(filePath, function (exists) {
fs.readFile(filePath, { encoding: "utf8" }, function (err, data) {
if (data) {
console.log('JSON Conversion Started');
var kml = new DOMParser().parseFromString(data, 'text/xml');
var convertedJSON = tj.kml(kml);
var value = JSON.stringify(convertedJSON, null, 4);
console.log(value);
}
})
})`
Result:
`{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "GeometryCollection",
"geometries": [
{
"type": "LineString",
"coordinates": [
[
-97.724896,
35.467413
],
[
-97.7248978704,
35.4674677778
],
[
-97.7248997407,
35.4675235956
],
[
-97.7249016111,
35.4675773333
],
[
-97.7249034815,
35.4676321111
],
[
-97.7249053519,
35.4676868889
],
[
-97.7249072222,
35.4677416667
],
[
-97.7249090926,
35.4677964444
],
[
-97.724910963,
35.4678512222
],
[
-97.7249128333,
35.467906
],
[
-97.7249147037,
35.4679607778
],
[
-97.7249165741,
35.4680155556
],
[
-97.7249184444,
35.4680703333
],
[
-97.7249203148,
35.4681251111
],
[
-97.7249221852,
35.4681798889
],
[
-97.7249240556,
35.4682346667
],
[
-97.7249259259,
35.4682894444
],
[
-97.7249277963,
35.4683442222
],
[
-97.7249296667,
35.468399
],
[
-97.724931537,
35.4684537778
],
[
-97.7249334074,
35.4685085556
],
[
-97.7249352778,
35.4685633333
],
[
-97.7249371481,
35.4686181111
],
[
-97.7249390185,
35.4686728889
],
[
-97.7249408889,
35.4687276667
],
[
-97.7249427593,
35.4687824444
],
[
-97.7249446296,
35.4688372222
],
[
-97.7249465,
35.468892
],
[
-97.7249483704,
35.4689467778
],
[
-97.7249502407,
35.4690015556
],
[
-97.7249521111,
35.4690563333
],
[
-97.7249539815,
35.4691111111
],
[
-97.7249558519,
35.4691658889
],
[
-97.7249577222,
35.4692206667
],
[
-97.7249595926,
35.4692754444
],
[
-97.724961463,
35.4693302222
],
[
-97.7249633333,
35.469385
],
[
-97.7249652037,
35.4694397778
],
[
-97.7249670741,
35.4694945556
],
[
-97.7249689444,
35.4695493333
],
[
-97.7249708148,
35.4696041111
],
[
-97.7249726852,
35.4696588889
],
[
-97.7249745556,
35.4697136667
],
[
-97.7249764259,
35.4697684444
],
[
-97.7249782963,
35.4698232222
],
[
-97.7249801667,
35.469878
],
[
-97.724982037,
35.4699327778
],
[
-97.7249839074,
35.4699875556
],
[
-97.7249857778,
35.4700423333
],
[
-97.7249876481,
35.4700971111
],
[
-97.7249895185,
35.4701518889
],
[
-97.7249913889,
35.4702066667
],
[
-97.7249932593,
35.4702614444
],
[
-97.7249951296,
35.4703162222
],
[
-97.724997,
35.470371
]
]
},
{
"type": "Point",
"coordinates": [
-97.724896,
35.467413
]
},
{
"type": "Point",
"coordinates": [
-97.7248978704,
35.4674677778
]
}
]
},
"properties": {
"name": "Pipe 1",
"styleUrl": "#pipeIcon",
"styleHash": "-3ba9ecd8",
"description": "Bore path",
"Pipe": "Pipe 2 of 55",
"Job": "Superior-I-40-Bore",
"Distance (ft in)": "9' 10\"",
"Pitch (%)": "-18.0\n \n \n 6' 5\"\n \n \n 1' 9\"\n \n \n 10\"\n \n \n Tue Feb 19 11:02:13 2013 GMT\n \n \n 35.4674677778\n \n \n -97.7248978704\n \n \n 4360' 3\"\n \n \n 359.0\n \n \n \n -97.7248978704,35.4674677778\n \n \n \n \n Paths\n Bore path\n \n Bore Path\n \n \n 0\n \n -97.724896,35.467413\n -97.7248978704,35.4674677778\n -97.7248997407,35.4675235956\n -97.7249016111,35.4675773333\n -97.7249034815,35.4676321111\n -97.7249053519,35.4676868889\n -97.7249072222,35.4677416667\n -97.7249090926,35.4677964444\n -97.724910963,35.4678512222\n -97.7249128333,35.467906\n -97.7249147037,35.4679607778\n -97.7249165741,35.4680155556\n -97.7249184444,35.4680703333\n -97.7249203148,35.4681251111\n -97.7249221852,35.4681798889\n -97.7249240556,35.4682346667\n -97.7249259259,35.4682894444\n -97.7249277963,35.4683442222\n -97.7249296667,35.468399\n -97.724931537,35.4684537778\n -97.7249334074,35.4685085556\n -97.7249352778,35.4685633333\n -97.7249371481,35.4686181111\n -97.7249390185,35.4686728889\n -97.7249408889,35.4687276667\n -97.7249427593,35.4687824444\n -97.7249446296,35.4688372222\n -97.7249465,35.468892\n -97.7249483704,35.4689467778\n -97.7249502407,35.4690015556\n -97.7249521111,35.4690563333\n -97.7249539815,35.4691111111\n -97.7249558519,35.4691658889\n -97.7249577222,35.4692206667\n -97.7249595926,35.4692754444\n -97.724961463,35.4693302222\n -97.7249633333,35.469385\n -97.7249652037,35.4694397778\n -97.7249670741,35.4694945556\n -97.7249689444,35.4695493333\n -97.7249708148,35.4696041111\n -97.7249726852,35.4696588889\n -97.7249745556,35.4697136667\n -97.7249764259,35.4697684444\n -97.7249782963,35.4698232222\n -97.7249801667,35.469878\n -97.724982037,35.4699327778\n -97.7249839074,35.4699875556\n -97.7249857778,35.4700423333\n -97.7249876481,35.4700971111\n -97.7249895185,35.4701518889\n -97.7249913889,35.4702066667\n -97.7249932593,35.4702614444\n -97.7249951296,35.4703162222\n -97.724997,35.470371\n \n \n \n \n \n",
"Depth (ft in)": "6' 5\"",
"Depth\nRelative (ft in)": "1' 9\"",
"Elevation\nRelative (ft in)": "10\"",
"Timestamp": "Tue Feb 19 11:02:13 2013 GMT",
"Latitude (degrees)": "35.4674677778",
"Longitude (degrees)": "-97.7248978704",
"Elevation (ft in)": "4360' 3\"",
"Heading (degrees)": "359.0"
}
},
{
"type": "Feature",
"geometry": {
"type": "GeometryCollection",
"geometries": [
{
"type": "LineString",
"coordinates": [
[
-97.724896,
35.467413
],
[
-97.7248978704,
35.4674677778
],
[
-97.7248997407,
35.4675235956
],
[
-97.7249016111,
35.4675773333
],
[
-97.7249034815,
35.4676321111
],
[
-97.7249053519,
35.4676868889
],
[
-97.7249072222,
35.4677416667
],
[
-97.7249090926,
35.4677964444
],
[
-97.724910963,
35.4678512222
],
[
-97.7249128333,
35.467906
],
[
-97.7249147037,
35.4679607778
],
[
-97.7249165741,
35.4680155556
],
[
-97.7249184444,
35.4680703333
],
[
-97.7249203148,
35.4681251111
],
[
-97.7249221852,
35.4681798889
],
[
-97.7249240556,
35.4682346667
],
[
-97.7249259259,
35.4682894444
],
[
-97.7249277963,
35.4683442222
],
[
-97.7249296667,
35.468399
],
[
-97.724931537,
35.4684537778
],
[
-97.7249334074,
35.4685085556
],
[
-97.7249352778,
35.4685633333
],
[
-97.7249371481,
35.4686181111
],
[
-97.7249390185,
35.4686728889
],
[
-97.7249408889,
35.4687276667
],
[
-97.7249427593,
35.4687824444
],
[
-97.7249446296,
35.4688372222
],
[
-97.7249465,
35.468892
],
[
-97.7249483704,
35.4689467778
],
[
-97.7249502407,
35.4690015556
],
[
-97.7249521111,
35.4690563333
],
[
-97.7249539815,
35.4691111111
],
[
-97.7249558519,
35.4691658889
],
[
-97.7249577222,
35.4692206667
],
[
-97.7249595926,
35.4692754444
],
[
-97.724961463,
35.4693302222
],
[
-97.7249633333,
35.469385
],
[
-97.7249652037,
35.4694397778
],
[
-97.7249670741,
35.4694945556
],
[
-97.7249689444,
35.4695493333
],
[
-97.7249708148,
35.4696041111
],
[
-97.7249726852,
35.4696588889
],
[
-97.7249745556,
35.4697136667
],
[
-97.7249764259,
35.4697684444
],
[
-97.7249782963,
35.4698232222
],
[
-97.7249801667,
35.469878
],
[
-97.724982037,
35.4699327778
],
[
-97.7249839074,
35.4699875556
],
[
-97.7249857778,
35.4700423333
],
[
-97.7249876481,
35.4700971111
],
[
-97.7249895185,
35.4701518889
],
[
-97.7249913889,
35.4702066667
],
[
-97.7249932593,
35.4702614444
],
[
-97.7249951296,
35.4703162222
],
[
-97.724997,
35.470371
]
]
},
{
"type": "Point",
"coordinates": [
-97.7248978704,
35.4674677778
]
}
]
},
"properties": {
"name": "Pipe 2",
"styleUrl": "#pipeIcon",
"styleHash": "-3ba9ecd8",
"description": "Bore path",
"Pipe": "Pipe 2 of 55",
"Job": "Superior-I-40-Bore",
"Distance (ft in)": "9' 10\"",
"Pitch (%)": "-18.0\n \n \n 6' 5\"\n \n \n 1' 9\"\n \n \n 10\"\n \n \n Tue Feb 19 11:02:13 2013 GMT\n \n \n 35.4674677778\n \n \n -97.7248978704\n \n \n 4360' 3\"\n \n \n 359.0\n \n \n \n -97.7248978704,35.4674677778\n \n \n \n \n Paths\n Bore path\n \n Bore Path\n \n \n 0\n \n -97.724896,35.467413\n -97.7248978704,35.4674677778\n -97.7248997407,35.4675235956\n -97.7249016111,35.4675773333\n -97.7249034815,35.4676321111\n -97.7249053519,35.4676868889\n -97.7249072222,35.4677416667\n -97.7249090926,35.4677964444\n -97.724910963,35.4678512222\n -97.7249128333,35.467906\n -97.7249147037,35.4679607778\n -97.7249165741,35.4680155556\n -97.7249184444,35.4680703333\n -97.7249203148,35.4681251111\n -97.7249221852,35.4681798889\n -97.7249240556,35.4682346667\n -97.7249259259,35.4682894444\n -97.7249277963,35.4683442222\n -97.7249296667,35.468399\n -97.724931537,35.4684537778\n -97.7249334074,35.4685085556\n -97.7249352778,35.4685633333\n -97.7249371481,35.4686181111\n -97.7249390185,35.4686728889\n -97.7249408889,35.4687276667\n -97.7249427593,35.4687824444\n -97.7249446296,35.4688372222\n -97.7249465,35.468892\n -97.7249483704,35.4689467778\n -97.7249502407,35.4690015556\n -97.7249521111,35.4690563333\n -97.7249539815,35.4691111111\n -97.7249558519,35.4691658889\n -97.7249577222,35.4692206667\n -97.7249595926,35.4692754444\n -97.724961463,35.4693302222\n -97.7249633333,35.469385\n -97.7249652037,35.4694397778\n -97.7249670741,35.4694945556\n -97.7249689444,35.4695493333\n -97.7249708148,35.4696041111\n -97.7249726852,35.4696588889\n -97.7249745556,35.4697136667\n -97.7249764259,35.4697684444\n -97.7249782963,35.4698232222\n -97.7249801667,35.469878\n -97.724982037,35.4699327778\n -97.7249839074,35.4699875556\n -97.7249857778,35.4700423333\n -97.7249876481,35.4700971111\n -97.7249895185,35.4701518889\n -97.7249913889,35.4702066667\n -97.7249932593,35.4702614444\n -97.7249951296,35.4703162222\n -97.724997,35.470371\n \n \n \n \n \n",
"Depth (ft in)": "6' 5\"",
"Depth\nRelative (ft in)": "1' 9\"",
"Elevation\nRelative (ft in)": "10\"",
"Timestamp": "Tue Feb 19 11:02:13 2013 GMT",
"Latitude (degrees)": "35.4674677778",
"Longitude (degrees)": "-97.7248978704",
"Elevation (ft in)": "4360' 3\"",
"Heading (degrees)": "359.0"
}
},
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[
-97.724896,
35.467413
],
[
-97.7248978704,
35.4674677778
],
[
-97.7248997407,
35.4675235956
],
[
-97.7249016111,
35.4675773333
],
[
-97.7249034815,
35.4676321111
],
[
-97.7249053519,
35.4676868889
],
[
-97.7249072222,
35.4677416667
],
[
-97.7249090926,
35.4677964444
],
[
-97.724910963,
35.4678512222
],
[
-97.7249128333,
35.467906
],
[
-97.7249147037,
35.4679607778
],
[
-97.7249165741,
35.4680155556
],
[
-97.7249184444,
35.4680703333
],
[
-97.7249203148,
35.4681251111
],
[
-97.7249221852,
35.4681798889
],
[
-97.7249240556,
35.4682346667
],
[
-97.7249259259,
35.4682894444
],
[
-97.7249277963,
35.4683442222
],
[
-97.7249296667,
35.468399
],
[
-97.724931537,
35.4684537778
],
[
-97.7249334074,
35.4685085556
],
[
-97.7249352778,
35.4685633333
],
[
-97.7249371481,
35.4686181111
],
[
-97.7249390185,
35.4686728889
],
[
-97.7249408889,
35.4687276667
],
[
-97.7249427593,
35.4687824444
],
[
-97.7249446296,
35.4688372222
],
[
-97.7249465,
35.468892
],
[
-97.7249483704,
35.4689467778
],
[
-97.7249502407,
35.4690015556
],
[
-97.7249521111,
35.4690563333
],
[
-97.7249539815,
35.4691111111
],
[
-97.7249558519,
35.4691658889
],
[
-97.7249577222,
35.4692206667
],
[
-97.7249595926,
35.4692754444
],
[
-97.724961463,
35.4693302222
],
[
-97.7249633333,
35.469385
],
[
-97.7249652037,
35.4694397778
],
[
-97.7249670741,
35.4694945556
],
[
-97.7249689444,
35.4695493333
],
[
-97.7249708148,
35.4696041111
],
[
-97.7249726852,
35.4696588889
],
[
-97.7249745556,
35.4697136667
],
[
-97.7249764259,
35.4697684444
],
[
-97.7249782963,
35.4698232222
],
[
-97.7249801667,
35.469878
],
[
-97.724982037,
35.4699327778
],
[
-97.7249839074,
35.4699875556
],
[
-97.7249857778,
35.4700423333
],
[
-97.7249876481,
35.4700971111
],
[
-97.7249895185,
35.4701518889
],
[
-97.7249913889,
35.4702066667
],
[
-97.7249932593,
35.4702614444
],
[
-97.7249951296,
35.4703162222
],
[
-97.724997,
35.470371
]
]
},
"properties": {
"name": "Bore Path"
}
}
]
}`
Contributor guide
Research direction
Start with the Node.js example in the issue, especially the tj.kml(kml) entry point and the xmldom DOMParser input. Compare its ExtendedData output with the browser result and determine which result should be expected. Done means the Node.js conversion matches the browser conversion for the reported KML input.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100