This object is in archive! 

Interface external URLs with position parameters

joeloc shared this idea 9 years ago
Completed

Hi Locus wizards.

I would like to add a button to the Locus toolbar that opens an URL with parameters corresponding to the current map position, e.g.

http://www.vttrack.fr/?zoom=11&lat=43.11557&lon=12.35409

Any way to do this?

Replies (32)

photo
1

Thanks, but that's not really useful in this case. I need ONE tap to directly interface ANY web page at the current map position.


I somehow thought Locus has that since years... must have been a dream ;-/. Isn't that something quite obvious and helpful?

photo
1

Hi,


hmm such feature really wasn't in Locus. At least as I know :).


On what is this useful?

photo
1

helpful? hm most of time i'm offline. so...

but nice gimmick

a new idea is born...

"create URL with custom string and open browser"


The string with placeholder. eg from cfg:


  1. button_url=http://www.myurl.com/?user=mike&time={t}&lat={lat}&lon={lon}&msg={txt}

...is also useful to send position manually to Live tracking server !!


Most part of code already exist in live tracking function.

photo
1

There are at least a dozen very useful trips&tours&track collection websites... gpsies... utagawa... vttrack... all invaluable for planning your trip along the road. You can immediately see which hike/bike/whatever routes are available in a region. One example I gave in the 1st post:


http://www.vttrack.fr/?zoom=14&lat=45.16176&lon=5.67131&layers=OpenCycleMap%7CSentiers%7CTopos%7CUtagawa%7C


Now... when I plan the next day... I normally scroll around in Locus towards the place I want to go and "have a look around". Wouldn't it be great if I could go from Locus to any of these trip sites at the correct position with a single tap?


Then it's another tap on the trip web site to download an interesting track as gpx and import it to Locus.

photo
1

Implementing this is straight forward and for a start wouldn't require any user interface at all. Like gynta said... something like


config.cfg:


link1_name="VTT"

link1_url="http://www.vttrack.fr/?zoom={mapzoom}&lat={maplat}&lon={maplon}&layers=OpenCycleMap%7CSentiers%7CTopos%7CUtagawa%7C"


link2_name=...


Support up to 9 link buttons for a start and if they're non-empty, offer them as buttons for your toolbars.

photo
1

Hmm interesting. Have to say .... why not.


Find at least ten votes (ten people who find this useful) and I'll look at it.

photo
1

hehe you also voting for a small project? funny :)


+1

photo
1

...and Stefan creates now a huge project from first tiny idea... :D

photo
1

These "custom link buttons" can also be used to fire position updates to tracking servers or link to google maps or to any other URL-controlled thingy out there... probably thousands of options.


Parameters... more can be added later:


maplat - map center latitude

maplon - map center longitude

mapzoom - map zoom (maybe needs another variant)

mapleft - left edge of map (longitude)

mapright - right edge of map (longitude)

maptop - top edge of map (latitude)

mapbottom - bottom edge of map (latidue)


gpslat

gpslon

gpsspeed

gpsalt

gpstime

utctime

systemtime


trackname - name of (last) selected track

...


With {trackname} parameter, I could e.g. add a custom button that would launch a google search for the track name. Why is that useful? Because when you download tracks from trip portals, they unfortunaley mostly lack any sort of description. By googling the track name, I can normally find this description in the trip portal again when I need to.

photo
1

This might all just sound like a "gimmick" to people who come home every night and do their trip planning on a PC. But when you're away for longer with just your smartphone, things start to look different.

photo
1

It is quite logical ... anyway you cannot expect that even a most useful feature for you, will be implemented without at least few more people who find this also useful. And best method I have for this now, is voting...


Thanks for understanding.

photo
1

I know I know... same old problem... too many sunday afternoon geocachers... too few "adventurers"... ok... lets wait and see :)

photo
1

To me this idea seems one of those where in the beginning we can't image all possible use cases, but once it's implemented, people may come up with creative ideas how to use it beyond our current imagination.


It's also rather simple to implement, I guess, and it'll not disturb those who don't need it, so I voted in favor of it.

