Closed spaasis closed 8 years ago
Hi Simo,
This library only parses longitude and latitude fields - other parts of the file should be represented verbatim as strings. Can you provide a snippet of the input information, including the header line?
Thanks,
Tom
@tmcw Input (time highlighted): piste,nimi,x_gk25,y_gk25,suunta,aika,vuosi,ha,pa,ka,ra,la,mp,rv,autot A01,LAUTTASAAREN SILTA,25494426,6672169,1,00:00,2011,76,5,1,0,5,0,0,87 A01,LAUTTASAAREN SILTA,25494426,6672169,1,01:00,2011,65,5,1,0,4,0,0,75
Output properties:
**aika**
**NaN**
autot
87
ha
76
ka
1
la
5
mp
0
nimi
"LAUTTASAAREN SILTA"
pa
5
piste
"A01"
ra
0
rv
0
suunta
1
vuosi
2011
If I add some characters at the beginning of the time, for example "a00:00a", the result is as expected.
I'm using 5.0.0. I'll test with the newest npm version to see if this has already been fixed EDIT: 5.0.2 has the same behavior
This input works correctly for me, on both versions, but this data doesn't have longitude or latitude values or headers in it, so I'm not sure why it's being run through csv2geojson in the first place.
@tmcw Oh sorry, forgot to specify. x_gk25,y_gk25 are the lat-lon fields that later get converted to their proper WGS84 presentations
Specifying those fields as longitude and latitude, I get:
~/src/csv2geojson〉./csv2geojson test/data/nan.csv --lon=x_gk25 --lat=y_gk25
(node) sys is deprecated. Use util instead.
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"piste": "A01",
"nimi": "LAUTTASAAREN SILTA",
"suunta": "1",
"aika": "00:00",
"vuosi": "2011",
"ha": "76",
"pa": "5",
"ka": "1",
"ra": "0",
"la": "5",
"mp": "0",
"rv": "0",
"autot": "87"
},
"geometry": {
"type": "Point",
"coordinates": [
25494426,
6672169
]
}
},
{
"type": "Feature",
"properties": {
"piste": "A01",
"nimi": "LAUTTASAAREN SILTA",
"suunta": "1",
"aika": "01:00",
"vuosi": "2011",
"ha": "65",
"pa": "5",
"ka": "1",
"ra": "0",
"la": "4",
"mp": "0",
"rv": "0",
"autot": "75"
},
"geometry": {
"type": "Point",
"coordinates": [
25494426,
6672169
]
}
}
]
}
Not seeing any NaNs in the output, or anywhere in the code that would manipulate those values into NaNs.
Okay, there must be something else going on here..
If I do JSON.stringify() on the first feature, the output is:
{"type":"Feature","properties":{"piste":"A01","nimi":"LAUTTASAAREN SILTA","suunta":"1","aika":"00:00","vuosi":"2011","ha":"76","pa":"5","ka":"1","ra":"0","la":"5","mp":"0","rv":"0","autot":"87"},"geometry":{"type":"Point","coordinates":[25494426,6672169]}}
So the time is actually as it should. For some reason, my debuggers see it as NaN. I'll figure out what's going on and post the result here. But clearly this is not a csv2geojson issue, so I'll close this.
EDIT: @tmcw yeah, thanks for your help!
EDIT2: So, the issue was caused by a function that later sets the appropriate types for the GeoJSON features, which wrongly determined the hh:mm to be a number. Why I believed it was a csv2geojson error was that I was using console.log to see what the output was, but although it was called before the typing function, it's output was printed out of order, therefore containing the NaNs.
Hi,
I have a CSV with a time field in the 24h format, for example 01:00. On the resulting GeoJSON the corresponding property value is NaN, instead of the expected "01:00".