Send Adress data from SMS to Google maps app

Share and discuss your flows and ideas with other users.

Moderator: Martin

Post Reply
Loupblanc
Posts: 1
Joined: 10 Mar 2018 11:45

Send Adress data from SMS to Google maps app

Post by Loupblanc » 12 Mar 2018 14:46

Hi!
I'm a voluntary firefighter in Zurich, Switzerland. We get alarm short messages on our cell phones. This message contains address data, where the fire / accident / patient is. I'd like to automatically copy this address data from the message text, start the Google Map app and paste the address to it, so it would automatically start a navigation solution.
I guess I'll need to copy / paste the variable {sms_text}. But how can I start Google map and paste the variable to it as a navigation destination?
Usually, Google map can handle texts that contain some address data and pick up the address from it. But not in all cases.
Alarm short messages look like that:
[Alarmed unit]: [S for siren] [alarm type] [CITY] [STREET] [STREET-NR] [Additional information]
Example (not a real case):
KA T1: S Gasaustritt im Gebaeude KLEINANDELFINGEN SCHAFFHAUSERSTR. 24 Volg
or
FR: S First Responder Basic KLEINANDELFINGEN SCHAFFHAUSERSTR. 24 Im EG Fam. Muster
So, maybe the {sms_text} will have to be processed in between, so only the address data will be extracted and passed to Google map. I don't know, how to do that.
As there are no dividers in the message, the only indication for address data is the upper case text (but not the one at the beginning of the message). But this is not reliable, because we already got a message like this one:
KA T1: S BMA ANDELFINGEN MITTELDORFWEG 25 EFH bei Mustermann --> where BMA and EFH is no address data (BMA= Brandmeldeanlage; EFH=Einfamilienhaus) !
Possibly, this would be the shortest [alarm type] we can get. So, if we start seeking for upper case after text pos. 13, that would be ok.

Anybody interested in this challenging task?
Thank you!

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Send Adress data from SMS to Google maps app

Post by Desmanto » 12 Mar 2018 18:39

Hi Loupblanc,

To start google map, you can use action Start Activity and tap the examples, choose the Google Maps: search. Replace the name after the q= with the variable that contains the location name, in encodeURL() format (space become %20).

To extract out the information from the {sms_text}, the best way is to use regex. But you have to try it out by yourself, since you are the one who have the sample text.

It is a little difficult if you have dynamic content in the sms. Since we need some text anchor for the regex to work properly. But if the [Alarmed unit]: [S for siren] [alarm type] part is fixed and can only have certain value at there, we can construct a very strict regex to match it. For example if the alarm type can consist only those 3 values : Gasaustritt im Gebaeude, First Responder Basic, BMA; we can limit that part to this 3.

Code: Select all

find = findAll(sms_text, '.*: S (?:Gasaustritt im Gebaeude|First Responder Basic|BMA) (.+\\d+) .*', true);
location = encodeURL(find[0][1]);
You can then use {location} in the Google Maps: search, after the q=. However this required the address ends in number (\\d+). If the address doesn't have number, or you have some extra number in the additional information; it can capture the wrong address or worse, capture no data at all.

This is for emergency cases, I highly recommend you to test the flow with so many example cases before relying upon it. You don't need to test to send the message, you can create the {sms_text} variable by yourself, by putting it in the script. Example :

Code: Select all

sms_text = "FR: S First Responder Basic KLEINANDELFINGEN SCHAFFHAUSERSTR. 24 Im EG Fam. Muster"
Or you can use my Variable Logger (I just shared the flow), to log the sms for several occassion, and use that as the sample data to test the flow.
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.

Post Reply