photo
1

Here's another possible and fancy usage: Locus checks the http result of the URL on click. If mime type is gpx/kml/kmz, download & save the result to "Locus/data/temp/{buttonname}.gpx/kml/kmz" and then display it (like map items) instantly.


Result? We could http query any kind of geo data (weather, wind, volcano activity, thunderstorms, whatever) and have instant visual result on our maps.

photo
1

Menion ● 17 hours ago:

>Hmm interesting. Have to say .... why not.

>Find at least ten votes (ten people who find this useful) and I'll look at it.


no comment.. :D

photo
1

Hmm interesting... from 12 votes, voted 8 people who had no ideas, no posts, no comments ... just fresh accounts.


Oki, maybe next time I'll try it with "20" votes ... damn :)

photo
1

There are a lot of travelling Locus users... they just need to be found to compete with the geocaching crowds :).

photo
3

You have forgotten - Stefan has a big community: http://www.alpenzorro.de/


"20" also wouldn't a big problem because as Stefan wrote: this idea has potential and so many possibilities.

photo
1

... maybe also together with locus-action:// urls.

photo
1

about mime type.


Is it smart to use it?

Because user with low knowledge will assingn the wrong app to mime typ and then - we read again a lot of "bug reports" here :o)

photo
1

Regarding MIME type, I was talking about the RESPONSE from the url and how/if it can/should be handled by Locus. Nothing to be assigned there by the user, it's a server thing. People who set up their own serves usually understand mime types.

But to handle/display responses, Locus would have to download the URL itself and not fire up a browser. That's normally not what I want... basically I just want to open a browser with the trip portal web site at the correct position.

So I guess forget about the response handling for now... just call the default browser with the URL.

photo
1

Nice idea. I support this.


Greetings jusc

photo
1

Still collecting votes? Come on... Its already more than twice the number you asked for :)

photo
1

Right. And what you expect? That I'll immediately leave work I have planned? Nope, sorry. Task has now just special place in long topo/check list ...

photo
1

I just thought there'd be a state change in the topic when the "required vote count" is reached... but maybe I still didn't get the hang of this web 2.0 voting/liking stuff... sorry... still an old "forum guy"... :).

photo
1

I'm usually change state of topic when I really start doing something ...


I was already thinking about this some time. Configuration over config is possible, but little bit cumberstore. UI for configuration will be on second side quite complex and I'm in small time pressure now ...


So task is in my top priority todo list and as soon as I'll have some free time, I'll look at it and give you some feedback. Most probably during June.

photo
2

Version 3.10.3.1 - BETA - first test of this feature


Main menu > More > first button "Quick URI request"


Reusing of live-tracking system is unfortunately more complicated, then writing it from scratch, which will be better solution due to future flexibility. Only help was reusing of small part of "Quick add point" feature.

photo
2

Menion wrote >"Version 3.10.3.1 - BETA...."

waiting - refresh page - waiting - refresh page - waiting - refresh page - waiting - refresh page...


:)

photo
2

Wait wait ... :)


393c321ae3cddc7df130ce382b1146aa

photo
2

done! :)

photo
2

First test was ok with exists vars

About time:

Server has received eg "2015-07-08 23:59:41:729+0200"

or

"{timeUtc}"


I'm able to give a format?

photo
2

Hmm fine ...


Time was made with hot needle as I wasn't sure what is best solution. Not sure if timestamp in UNIX ms since 1. 1. 1970 us usable in all cases or if there is need for some parameters like in live-tracking (hope not). For now, no options, just what you see ...

photo
2

fine, first step done and stefans idea was Completed ;D

photo
2

Nice... wish I had a config.cfg interface and could use a proper editor instead of cumbersome android text fields :). Editing an existing entry only works very rarely here. Most of the time, when I change the URI and hit OK, nothing happens. The OK button blinks shortly but the window stays open and nothing is changed. I can only close it with X and lose my edits.

photo
2

Hmm difference between text editor and editing directly in Locus? Seems that field do not enlarge to more lines, I'll fix this, but except this?


