1. Download our Official Android App: Forums for Android!

tasker convert location

Discussion in 'Android Apps & Games' started by alackman, Sep 2, 2011.

  1. alackman

    alackman Android Enthusiast
    Thread Starter
    Rank:
    None
    Points:
    43
    Posts:
    336
    Joined:
    Aug 24, 2010

    Aug 24, 2010
    336
    36
    43
    london
    hi, ive searched but cannot find any understandable answers to this.

    I want to be able to convert the %LOC variable result into an actual nearest town,city or even area name. Is this possible? I want to be able to fire off an autotext when driving that responds with this informaion as opposed to a load of numbers.

    any one help?
     

    Advertisement

  2. CodeMonkey

    CodeMonkey Guest
    Rank:
    None
    Posts:
    0
    Joined:

    I wrote this one a while back but this is the only documented version I have: the Tasker groups thread

    Note that this task depends on having an updated network location (%LOCN), this is a lower power draw than GPS Location (%LOC), but you should be able to switch %LOCN for %LOC without issues if you wish.
    You can do a 'Location Get' with Tasker first to make sure your location is up to date.

    Note also that the newest Tasker versions have better variable cleanups, so you may want to consider copying out %HTTPD to a user variable to make cleanup easier.

    Hope this helps.
     
    alackman likes this.
  3. alackman

    alackman Android Enthusiast
    Thread Starter
    Rank:
    None
    Points:
    43
    Posts:
    336
    Joined:
    Aug 24, 2010

    Aug 24, 2010
    336
    36
    43
    london
    Hi codemonkey,

    Thank you for this. However, it is way over my head. I've started copying it down, when I get some more time/patience, I will complete it and test. The talk of variable splits and cleanups is what loses me I'm afraid. None of my tasks have more than 8 stages in, so I'm a little daunted by all of this. My problem is I want to understand what each stage means...and I don't! I was hoping it would be easier than this lol. Lots to learn.....again.
     
  4. CodeMonkey

    CodeMonkey Guest
    Rank:
    None
    Posts:
    0
    Joined:

    Cleanup = variable clear.

    When you've finished using a variable that you have created (ie not a system variable) it's good practice to do a variable clear to remove it from memory.

    Splits are explained quite well in the user guide, but basically they are a way of breaking a chunk of data contained in one variable into two or more bits based on its contents.

    If you can get to grips with the task, then it's pretty easy to supply the extracted postcode back to another Google API and get the current / future weather forecast for the area.
     
  5. alackman

    alackman Android Enthusiast
    Thread Starter
    Rank:
    None
    Points:
    43
    Posts:
    336
    Joined:
    Aug 24, 2010

    Aug 24, 2010
    336
    36
    43
    london
    I get the need for clean up. Also the splits....I just don't understand all the splits in your profile. Maybe it will all make sense once I try it.I'll get back to you on that one. :) I'm not so fussed about the postcode, I just want to be able to text rough location area. I guys I need to run whole profile to be able to understand what I can take out.
     
  6. alackman

    alackman Android Enthusiast
    Thread Starter
    Rank:
    None
    Points:
    43
    Posts:
    336
    Joined:
    Aug 24, 2010

    Aug 24, 2010
    336
    36
    43
    london
    Wow, I'm struggling. I can't find the bit in the user guide describing splits and I just can't understand how to define them. How do I know what to put after the % variable for example? (httpd211 etc)

    I understand why splits work just not how.

    Could you point me in the right direction for the user guide description?

    Also any other advice, if you have time, on how I can use the splits etc to collect location data, using gps/google maps so when I'm driving....and plugged in to power my auto response text will add in my location.

    I'm sorry, I just can't get my head around your profile enough to work it out myself.
    :thinking:

    I've copied it exactly..I think. And when I add a pop up to tell me what % LOCNAME should be....I just get % HTTPD11221? Any ideas?
     
  7. CodeMonkey

    CodeMonkey Guest
    Rank:
    None
    Posts:
    0
    Joined:

    Splits are explained quite well here

    Are you doing a GET first to obtain the location? a variable rerturns its own name when it has no value.

    I would start by building a very basic task first to get used to how this all works,
    eg:

    1. Misc Action: Get Location (Net)
    2. HTTP GET (per my first task link)
    3. Alert Action: Popup %HTTPD

    Test.
    The popup should contain the returned data from the GET; this is what we want to split.

    As far as knowing what to split, it is trial and error I'm afraid. I built that task over a weekend, using various posts on the tasker google group and the Google API documentation (and several file editing utilities on my old macbook).

    When you split a variable it divides into as may sub variables as required (eg %TEST divides into %TEST1 %TEST2 etc as required by the splitter).

    As far as the contexts you need I would suggest:

    1. State - Power
    2. Event - Phone - Received Text
    3. <Some other trigger> - bluetooth connected (if you have a car kit / headset you use?)

    Alternatively I've seen some posts on the tasker group about detecting movement, but not tried that route myself.
    You can then trigger the task based on these contexts; I'd consider setting up some way of ensuring that you aren't checking for location more than you need to (eg if you get 5 texts in 2 minutes you probably don't want to check your location 5 times) - storing the time you last retrieved the location and checking it at the start of the location retrieval woud do it.

    This is quite an advanced task if you are just starting out with Tasker so don't be put off by it; start small and build on what you have. It took me about 2 rewrites to be happy with my tasker setup, and I have slimmed down the number of tasks that I was running at one point..
     
    alackman likes this.
  8. alackman

    alackman Android Enthusiast
    Thread Starter
    Rank:
    None
    Points:
    43
    Posts:
    336
    Joined:
    Aug 24, 2010

    Aug 24, 2010
    336
    36
    43
    london
    I undestand the context parts, ive got my head around most of tasker and now am trting to sort ths splits. I've got about 15 profiles running well without any splits so far. Maybe ill play with splitting something simpler like a name into just 1st name etc. the link you sent has helped clarify somewhat, thank you.

    Re this task, I was running the get first. So no idea why it was just bringing up the variable split name. I think to understand this task I need to clarify how you know what to write in the stage that pulls ths data from google? I understand it is this that gets split. But when you just do the get location, you end up with a latitude, longitude number, which would be pointless splitting right? So how do I know how to get the information like town or county etc? Once I have this figured out, I guess I will be able to apply the trial and write to split the variable to get the info I want.

    I already have a profile that fires off when I get a text from certain people and when I'm driving (connected to bluetooth car kit). It send a text reply giving my speed and saying I'll respond later. This is where I want to add the task to also say where I am.

    So yes, I'll start small. Where does the http get server line come from?
     
  9. CodeMonkey

    CodeMonkey Guest
    Rank:
    None
    Posts:
    0
    Joined:

    The GET action:

    HTTP GET: Port: maps.google.com/maps/api/geocode/json?latlng=%LOCN&sensor=false Timeout: 10 Mime Type: text/xml

    should (if successful) fill the %HTTPD system variable with a response from Google in xml format as documented here
     
    alackman likes this.
  10. alackman

    alackman Android Enthusiast
    Thread Starter
    Rank:
    None
    Points:
    43
    Posts:
    336
    Joined:
    Aug 24, 2010

    Aug 24, 2010
    336
    36
    43
    london
    Aha, now this is what I needed. there goes my evening.lol. I will read and spend some time getting my head around this first. Thank you for all your help.
     
  11. CodeMonkey

    CodeMonkey Guest
    Rank:
    None
    Posts:
    0
    Joined:

    NP. Happy tasking!
     
  12. GarrMatey

    GarrMatey Lurker
    Rank:
    None
    Points:
    6
    Posts:
    3
    Joined:
    Mar 13, 2010

    Mar 13, 2010
    3
    1
    6
    Ok, so uh, I know this post is old, but, did you ever get this all figured out? I am now looking to do the same thing.
     
  13. alackman

    alackman Android Enthusiast
    Thread Starter
    Rank:
    None
    Points:
    43
    Posts:
    336
    Joined:
    Aug 24, 2010

    Aug 24, 2010
    336
    36
    43
    london
    I wouldn't say completely figured out but I have got a couple of working profiles that check location and then update % loc variable to be able to add info into auto text etc. it used the httpget and so isn't 100% all the time. (sometimes puts more general area than town, but mostly works. Ill try and write up what I have unless anyone knows of a way to export the profile onto here.
     
  14. GarrMatey

    GarrMatey Lurker
    Rank:
    None
    Points:
    6
    Posts:
    3
    Joined:
    Mar 13, 2010

    Mar 13, 2010
    3
    1
    6
    alackman likes this.
  15. alackman

    alackman Android Enthusiast
    Thread Starter
    Rank:
    None
    Points:
    43
    Posts:
    336
    Joined:
    Aug 24, 2010

    Aug 24, 2010
    336
    36
    43
    london
  16. alackman

    alackman Android Enthusiast
    Thread Starter
    Rank:
    None
    Points:
    43
    Posts:
    336
    Joined:
    Aug 24, 2010

    Aug 24, 2010
    336
    36
    43
    london
    Ok so here goes with what I have as a task that checks for location and sets variable to actual location. Its not perfect as sometimes it finds correct town and sometimes just puts county (I'm in uk, im assuming this makes a difference). If anyone has suggestions to improve although I must admit I've not really played and compared gps with net location.
    This is a task which can be run in a profile with perform task *name. If any one wants me to email it to them rather than typing it out, I should be able to do this. Let me know how you get on with it. :)

    1.get location
    Source net
    2 HTTP Get
    Server: port maps.googleapis.com/maps/apis/geocode/json?latlng=%LOCN&sensor=false
    3. Goto
    Type action number
    Number 16
    If HTTPD = -1
    4.variable set
    Name %LIN
    To 16
    5. Read line
    File sync
    Line %LIN
    To var %HTTPD1
    6. variable split
    Name %HTTPD1
    Splitter "
    7. Variable set
    Name %LOCLONG
    To %HTTPD14
    8.variable set
    Name %LIN
    To 17
    9. Read line
    File sync
    Line %LIN
    To var %HTTPD1
    10.variable split
    Name HTTPD1
    splitter "
    11.if
    %HTTPD14 ~ * *
    12. Variable split
    Name %HTTPD14
    13. Variable set
    Name %HTTPD14
    To %HTTPD141+%HTTPD142
    14. End if
    15 variable set
    Name %LOCSHRT
    TO %HTTPD14
    16. Variable clear
    Name % HTTPD*
     
    GarrMatey likes this.
  17. GarrMatey

    GarrMatey Lurker
    Rank:
    None
    Points:
    6
    Posts:
    3
    Joined:
    Mar 13, 2010

    Mar 13, 2010
    3
    1
    6
    Thank you so much! I would REALLY appreciate an emailed copy so I can just import it.

    albuquerquecomputerguy
    at
    gmail.com

    Thanks again!
     

Share This Page

Loading...