/maps/api/geocode/xml?latlng=%loc&sensor=false
Hopefully it points you in the right direction.
A1: Get Location [ Source:GPS Timeout (Seconds):120 Continue Task Immediately:Off Keep Tracking:Off ]
A2: Variable Set [ Name:%locage To:%TIMES - %LOCTMS Do Maths:On Append:Off ]
A3: Goto [ Type:Action Number Number:1 Label: ] If [ %locage > 59 ]
A4: Variable Set [ Name:%loc To:%LOC Do Maths:Off Append:Off ]
A5: HTTP Get [ Server:Port:maps.googleapis.com Path:/maps/api/geocode/xml?latlng=%loc&sensor=false Attributes: Cookies: Timeout:15 Mime Type: Output File: Trust Any Certificate:Off ]
A6: Variable Set [ Name:%httpd To:%HTTPD Do Maths:Off Append:Off ]
A7: Variable Search Replace [ Variable:%httpd Search:(?<=address>).+(?=</format) Ignore Case:Off Multi-Line:Off One Match Only:Off Store Matches In:%result Replace Matches:Off Replace With: ]
A8: Flash [ Text:%result1 Long:Off ]
Hope this helps.
This is the beginning of the %HTTPD value:
<?xml version="1.0" encoding="UTF-8"?>
<GeocodeResponse>
<status>OK</status>
<result>
<type>street_address</type>
<formatted_address>1234 Las Vegas Ave, Las Vegas, NV 89123, USA</formatted_address>
Ohhhh the value is am ARRAY! I kept using %ADDRESS instead of %ADDRESS1....sheesh.
But thanks your regex grabs the text inside the tags while the regex i used kept the tags.
Thanks Bob!
Here is the simplest version:
Location To Address (769)
A1: Variable Clear [ Name:%LOC Pattern Matching:Off ]
A2: Get Location [ Source:Any Timeout (Seconds):10 Continue Task Immediately:On Keep Tracking:Off ]
A3: Wait Until [ MS:0 Seconds:10 Minutes:0 Hours:0 Days:0 ] If [ %LOC Is Set ]
A4: HTTP Get [ Server:Port:maps.googleapis.com Path:/maps/api/geocode/xml?latlng=%LOC&sensor=false Attributes: Cookies: Timeout:10 Mime Type: Output File: Trust Any Certificate:Off ]
A5: Variable Search Replace [ Variable:%HTTPD Search:(?<=<formatted_address>).+(?=</formatted_address>) Ignore Case:Off Multi-Line:Off One Match Only:Off Store Matches In:%ADDRESS Replace Matches:Off Replace With: ]
A6: Flash [ Text:%ADDRESS1 Long:Off ]
--
You received this message because you are subscribed to a topic in the Google Groups "Tasker" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tasker/_SPCn3hztRE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tasker+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/d/optout.
Just get rid off that. Tasker ignores it anyway as an error.
No offense, but the only way to guarantee a 'current' location (not based on previously obtained %LOC value) is with the method I listed using a loop.
I did it that way because i see it as a repetitive task you'll do again and again, and on top of that from testing and personal knowledge of people's behavior, they have their GPS on anyways PLUS this task uses network location too which is by DEFAULT enabled in every android device and under many tests in phone it already has current location info from background apps or finds it in seconds.
That's my logic but i understand what you mean in the programming sense ;-)
> I did it that way because i see it as a repetitive task you'll do again and again,
Not sure what that has to do with brandons recomdation?
and on top of that from testing and personal knowledge of people's behavior, they have their GPS on anyways PLUS this task uses network location too which is by DEFAULT enabled in every android device and under many tests in phone it already has current location info from background apps or finds it in seconds.
>
> That's my logic
I think Brandon was trying to point out that your logic is not working as you expect.
A1: Variable Clear [ Name:%LOC Pattern Matching:Off ]
This will not clear %LOC. You can not edit a system variable.
A2: Get Location [ Source:Any Timeout (Seconds):10 Continue Task Immediately:On Keep Tracking:Off ]
A3: Wait Until [ MS:0 Seconds:10 Minutes:0 Hours:0 Days:0 ] If [ %LOC Is Set ]
This means %LOC will always be set and A3 will never wait and you since you have 'continue task immediately' checked in the get location then you will can end up with the previous %LOC value.
Although if I am not mistaken Brandons method will force the task to wait until the gps has a new fix which is the same as if you did not have 'continue task immediately' checked. (I think)..
I would recommend the same loop as Brandon recommended except put a 1 sec wait in it then only let it loop as long as you want and if no fix in x loops then use %LOCN instead...
I also suggest looking at %LOCACC. Since you're using %LOCN, location accuracy would be good to know.
Fyi, I realize about GPS... the task actually used accounts for it being off, queried interval loops timeout, force action stops, disabled data connection, etc. This is just the bare basics to get an address in the above example.
But, yes. Rich mentioned exactly why I made the suggestion. However, I see what you mean (off the top) about it continually looping if no GPS is determined. The actual task accounts for such a possibility though.
Here's the actual task used that initiates a address check. You'll notice that GPS being off is taken into account, the qquery to enable GPS, reverting settings, highlighting accuracy, indicating errors, endless loop prevention, ensured forced timeout, etc.
Oh, and it makes a little GPS icon flicker on/off in the scene so you know it's busy/working ;-) (way cooler than a standard one second wait!)
Obtain Current Address (52)
A1: Stop [ With Error:Off Task:Calendar Manual Timeout Task ]
A2: Variable Set [ Name:%gps To:off Do Maths:Off Append:Off ] If [ %GPS ~ off ]
A3: GPS [ Set:On Continue Task After Error:On ] If [ %GPS ~ off ]
<GPS Test>
A4: If [ %GPS ~ off ]
A5: Variable Add [ Name:%gps_timeout Value:1 Wrap Around:0 ]
A6: Wait [ MS:0 Seconds:5 Minutes:0 Hours:0 Days:0 ] If [ %GPS ~ off ]
A7: Goto [ Type:Action Label Number:1 Label:GPS Test ] If [ %gps_timeout < 6 & %GPS ~ off ]
A8: End If
A9: Test Scene [ Name:Calendar Entry Test:Status Store Result In:%scene ]
A10: Show Scene [ Name:Calendar Entry Display As:Activity, Full Window, No Bar Horizontal Position:100 Vertical Position:100 Animation:System Show Exit Button:Off Continue Task Immediately:On ] If [ %scene !~ visible ]
A11: If [ %GPS ~ on ]
A12: Variable Set [ Name:%times To:%TIMES Do Maths:Off Append:Off ]
A13: Variable Clear [ Name:%Cal_loc Pattern Matching:Off ]
A14: Get Location [ Source:GPS Timeout (Seconds):120 Continue Task Immediately:On Keep Tracking:Off Continue Task After Error:On ]
<Get Location>
A15: Element Image [ Scene Name:Calendar Entry Element:GPS Address Button Image:hl_device_access_location_searching ]
A16: Wait [ MS:500 Seconds:0 Minutes:0 Hours:0 Days:0 ]
A17: Element Image [ Scene Name:Calendar Entry Element:GPS Address Button Image:hd_device_access_location_searching ]
A18: Wait [ MS:500 Seconds:0 Minutes:0 Hours:0 Days:0 ]
A19: Variable Set [ Name:%locage To:%TIMES - %LOCTMS Do Maths:On Append:Off ]
A20: Goto [ Type:Action Label Number:1 Label:End ] If [ %times + 120 < %TIMES ]
A21: Goto [ Type:Action Label Number:1 Label:Get Location ] If [ %locage > 120 ]
A22: Flash [ Text:Location found, retrieving data... Long:Off ] If [ %LOC Is Set & %locage < 121 ]
A23: Stop Location [ Source:GPS ]
A24: Variable Set [ Name:%loc To:%LOC Do Maths:Off Append:Off ] If [ %LOC Is Set ]
A25: HTTP Get [ Server:Port:maps.googleapis.com Path:/maps/api/geocode/xml?latlng=%loc&sensor=false Attributes: Cookies: Timeout:15 Mime Type: Output File: Trust Any Certificate:Off Continue Task After Error:On ] If [ %loc Is Set ]
A26: Variable Set [ Name:%httpd To:%HTTPD Do Maths:Off Append:Off ] If [ %HTTPD Is Set ]
A27: Variable Search Replace [ Variable:%httpd Search:(?<=address>).+(?=</format) Ignore Case:Off Multi-Line:Off One Match Only:Off Store Matches In:%result Replace Matches:Off Replace With: ]
A28: Variable Set [ Name:%Cal_loc To:%result1 Do Maths:Off Append:Off ] If [ %result1 Is Set ]
A29: Element Text [ Scene Name:Calendar Entry Element:Calendar Location Position:Replace Existing Text:%result1 ] If [ %result1 Is Set ]
A30: Element Visibility [ Scene Name:Calendar Entry Element Match:Location Accuracy Text Set:True Animation Time (MS):400 ] If [ %result1 Is Set ]
A31: Variable Set [ Name:%Cal_loc To:Error occurred! Do Maths:Off Append:Off ] If [ %result1 ! Set ]
A32: Element Text [ Scene Name:Calendar Entry Element:Calendar Location Position:Replace Existing Text:Error occurred! ] If [ %result1 ! Set ]
A33: End If
A34: Variable Set [ Name:%Cal_loc To:Please enable GPS Do Maths:Off Append:Off ] If [ %GPS ~ off ]
A35: Element Text [ Scene Name:Calendar Entry Element:Calendar Location Position:Replace Existing Text:Please enable GPS ] If [ %GPS ~ off ]
A36: Element Image [ Scene Name:Calendar Entry Element:GPS Address Button Image:hd_alerts_and_states_warning ] If [ %GPS ~ off ]
A37: Element Image [ Scene Name:Calendar Entry Element:GPS Address Button Image:hd_device_access_location_found ] If [ %Cal_loc !~ Error occurred! & %GPS !~ off ]
A38: Element Image [ Scene Name:Calendar Entry Element:GPS Address Button Image:hd_device_access_location_off ] If [ %Cal_loc ~ Error occurred! ]
A39: GPS [ Set:Off ] If [ %gps ~ off ]
A40: Perform Task [ Name:Calendar Manual Timeout Task Stop:Off Priority:%priority - 1 Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: ] If [ %Share_event !~ true ]
A41: Stop [ With Error:Off Task:Obtain Current Address ]
<End>
A42: Anchor
A43: Element Text [ Scene Name:Calendar Entry Element:Calendar Location Position:Replace Existing Text:An error occurred! ]
A44: Element Image [ Scene Name:Calendar Entry Element:GPS Address Button Image:hd_device_access_location_off ]
A45: Stop Location [ Source:GPS ]
A46: GPS [ Set:Off ] If [ %gps ~ off ]
A47: Perform Task [ Name:Calendar Manual Timeout Task Stop:Off Priority:%priority - 1 Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: ] If [ %Share_event !~ true ]
A48: Stop [ With Error:Off Task:Obtain Current Address ]
> I would be grateful if the XML file is made available.
> Thank you
Have you tried searching this group? I am sure I have seen this posted several times.
I couldn't get the search replace action as written to work. Try using the following in the search: (?<=address>).+(?=<)
Good help Rich, as always but I still like the regex approach.
Have a look at this web site. I helps you build a regex and lets you test it on your target text. https://regex101.com/
I tried copying these tasks to a text editor and saving as .tsk.xml files. When I try to import I get an error bad data format message. How do I convert text to a task.
That surprises me. I just changed it to remove the state, zip code, USA component.
(?<=address>).+(?=, CA)
Don't understand why it doesn't work for you.
Are you in California?