And "nothing" - seems that there is missing some notitication, but check if your url is valid (no spaces, starts with "http" or "www", longer then 10 characters..

photo
2

Text editors are just good at what they do... editing text. You wouldnt edit your source code in an Android text field would you? :)


Anyway... I can understand that config.cfg is not usable in general for public features. Never mind.


Valid URL seems to be the problem... I cannot add a vertical line in a parameter, like layers=Utagawa|GPSies . Then Locus refuses to OK.

photo
2

Ah only "vertical line" may caused troubles, thanks fixed!

photo
1

Hi menion.


Could you please add the current views bounding box as possible parameters? Like

{mapNorth} {mapSouth} {mapEast} {mapWest} ?


I know there is center and zoom, but that doesn't allow talking to OSM overpass api nicely. They want a bounding box.

photo
1

Oki, understand. Added.

photo
1

http://overpass-turbo.eu is a really powerwul thingy that allows extraction of all kinds of OSM data in realtime. With a little more support from Locus, this could turn into a powerful tool. We could e.g. define a "Watersources" button and have Locus immediately show all water sources in the current map view as waypoints. That would work on all kinds of maps, OSM or not, on all zoom levels, regardless if the render theme displays those things prominently or not.

Locus has all the stuff required for this already, it only needs to be tied together properly:

Don't fire up a web browser but download the result data from the constructed URL and store it (silent overwrite) in

/Locus/mapItems/wwwbookmarks/{bookmarkName}.resultMimeType

If resultMimeType is gpx/kml/kmz (or anything else that Locus understands), auto-enable that file as a map item.

Done.

Dozens of cool uses for such shortcuts spring to mind. Imagine e.g. traveling to Gran Canaria and wanting to find out where all the easy rated mountainbike trails are. A click on the (predefined) "mtbscale-S0" and the "mtbscale-S1" buttons will get you there, instead of teadiously and manually scrolling across the whole island in a detailed zoom level.

The distinction if Locus should fire up a web browser or download the result data directly could either be made by an option in the url bookmarks edit window, or by prepending "download:" to the url string, or maybe even automagically: You try downloading the URL first... if its mimeType is gpx/kml/kmz you switch to mapItems handling, if not you fire up a browser.

photo
1

Nice post joeloc, overpass queries are already discussed in this topic: http://help.locusmap.eu/topic/add-overpass-queries-like-where-is-the-next-bicycle-shop

photo
1

Just for testing... the supercharged shortcut buttons could do something like this... on a single tap... right inside Locus... where it belongs:

http://overpass-turbo.eu/s/dRb

photo
1

I was also thinking about something like this (Locus not opening a browser, but doing the http request by itself and use the returned data directly) some time ago.

But this would require overpass to have an option to return gpx/kml/kmz directly, which I have not found yet.

As far as I know, overpass can generate this filetypes, but only after manually clicking export on the overpass website!?

I only found this:

http://overpass-api.de/output_formats.html

None of this output options is supported by Locus directly, I think.

Does anybody have a clue how this could work?

photo
1

Setting up a simple json2gpx.php on some random server is a matter of one hour maybe. The URL for Locus shortcut buttons would look somewhat like this then:

http://randomserver.de/geojson2gpx.php?json=http://overpass-api.de/api/interpreter?data=<overpassquery>;

photo
1

Ok, this of course possible. I was searching for a solution without using another server.

Maybe this will be supported by overpass sometimes in the future.

Meanwhile, if you happen to implement such a converter script, I hope you don't mind sharing it ;-)

photo
1

Sure.... but since this topic is "completed", don't get your hopes up. Urlbookmarks might go down the same road as many other things in Locus: Could have been useful but were terminated just two manhours too early :-).


Another example for this: "map items" could totally rock if they were simply and silently auto-updating on file modification. We could have done many nifty things with this... like auto-syncing data with friends... displaying new pictures as soon as they are taken... even buddy tracking without external servers and emailing random people on random forums.


Oh... and if map items were auto-updating already, doing this little addition here to urlbookmarks would be two lines of code more or less. Maybe twelve if you wrap it in a separate non-blocking thread, where all network stuff belongs.

