Write in file >> problem with json format
Posted: 28 Feb 2019 14:09
Hi all
Have a problem with json format.
Currently, I log GPS data, cellID and LAC and write this info periodically in a text file with action "write to file" >> all works fine.
Text:
{"\n"}{location,locationformat,decimal},{cid},{lac},{getDate(),dateformat,dd.MM.yyyy,HH:mm};
BUT:
Now I should have the data written in this file in geojson format.
So I thought, I can do this like follows (with the variables):
{
"type": "FeatureCollection",
"features": [
{ "type": "Feature",
"geometry": {"type": "Point", "coordinates": {location,locationformat,decimal}},
"properties": {
"cellID": {cid},
"lac": {lac},
"date": {getDate(),dateformat,dd.MM.yyyy,HH:mm}
}
}
]
}
But the only what I get in this file is:
{error}
Anybody can help me? Sorry, I am really not the programmer specialist, therefore upper question.
Thanks a lot in advance!!!
The flow log shows no error:
28.02.2019 14:49:39.432 [4_Save gps cid lac to file] Starting to execute flow '4_Save gps cid lac to file' with Context{global{global_prevloc=Location[gps 46.947200,7.389944 hAcc=48 et=+5d19h34m45s117ms alt=603.4882866595597 vel=0.37801284...},local{flow_name=4_Save gps cid lac to file,trigger=Manual,triggertime=1551361779427}}
28.02.2019 14:49:39.435 [4_Save gps cid lac to file] Start executing action 'Initialisiere Variable Standort: Neuer Standort in location durch GPS, Timeout 2m'
28.02.2019 14:49:47.811 [4_Save gps cid lac to file] Action 'Initialisiere Variable Standort: Neuer Standort in location durch GPS, Timeout 2m' Variable 'location' set to value 'Location[gps 46.947190,7.389795 hAcc=48 et=+5d19h59m54s183ms alt=670.3619005996284 vel=0.11095798 bear=301.61996 vAcc=??? sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=40]}]'.
28.02.2019 14:49:47.828 [4_Save gps cid lac to file] End executing action 'Initialisiere Variable Standort: Neuer Standort in location durch GPS, Timeout 2m'
28.02.2019 14:49:47.841 [4_Save gps cid lac to file] Flow continues executing with the next step.
28.02.2019 14:49:47.842 [4_Save gps cid lac to file] Start executing condition 'Funkzelle GSM: Verbunden mit LACs oder CIDs '
28.02.2019 14:49:47.885 [4_Save gps cid lac to file] End executing condition 'Funkzelle GSM: Verbunden mit LACs oder CIDs ' with return value false
28.02.2019 14:49:47.907 [4_Save gps cid lac to file] Flow continues executing with the next step.
28.02.2019 14:49:47.907 [4_Save gps cid lac to file] Start executing action 'Script: if (isEmpty({global_prevloc})) {global_prevloc = {location} }'
28.02.2019 14:49:47.922 [4_Save gps cid lac to file] End executing action 'Script: if (isEmpty({global_prevloc})) {global_prevloc = {location} }'
28.02.2019 14:49:47.940 [4_Save gps cid lac to file] Flow continues executing with the next step.
28.02.2019 14:49:47.940 [4_Save gps cid lac to file] Start executing condition 'Expression: distance(location, global_prevloc)>1'
28.02.2019 14:49:47.956 [4_Save gps cid lac to file] End executing condition 'Expression: distance(location, global_prevloc)>1' with return value true
28.02.2019 14:49:47.972 [4_Save gps cid lac to file] Flow continues executing with the next step.
28.02.2019 14:49:47.973 [4_Save gps cid lac to file] Start executing action 'In Datei Schreiben: {
"type": "FeatureCollection",
"features": [
{ "type": "Feature",
"geometry": {"type": "Point", "coordinates": {location,locationformat,decimal}},
"properties": {
"cellID": {cid},
"lac": {lac},
"date": {getDate(),dateformat,dd.MM.yyyy,HH:mm}
}
}
]
}
in /storage/emulated/0/Automagic/writelocfile.txt (anhängen)'
28.02.2019 14:49:47.990 [4_Save gps cid lac to file] End executing action 'In Datei Schreiben: {
"type": "FeatureCollection",
"features": [
{ "type": "Feature",
"geometry": {"type": "Point", "coordinates": {location,locationformat,decimal}},
"properties": {
"cellID": {cid},
"lac": {lac},
"date": {getDate(),dateformat,dd.MM.yyyy,HH:mm}
}
}
]
}
in /storage/emulated/0/Automagic/writelocfile.txt (anhängen)'
28.02.2019 14:49:48.005 [4_Save gps cid lac to file] Flow continues executing with the next step.
28.02.2019 14:49:48.006 [4_Save gps cid lac to file] Start executing action 'Script: global_prevloc = location'
28.02.2019 14:49:48.022 [4_Save gps cid lac to file] End executing action 'Script: global_prevloc = location'
28.02.2019 14:49:48.038 [4_Save gps cid lac to file] Flow ended.
Have a problem with json format.
Currently, I log GPS data, cellID and LAC and write this info periodically in a text file with action "write to file" >> all works fine.
Text:
{"\n"}{location,locationformat,decimal},{cid},{lac},{getDate(),dateformat,dd.MM.yyyy,HH:mm};
BUT:
Now I should have the data written in this file in geojson format.
So I thought, I can do this like follows (with the variables):
{
"type": "FeatureCollection",
"features": [
{ "type": "Feature",
"geometry": {"type": "Point", "coordinates": {location,locationformat,decimal}},
"properties": {
"cellID": {cid},
"lac": {lac},
"date": {getDate(),dateformat,dd.MM.yyyy,HH:mm}
}
}
]
}
But the only what I get in this file is:
{error}
Anybody can help me? Sorry, I am really not the programmer specialist, therefore upper question.
Thanks a lot in advance!!!
The flow log shows no error:
28.02.2019 14:49:39.432 [4_Save gps cid lac to file] Starting to execute flow '4_Save gps cid lac to file' with Context{global{global_prevloc=Location[gps 46.947200,7.389944 hAcc=48 et=+5d19h34m45s117ms alt=603.4882866595597 vel=0.37801284...},local{flow_name=4_Save gps cid lac to file,trigger=Manual,triggertime=1551361779427}}
28.02.2019 14:49:39.435 [4_Save gps cid lac to file] Start executing action 'Initialisiere Variable Standort: Neuer Standort in location durch GPS, Timeout 2m'
28.02.2019 14:49:47.811 [4_Save gps cid lac to file] Action 'Initialisiere Variable Standort: Neuer Standort in location durch GPS, Timeout 2m' Variable 'location' set to value 'Location[gps 46.947190,7.389795 hAcc=48 et=+5d19h59m54s183ms alt=670.3619005996284 vel=0.11095798 bear=301.61996 vAcc=??? sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=40]}]'.
28.02.2019 14:49:47.828 [4_Save gps cid lac to file] End executing action 'Initialisiere Variable Standort: Neuer Standort in location durch GPS, Timeout 2m'
28.02.2019 14:49:47.841 [4_Save gps cid lac to file] Flow continues executing with the next step.
28.02.2019 14:49:47.842 [4_Save gps cid lac to file] Start executing condition 'Funkzelle GSM: Verbunden mit LACs oder CIDs '
28.02.2019 14:49:47.885 [4_Save gps cid lac to file] End executing condition 'Funkzelle GSM: Verbunden mit LACs oder CIDs ' with return value false
28.02.2019 14:49:47.907 [4_Save gps cid lac to file] Flow continues executing with the next step.
28.02.2019 14:49:47.907 [4_Save gps cid lac to file] Start executing action 'Script: if (isEmpty({global_prevloc})) {global_prevloc = {location} }'
28.02.2019 14:49:47.922 [4_Save gps cid lac to file] End executing action 'Script: if (isEmpty({global_prevloc})) {global_prevloc = {location} }'
28.02.2019 14:49:47.940 [4_Save gps cid lac to file] Flow continues executing with the next step.
28.02.2019 14:49:47.940 [4_Save gps cid lac to file] Start executing condition 'Expression: distance(location, global_prevloc)>1'
28.02.2019 14:49:47.956 [4_Save gps cid lac to file] End executing condition 'Expression: distance(location, global_prevloc)>1' with return value true
28.02.2019 14:49:47.972 [4_Save gps cid lac to file] Flow continues executing with the next step.
28.02.2019 14:49:47.973 [4_Save gps cid lac to file] Start executing action 'In Datei Schreiben: {
"type": "FeatureCollection",
"features": [
{ "type": "Feature",
"geometry": {"type": "Point", "coordinates": {location,locationformat,decimal}},
"properties": {
"cellID": {cid},
"lac": {lac},
"date": {getDate(),dateformat,dd.MM.yyyy,HH:mm}
}
}
]
}
in /storage/emulated/0/Automagic/writelocfile.txt (anhängen)'
28.02.2019 14:49:47.990 [4_Save gps cid lac to file] End executing action 'In Datei Schreiben: {
"type": "FeatureCollection",
"features": [
{ "type": "Feature",
"geometry": {"type": "Point", "coordinates": {location,locationformat,decimal}},
"properties": {
"cellID": {cid},
"lac": {lac},
"date": {getDate(),dateformat,dd.MM.yyyy,HH:mm}
}
}
]
}
in /storage/emulated/0/Automagic/writelocfile.txt (anhängen)'
28.02.2019 14:49:48.005 [4_Save gps cid lac to file] Flow continues executing with the next step.
28.02.2019 14:49:48.006 [4_Save gps cid lac to file] Start executing action 'Script: global_prevloc = location'
28.02.2019 14:49:48.022 [4_Save gps cid lac to file] End executing action 'Script: global_prevloc = location'
28.02.2019 14:49:48.038 [4_Save gps cid lac to file] Flow ended.