Proximity or Manual Detection of Nearest Location
Moderator: Martin
-
- Posts: 20
- Joined: 23 Jan 2019 21:02
Proximity or Manual Detection of Nearest Location
Is there any way to get Automagic to detect, from a list of addresses (or coordinates, I can convert them all) when it is within proximity of a location?
I drive to multiple practices for work, over 150 a month.
Would like to see something that can detect when I am near 1 of my practices and then trigger some actions, also pulling data from the respective row of information correlating to the location.
If it can't be done automatically, I don't mind pressing an "arrived" button to have it trigger and start calculating which location I appear to be closest to and then pull the correlating data.
Also, what UI is best for firing actions without triggers (like shorcuts). Tasker has a scene part where you can design an interface and you press virtual buttons and it fires actions. Would like something similar with Automagic.
I drive to multiple practices for work, over 150 a month.
Would like to see something that can detect when I am near 1 of my practices and then trigger some actions, also pulling data from the respective row of information correlating to the location.
If it can't be done automatically, I don't mind pressing an "arrived" button to have it trigger and start calculating which location I appear to be closest to and then pull the correlating data.
Also, what UI is best for firing actions without triggers (like shorcuts). Tasker has a scene part where you can design an interface and you press virtual buttons and it fires actions. Would like something similar with Automagic.
Re: Proximity or Manual Detection of Nearest Location
It can be done through trigger location, but I can't predict the real usage later. You can add those 150 location triggers into the same flow, but I am afraid with so many checking, Automagic might crash after you enable the flow (never try and won't try). Besides, it is so painful to edit the flow to add those 150 triggers. We can use some script to replace the trigger, but again not worth it.
I assume you have those location in certain text or json or any other format. And most likely the location will be added/removed from time to time. You can loop convert the address into list of location using script. So you don't need to add those location one by one, not even need to type it back to the script in the flow.
The best trigger for this case probably Periodic Location update. This is just like periodic timer, but combined with action init location. After you got current location coordinate, then loop it into the 150 location list to calculate the distance. Find the minimum distance, as shown in here : viewtopic.php?f=5&t=7829
You have to modify the script a bit, to lookback which location is the current point. Probably you have the location name too, but I need to see how the location name - coordinate are stored, before I can show the way to do it. After you get the location name too, you can then do your stuff and logs many things you need. You can look at my variable logger flow in my index too in case you need to log everything.
As for UI shortcut, just use Trigger Shortcut and add the shortcut to the home screen. You can tap it to execute it manually. Automagic's equivalent for scene is widget. You can create the widget, add the button to check current location and show the result in the widget directly. Maybe create another button to crosscheck against 150 location, or maybe to enable/disable the location update flow. The widget can be added to homescreen to behave just like usual widget/shortcut, or can be shown as overlay to dragged on top of other app (virtual button).
I have prooftest the concept, generate random 150 location to the glovar, and loop calculate distance, find the minimum distance. The speed of the script is very fast, only about 70 ms (which is amazing). I wonder what distance lib Automagic use. With so fast calculation, I assume it is using Haversine (error can be up to 0.05%, 5 m error in 10 Km). But I tested the accuracy is very close to Vincenty formula.
@Martin : Which formula does Automagic use in distance()? Haversine or Vincenty?
I assume you have those location in certain text or json or any other format. And most likely the location will be added/removed from time to time. You can loop convert the address into list of location using script. So you don't need to add those location one by one, not even need to type it back to the script in the flow.
The best trigger for this case probably Periodic Location update. This is just like periodic timer, but combined with action init location. After you got current location coordinate, then loop it into the 150 location list to calculate the distance. Find the minimum distance, as shown in here : viewtopic.php?f=5&t=7829
You have to modify the script a bit, to lookback which location is the current point. Probably you have the location name too, but I need to see how the location name - coordinate are stored, before I can show the way to do it. After you get the location name too, you can then do your stuff and logs many things you need. You can look at my variable logger flow in my index too in case you need to log everything.
As for UI shortcut, just use Trigger Shortcut and add the shortcut to the home screen. You can tap it to execute it manually. Automagic's equivalent for scene is widget. You can create the widget, add the button to check current location and show the result in the widget directly. Maybe create another button to crosscheck against 150 location, or maybe to enable/disable the location update flow. The widget can be added to homescreen to behave just like usual widget/shortcut, or can be shown as overlay to dragged on top of other app (virtual button).
I have prooftest the concept, generate random 150 location to the glovar, and loop calculate distance, find the minimum distance. The speed of the script is very fast, only about 70 ms (which is amazing). I wonder what distance lib Automagic use. With so fast calculation, I assume it is using Haversine (error can be up to 0.05%, 5 m error in 10 Km). But I tested the accuracy is very close to Vincenty formula.
@Martin : Which formula does Automagic use in distance()? Haversine or Vincenty?
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
-
- Posts: 20
- Joined: 23 Jan 2019 21:02
Re: Proximity or Manual Detection of Nearest Location
All the locations are stored in a spreadsheet in address format. I can easily get lat/long added in to reduce response time (and errors) of looking up certain addresses in real time.
Its excel. They addresses very infrequently change, so not too worried about that. Instead of adding a location trigger for each location, I was thinking if there was a way for location trigger to just check a spreadsheet.
I prefer not to clutter my home screens with shortcuts and and such. I'll check out widgets and see how that looks. With Tasker I had used scene and locked myself into that scene for everything I needed to do while working, which was nice, a full screen of work only related buttons. Improved my productivity as I was less lik-SQUIRREL! with other stuff.
I appreciate your input, that's helped me such in terms of what things to try but not liking having static locations in Automagic app itself.
Additional input much appreciated.
Its excel. They addresses very infrequently change, so not too worried about that. Instead of adding a location trigger for each location, I was thinking if there was a way for location trigger to just check a spreadsheet.
I prefer not to clutter my home screens with shortcuts and and such. I'll check out widgets and see how that looks. With Tasker I had used scene and locked myself into that scene for everything I needed to do while working, which was nice, a full screen of work only related buttons. Improved my productivity as I was less lik-SQUIRREL! with other stuff.
I appreciate your input, that's helped me such in terms of what things to try but not liking having static locations in Automagic app itself.
Additional input much appreciated.
Re: Proximity or Manual Detection of Nearest Location
Location trigger update usually update every 4 minutes, so that will introduce some latency too. Better use periodic location update, you can set a lower value, example every minute. It is just the same as you check against the spreadsheet using normal location trigger. But of course only enable the flow during certain time range or when you need it.
Spreadsheet is not automation friendly, as their format is not uniform across platform and software that create it. There is Spreadsheet Tasker Plugin, which you can use in Automagic too. But I won't rely on that. Better export the spreadsheet as csv (since you don't change it frequently) and init this csv in Automagic, parse the column into the list.
You can use the shortcut anywhere. You can put it into quick setting if your ROM is nougat 7.0+ and very AOSP-ish. If your ROM support smartbar, you can even put it into the navbar as I do. I also put the shortcut in GMD gesture (require root), so I can execute flow using gesture.
Automagic widget also can be created to be full screen and blocking the whole UI. You can put only the needed button there. I don't know how you use scene in tasker, but Automagic's widget is much less capable than tasker's scene (you must consider this).
For me, designing a fully functional tasker scene takes too much time. I never properly utilize it. I better use Automagic's widget and coupled it with several input dialog for the input. I use many input dialog with choices or multiple choices. So even though the widget capability is less, I can actually use it more effective than what I used to do in tasker. Because it is quite easy (for me) to deal with the multiple consecutive choices. So you can dig down between choices and you only need to maintain a single nested map/list database for those multiples nested choices. Example, one of my backup flow, maintain the choices in the list : viewtopic.php?f=3&t=7858
Spreadsheet is not automation friendly, as their format is not uniform across platform and software that create it. There is Spreadsheet Tasker Plugin, which you can use in Automagic too. But I won't rely on that. Better export the spreadsheet as csv (since you don't change it frequently) and init this csv in Automagic, parse the column into the list.
You can use the shortcut anywhere. You can put it into quick setting if your ROM is nougat 7.0+ and very AOSP-ish. If your ROM support smartbar, you can even put it into the navbar as I do. I also put the shortcut in GMD gesture (require root), so I can execute flow using gesture.
Automagic widget also can be created to be full screen and blocking the whole UI. You can put only the needed button there. I don't know how you use scene in tasker, but Automagic's widget is much less capable than tasker's scene (you must consider this).
For me, designing a fully functional tasker scene takes too much time. I never properly utilize it. I better use Automagic's widget and coupled it with several input dialog for the input. I use many input dialog with choices or multiple choices. So even though the widget capability is less, I can actually use it more effective than what I used to do in tasker. Because it is quite easy (for me) to deal with the multiple consecutive choices. So you can dig down between choices and you only need to maintain a single nested map/list database for those multiples nested choices. Example, one of my backup flow, maintain the choices in the list : viewtopic.php?f=3&t=7858
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
-
- Posts: 20
- Joined: 23 Jan 2019 21:02
Re: Proximity or Manual Detection of Nearest Location
Thanks once again for your reply.
I agree with your assessment on Tasker. Which is why I am moving to Automagic. Tasker is too time consuming for simple tasks and being on a phone with a tiny keyboard doesnt help. Automagic makes these things easier to put together with more user friendly UI and less typing needed.
In a few weeks, I will likely have tasker off my phones. Just need to learn the curve with Automagic and get used to the different terminologies. Looking for a "wait" command. Couldn't find it. Tried "pause". Tried "wait". etc. Eventually had to search the forums only to find out it's "sleep" which I had saw but assume it was literally a sleep function to put your phone to sleep. Didn't make sense to me. But it is what it is. Running into a number of lingo issues but I'm learning.
CSV is no issue. In fact, I realized doing it in CSV saves me a few other steps as well. Now its just a matter of the most efficient way to push the CSV to my phone for use. Confidential data and all.
I agree with your assessment on Tasker. Which is why I am moving to Automagic. Tasker is too time consuming for simple tasks and being on a phone with a tiny keyboard doesnt help. Automagic makes these things easier to put together with more user friendly UI and less typing needed.
In a few weeks, I will likely have tasker off my phones. Just need to learn the curve with Automagic and get used to the different terminologies. Looking for a "wait" command. Couldn't find it. Tried "pause". Tried "wait". etc. Eventually had to search the forums only to find out it's "sleep" which I had saw but assume it was literally a sleep function to put your phone to sleep. Didn't make sense to me. But it is what it is. Running into a number of lingo issues but I'm learning.
CSV is no issue. In fact, I realized doing it in CSV saves me a few other steps as well. Now its just a matter of the most efficient way to push the CSV to my phone for use. Confidential data and all.
Re: Proximity or Manual Detection of Nearest Location
Few weeks is too long, you should burn the bridge, uninstall tasker now!
Just kidding Take your time to slowly convert the important profiles/tasks first. 1 week should be enough to that, as we have the logic already in tasker; only need to find the equivalent way to do it in automagic (and some syntax/method difference).
Automagic's scripting is heavily influenced by java and javascript. Hence you will find a lot of similarity. You can look at available function in the function button at the script action. Or you can look at the script documentation/help page for more usage. I recommend you to spend some time reading the whole Automagic help, especially list of available triggers, conditions and actions. I have put the links in my index, at the documentation section. You don't have to remember or study them intensively. But at least took a glance (quick reading) for all. I spend 4 days just to read the documentation, and that really boost my migration from tasker to Automagic.
You can transfer the csv in many ways. You can
- copy it using MTP to the phone folder
- upload it gdrive and download it at phone
- Create http request trigger and post the data using eventghost.
- Copy it using FTP using MiXplorer FTP, or use MiXplorer to copy it from the folder share.
- You can creat qrcode from the content of the csv (if below 1 KB) and scan it to copy the content, paste into file. Or you can even create a flow to automatically scan the QR and save the scanned text into file.
- Still a lot of ways.
For data security, it is quite blurry. The csv file will be stored at the internal storage and can be accessed by other app which have the storage permission. Even if you encrypt it and decrypt it later, you still have to put the password inside your flow; and automagic's flows.xml is stored at internal storage... Yeah, the flow is not in visible format, but still can be accessed by other app too.
There is a way though to create a self destruct flow. It works best if the phone is rooted and automagic is installed as system. It can completely wipe out everything, including the phone bootloader and IMEI partition, rendering it totally useless (although probably still can be saved by some low level partition access). But it was too dangerous, that I postponed it until undefined time.
Just kidding Take your time to slowly convert the important profiles/tasks first. 1 week should be enough to that, as we have the logic already in tasker; only need to find the equivalent way to do it in automagic (and some syntax/method difference).
Automagic's scripting is heavily influenced by java and javascript. Hence you will find a lot of similarity. You can look at available function in the function button at the script action. Or you can look at the script documentation/help page for more usage. I recommend you to spend some time reading the whole Automagic help, especially list of available triggers, conditions and actions. I have put the links in my index, at the documentation section. You don't have to remember or study them intensively. But at least took a glance (quick reading) for all. I spend 4 days just to read the documentation, and that really boost my migration from tasker to Automagic.
You can transfer the csv in many ways. You can
- copy it using MTP to the phone folder
- upload it gdrive and download it at phone
- Create http request trigger and post the data using eventghost.
- Copy it using FTP using MiXplorer FTP, or use MiXplorer to copy it from the folder share.
- You can creat qrcode from the content of the csv (if below 1 KB) and scan it to copy the content, paste into file. Or you can even create a flow to automatically scan the QR and save the scanned text into file.
- Still a lot of ways.
For data security, it is quite blurry. The csv file will be stored at the internal storage and can be accessed by other app which have the storage permission. Even if you encrypt it and decrypt it later, you still have to put the password inside your flow; and automagic's flows.xml is stored at internal storage... Yeah, the flow is not in visible format, but still can be accessed by other app too.
There is a way though to create a self destruct flow. It works best if the phone is rooted and automagic is installed as system. It can completely wipe out everything, including the phone bootloader and IMEI partition, rendering it totally useless (although probably still can be saved by some low level partition access). But it was too dangerous, that I postponed it until undefined time.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
-
- Posts: 20
- Joined: 23 Jan 2019 21:02
Re: Proximity or Manual Detection of Nearest Location
"parse the column into a list"
As I'm reading your posts I am having difficulties figuring out the terminology.
You had said "init this CSV" which took me awhile to figure out you meant "init variable text file"
Now the parse column into a list I cannot figure out which function that's supposed to relate to.
You said something about links in your signature. I don't see signatures... I'm assuming because I'm on mobile?
As I'm reading your posts I am having difficulties figuring out the terminology.
You had said "init this CSV" which took me awhile to figure out you meant "init variable text file"
Now the parse column into a list I cannot figure out which function that's supposed to relate to.
You said something about links in your signature. I don't see signatures... I'm assuming because I'm on mobile?
Re: Proximity or Manual Detection of Nearest Location
Oh, sorry, I am talking more about the big picture. Yes, the detail should be Action "Init Variable text file" and choose the csv file to init to the variable {csv}.
As to parse column into list, the detail is in script. You will split the csv lines first, and the use splitCSVRecord() to split each column into new nested list.
For example, your data is like this, in csv.
It is very difficult to work with this kind of data. You have to parse it first to a list object, so we can loop to it.
Using this script
Will parse it into a list object like this. Each [] is a list level. It is much easier to see if you use condition debug dialog.
To access "Hope, AR, USA", we will use database[0][0]. To access the lat is database[0][1], the long is database[0][2] and so on. You can easily loop to this list to calculate distance.
As for link, yes, maybe because you are using mobile version. You can access my index here : viewtopic.php?f=6&t=6993
As to parse column into list, the detail is in script. You will split the csv lines first, and the use splitCSVRecord() to split each column into new nested list.
For example, your data is like this, in csv.
Code: Select all
"Hope, AR, USA",33.669964,-93.590096
"Tujunga, Los Angeles, CA, USA",34.263302,-118.302711
"Bonnybridge, Scotland, UK",56.003227,-3.888634
"Tarzana, Los Angeles, CA, USA",34.150879,-118.551651
Using this script
Code: Select all
temp = split(csv, "\n");
database = newList();
for(i in temp)
addElement(database, splitCSVRecord(i));
Code: Select all
[
[Hope, AR, USA, 33.669964, -93.590096],
[Tujunga, Los Angeles, CA, USA, 34.263302, -118.302711],
[Bonnybridge, Scotland, UK, 56.003227, -3.888634],
[Tarzana, Los Angeles, CA, USA, 34.150879, -118.551651]
]
As for link, yes, maybe because you are using mobile version. You can access my index here : viewtopic.php?f=6&t=6993
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
-
- Posts: 20
- Joined: 23 Jan 2019 21:02
Re: Proximity or Manual Detection of Nearest Location
Thanks.
I'm stuck on this part.
Rather than importing the database and parsing it every time I'm trying to figure the distance from current location to add to the database. I want compare and find the closest distance to me and return that value for later use in receiving relevant information to the one closets to me.
database is the already parsed CSV
Also theory tells me that this will continue to add more fields rather than replacing itself like I would want it to.
/Code
temp = database;
for (i in temp)
csv_location=newLocation(database[56],database[57]);
addElement(database, round(distance(csv_location, location)));
/code
What I'm trying to accomplish:
1) calculate distance of my current point to each office location.
2) find out which one is closest to me
3) store the data in easily used variables from closest location to me for use later in the flow/other flows
4) maintain the distance data for this for so I can later (before leaving my location) select from the next 10 closest locations to me from a list without the need to recalculate and use it's data as needed. (Selecting my next location and pulling up respective map, phone number to call, etc etc)
I'm stuck on this part.
Rather than importing the database and parsing it every time I'm trying to figure the distance from current location to add to the database. I want compare and find the closest distance to me and return that value for later use in receiving relevant information to the one closets to me.
database is the already parsed CSV
Also theory tells me that this will continue to add more fields rather than replacing itself like I would want it to.
/Code
temp = database;
for (i in temp)
csv_location=newLocation(database[56],database[57]);
addElement(database, round(distance(csv_location, location)));
/code
What I'm trying to accomplish:
1) calculate distance of my current point to each office location.
2) find out which one is closest to me
3) store the data in easily used variables from closest location to me for use later in the flow/other flows
4) maintain the distance data for this for so I can later (before leaving my location) select from the next 10 closest locations to me from a list without the need to recalculate and use it's data as needed. (Selecting my next location and pulling up respective map, phone number to call, etc etc)
Re: Proximity or Manual Detection of Nearest Location
Do you mean that you have starting point, location A, save it to the database. Move around and arrive at new location B, calculate the distance between A-B, do some stuff and log the data.
Someone ever ask me the similar case in tasker thread. He is a network perfomance tester. He use it to speedtest random location around the city, but the test must spread at least 500 meter from previous location. It used to be more difficult to do in tasker, but much easier to replicate the concept in Automagic.
For your code, I don't get the concept, since I don't know what is the structure of the temp/database. But if you loop like that, it will be run into error, since temp = database, will most likely point both variable to the same object list/map. And looping (temp) while adding the element to the loop (database), will cause error.
1, 2, 3 can be done using the link I post before. The result can be stored in global variable first, if the data is just several lines. But I don't quite get number 4, since I don't know what data you want to maintain and how the relationship to the distance. But as long as you have the global variable, you can use it later for choosing the next closest distance. If you sort it, the index 0 is the closest. The next one will index 1, simply increase the index until you reach the furthest location.
Someone ever ask me the similar case in tasker thread. He is a network perfomance tester. He use it to speedtest random location around the city, but the test must spread at least 500 meter from previous location. It used to be more difficult to do in tasker, but much easier to replicate the concept in Automagic.
For your code, I don't get the concept, since I don't know what is the structure of the temp/database. But if you loop like that, it will be run into error, since temp = database, will most likely point both variable to the same object list/map. And looping (temp) while adding the element to the loop (database), will cause error.
1, 2, 3 can be done using the link I post before. The result can be stored in global variable first, if the data is just several lines. But I don't quite get number 4, since I don't know what data you want to maintain and how the relationship to the distance. But as long as you have the global variable, you can use it later for choosing the next closest distance. If you sort it, the index 0 is the closest. The next one will index 1, simply increase the index until you reach the furthest location.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.