photo
1

Correct, completed topics has no chance to get any more attention, sorry.


Ah, FileObserver implemented (3 hours because of some weird issues in Android).

photo
1

Thanks for the auto-update feature! Now it might make sense to find/write apps to create gpx/kml for all kinds of geotagged data (eg fotos/contacts/etc) automatically in background whenever they are changed.


I also wonder if this could somehow work together with file clouds (google drive, drop box etc). Maybe if track/point folders in Locus had an auto-export-to-gpx-when-changed feature and we set the paths to some autosycned folder shared with a friend, this whole thing could lead to buddy-tracking and buddy-data-mirroring without the need for dedicated external servers (except the file cloud).


I basically have those things in mind:


Whenever I take a new foto (or one comes in via wifi from a real camera), it should show up automatically in Locus.


When I am on a trip with a few buddies and any of us adds waypoints/tracks relevant to our current journey, they should show up in each others Locus automatically.

photo
1

Tested the new boundingbox parameters for WWW-Bookmarks, working as expected! Thanks!


So what do you think about an option to request the URL (and download the result, e.g. to MapItems-Folder) directly in Locus instead of calling an external browser?

joeloc already asked for this. Together with the new MapItems auto-update, this would be a very handy and flexible way to request and display dynamic data from the internet!

photo
1

Hmm not sure about it. As someone already noticed somewhere ... there will be need to handle results correctly. For now Locus is able to read just a few file formats, not any special JSONs or OSM XML files.


If someone give me any usable links to web services that offer some GPX or KML files as results to questions, I may think about it.

photo
1

I don't think Locus needs to handle anything specifically here. Don't care about what you download... just grab the data and save/overwrite it quietly to mapitems/urlbookmarks/<bookmarkname>.<resultmimetype> and enable this file as a mapitem.


The map item code will find out later if it can handle the format. If not (no gpx/kml/kmz/zip)... nothing is lost.


I will write some osm-geojson to gpx php... this should not be part of Locus but run someplace else.

photo
1

I just hacked a little php to translate overpass json api output to gpx on the fly.

When used within url bookmarks in Locus, it opens an Opera browser which displays the gpx file in XML notation. Not very useful for now. I guess it's menions turn again to download this instead of open a browser, save it, use it as mapitem, all automagically. Should be quite straight forward.


hmm... sorry... this editor here goes totally crazy when I try to insert my example URLs...


http://tinyurl.com/zqpfavo

for an example. Sorry for the tinyurl stuff... but I really cannot paste complex urls in this editor. It majorly messes them up. See screenshot below for Locus settings. My script parses the json tracks from overpass into a gpx file with one waypoint per track, name is mtb:scale difficulty, desc is all other osm properties. Obviously only an example, will add more options as soon as we find a way to get the data into Locus without major headaches (= without any other clicks)


5b08049116b8cd6a6781cccca694bacf


  1. <?php
  2. if (defined("STDIN")) // from shell
  3. {
  4. $url = $argv[1];
  5. }
  6. else // from web
  7. {
  8. $url = $_GET['url'];
  9. }
  10. header('Content-Type: application/xml');
  11. //header('Content-Type: text/plain');
  12. $url = str_replace(' ', '%20', $url);
  13. $json = json_decode(file_get_contents($url));
  14. echo <<<EOL
  15. <?xml version="1.0" encoding="utf-8" standalone="yes"?>
  16. <gpx version="1.1" creator="overpass2gpx"
  17. xmlns="http://www.topografix.com/GPX/1/1";
  18. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
  19. xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd";
  20. xmlns:gpx_style="http://www.topografix.com/GPX/gpx_style/0/2";
  21. xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3";
  22. xmlns:gpxtrkx="http://www.garmin.com/xmlschemas/TrackStatsExtension/v1";
  23. xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v2";
  24. xmlns:locus="http://www.locusmap.eu">;
  25. <metadata>
  26. <desc>$url</desc>
  27. </metadata>
  28. EOL;
  29. foreach($json->elements as $ele)
  30. {
  31. if ($ele->type=="way")
  32. {
  33. //var_dump($ele->tags);
  34. $middlenode = $ele->nodes[count($ele->nodes)/2];
  35. //var_dump($middlenode);
  36. foreach($json->elements as $n)
  37. {
  38. if ($n->id==$middlenode)
  39. {
  40. $name = "S" . $ele->tags->{'mtb:scale'};
  41. $desc = json_encode($ele->tags);
  42. $desc = substr($desc,1,strlen($desc)-2);
  43. $desc = preg_replace('/"/','',$desc);
  44. echo <<<EOL
  45. <wpt lat="$n->lat" lon="$n->lon"><name>$name</name>
  46. <desc>$desc</desc>
  47. </wpt>
  48. EOL;
  49. }
  50. }
  51. }
  52. }
  53. echo <<<EOL
  54. </gpx>
  55. EOL;
  56. //var_dump($json);

photo
1

Since the complete URL as parameter only caused major headaches, you can now simply pass data=... to my script as well. It is directly sent overpass-api. So here's finally a working example to copypaste into your www bookmark config:

http://www.alpenzorro.de/overpass2gpx.php?data=[out:json][timeout:25];(way["mtb:scale"~"[0123456]"]({screenLatBottom},{screenLonLeft},{screenLatTop},{screenLonRight}););out%20body;>;out%20skel%20qt;

photo
1

So far so good... I can click on my URL bookmark now, a web browser opens and is forced into downloading "test.gpx" by my script using an unknown mime type. Then test.gpx can be imported manually into Locus to get the data. On subsequent calls, this will be test-1.gpx, test-2.gpx etc (depending on Browser) and obviously this turns into a major headache until the data is in Locus.


To make this all worthwile, Locus needs to support direct downloading instead of browser launching. The filename should be something like mapitems/bookmarks/<bookmarkname>.<ending> . Not sure what the best practice would be here and where to get the ending from. I could return a header like

'Content-Disposition: attachment; filename="overpass.gpx"

Could you read this easily? And maybe prepend <bookmarkname>?


The idea here is to have lots of pre-configured bookmarks shipping with Locus, eg

"Singletracks"

"Watersources"

"Bikeshops"

etcpp.


On tap, they should then produce "mapItems/bookmarks/Singletracks.gpx" etc and auto-enable that as map item. On next taps, the file needs to be quietly overwritten and updated.

photo
2

Obviously this could work for many other things as well, if we have it flexible enough. I am pretty sure there are e.g. Panoramio or Flickr URLs to query that kind of data...

photo
2

I rely appreciate the way the topic is followed up !

I can see some great progress coming up, if you guys put together your knowledge.

photo
1

@joeloc: Just to give me a little deeper understanding:

Overwriting the "mapItems/bookmarks/Singletracks.gpx" will not overwrite my former mapitems (eg Waypoints)?

photo
1

It doesnt really work as mapitems yet... not unless menion implements direct downloading to the proper paths. Until then, the gpx downloads are managed by whatever browser you chose to launch. And then you have to manually find the correct gpx file in your download directory and import it to Locus manually.

photo
1

Yes, I already tested it out in that way.


1cb6446f65ff88e07ff466bde1d1546aI was asking for the described future behavior.

photo
1

The future behavior depends on menion :)

photo
1

gomme-singlemap

Script test run to find all mountainbike singletracks on Gomera. This is really quite useful if you dont know the area. You can immediately figure out if and where it makes sense to go.

Of course mapsforge will also render singletrack scales on higher zoom levels, but you would have to tediously scroll across the whole island to find out whats going on.

photo
1

menion... if you happen to be working on direct download... you can test with different mime types by using mime parameter, eg


http://www.alpenzorro.de/overpass2gpx.php?mime=application/xml&data=[out:json][timeout:25];(way["mtb:scale"~"[0123456]"]({screenLatBottom},{screenLonLeft},{screenLatTop},{screenLonRight}););out%20body;>;out%20skel%20qt;

Replies have been locked on this page!