The quest for all possible geographical intents

408 views
Skip to first unread message

Sanderd17

unread,
Jun 3, 2012, 5:46:46 AM6/3/12
to osm...@googlegroups.com
Currently, Osmand only implements the geo: intent. But there are a multitude of other intents also used. I think it would be good if we try to implement all those intents, and use online or offline search to get a location for those.

1

The first one I have is
Starting: Intent { act=android.intent.action.VIEW dat=content://com.android.contacts/data/1449 }
This is when I click on the location in the default contacts app in Android 2.x (in Cyanogen or in the emulator). The number 1449 is the ID of the contact (as it changes when I click on another contact). Nothing else changes.

The question is, how can we get the address information out of this. I think it can be done with the getStringExtra method from the Intent class. (http://developer.android.com/reference/android/content/Intent.html#getStringExtra%28java.lang.String%29)

2

The intent I see on my tablet's default contacts app is
Starting: Intent { act=android.intent.action.VIEW dat=geo:0,0?q=Vyvestraat%0AOostnieuwkerke cmp=android/com.android.internal.app.ResolverActivity }
This intent can be handled with Osmand, but nothing is found. The only way to find something is when only the street is entered in the query. From the moment there are two fields in the query, no results are found.

The string can be split with %20 when the address is just entered in one blob, or with %0A when the addresses are entered with one data type per field (when you go to your google contacts, you can edit the address of your contacts in two ways). Maybe it is also possible in the second case to get the city name and street name separated with the getStringExtra method.

I have also found other delimiters. Like the Go Contacts app likes to split the fields with a \n. Others could split it with a \t, and this is probably not the end of delimiters.

3

A third one I found is this:
Starting activity: Intent { act=android.intent.action.VIEW dat=content://com.android.contacts/data/4169 cmp=com.google.android.apps.maps/com.google.android.maps.MapsActivity }
This is the same as the first, except that there is a clear reference to the mapps app from Google. So I doubt if Osmand will ever be able to catch this intent. I found it in the contacts app on a samsung.

4

And a fourth, unofficial one I've seen around is the following (this was on an old version of the cyanogen contacts app, but currently, I can't find an app that uses it, so this is not a priority):
Starting activity: Intent { act=android.intent.action.VIEW dat=google.navigation:///?q=Some%20place cmp=brut.googlemaps/com.google.android.maps.driveabout.app.NavigationActivity }
this is a unofficial api to the navigation app from Google. It would be good if we could get those too.

Online vs offline search

Once all intents are handled, the search could also use a bit of work.

Currently, the geo: intent is handled in the GeoAddressSearch subclass of GeoIntentActivity.

The first problem is the parsing of the query string. As currently, only ',' and '+' are accepted as delimiters (if I can read the code right). But in my examples, I also have '%20', '\n', '%0A' and there are probably even more, depending on the app that sends the intent.

Next, when the parsing is fixed, it is possible that nothing is found (because the right maps aren't downloaded etc), so I would suggest searching on Nominatim. One search query of Nominatim doesn't use a lot of data, and if people are really afraid of extra data usage, we could make it a setting (although, people who are really afraid should probably just disable mobile data).

My question

I haven't succeeded in catching that content: intent, so I could use some tips on that, and before I try to work on the GeoAddressSearch, I would like to get a reaction if my ideas have some quality in them or not. I've only been reading code and organizing my thoughts about it now.

I also do a call to others to check if there are even other intents that should be able to launch the Osmand search, and if there are other encodings of search queries (even other delimiters).


Sanderd17

unread,
Jun 3, 2012, 8:48:05 AM6/3/12
to osm...@googlegroups.com
Hmmm, when using the search in GeoIntentActivity, this part has a problem (I can't give line numbers since I've messed a lot in that class)

                         public boolean publish(MapObject object) {
                            if (object instanceof City && object.getId() != null) {
                                cityIds.put(object.getId(), (City) object);
                            } else if(object instanceof Street) {
                                City c = ((Street)object).getCity();
                                if(c != null && c.getId() != null && cityIds.containsKey(c.getId().longValue())) {
                                    connectedStreets.add((Street) object);
                                    return false;
                                }
                            }
                            results.add(object);
                            return false;
                        }

When the results are cities or postal codes, there is no real problem, but when the results are streets, the latitude and longitude are reversed. I want to search a street in Belgium, and I arrive somewhere next to Somalia. Luckily, I see the lat and lon, and I see that they are switched.

Victor Shcherb

unread,
Jun 3, 2012, 9:02:01 AM6/3/12
to osm...@googlegroups.com
Nice research! Please open an issue with these intents. We definitely need to add some intents and take a review on them.

2012/6/3 Sanderd17 <sand...@gmail.com>

Sanderd17

unread,
Jun 3, 2012, 11:40:27 AM6/3/12
to osm...@googlegroups.com
This is quite a big task to get into one issue. I think it's best split as follows:

1. let Osmand listen to the different intents. (enhancement)
3. make better search algorithm: add search for buildings, and try to get rid of irrelevant results (enhancement)
2. the issue of the switched lat and lon for the street results (bug)
4. the issue that countries can only be found with English names. (bug - in my opinion)

What do you think? The 4th one has already been filed, as you know. (btw, I have no rights to edit anything in an issue, so that's why I ask before filing them).

Pavol Zibrita

unread,
Jun 3, 2012, 1:23:38 PM6/3/12
to osm...@googlegroups.com
I would say separate issues.

Best regards,
Pavol

MelTraX

unread,
Jun 3, 2012, 1:36:20 PM6/3/12
to Osmand
I started to work on this a few weeks (probably months) ago. I ran
into a few problems and lacked time and motivation to finish it yet.

You say, you messed with the files already so I wanted to reply as
quickly as possible but it will probably still be a few days until I
can show my code in a reasonable way. It would be nice if you
described what changes you already made.

I, too, want OsmAnd to listen to every type of mapping intent I can
think of. You already listed quite a few and I would even go a step
further and add http intents for Google Maps, Bing, etc. The user
still has the choice to ignore them and use the browser instead.

For the contact intent, some tickets already said that it wasn't
implemented because it needs permission to read contact data. My
current idea is to have a helper application that would listen for
those intents and rewrite them.

Which brings me to the intents themselves.

I started to create custom intents for OsmAnd that can do everything
I'd like to do with OsmAnd from an external application:

net.osmand.intent.action.MAP:
- Name (description to show in favorites or whatever)
- Latitude
- Longitude
- Directions (show directions to position?)
- Navigate (start navigating to position?)
- Zoom
- Application mode
- Original latitude/longitude (for directions that don't start at the
current location)
- Force (if true, OsmAnd starts the required action right away; if
false, a dialog pops up with the given values preset that the user can
change)
- ... (That's all that I started to implement at the moment but there
are probably a few more that would be nice to have. Another option I
want is online/offline.)

net.osmand.intent.action.SEARCH:
- Query (just a text parameter)
- returns latitude and longitude
- the activity that does the search should have a possibility to use
online search tools aswell as offline

Pretty much all parameters for the MAP intent are optional. If no lat/
lon is given but a name is, it will be stuffed into the SEARCH intent.

That's pretty much my vision and some stuff already works. My main
problem at the moment is that MapActivity doesn't set some
initialization stuff if OsmAnd is launched using that activity
directly.

Once those intents are working, we just need a simple activity that
listens for all the geo intents and translates them to the MAP intent.
I already implemented the google.navigation intent but supporting any
of them should be a piece of cake.

I will try to commit my current codebase to https://github.com/MelTraX/Osmand
in the next days. Writing this post already motivated me quite a lot
to actually make it work.

I don't care too much about your points 2-4. Obviously they should be
addressed but I won't do that. :)

That's it for now. As I said, I just wanted to throw my progress out
there before you spend a lot of time on things I already did.

Sanderd17

unread,
Jun 3, 2012, 2:03:50 PM6/3/12
to osm...@googlegroups.com
@MelTraX, thank you for your post. I didn't mess too much with it. I just tried to understand how searching works, and got kinda stuck on it :D

You say you don't care for points 2-4, but they are also relevant for your work, right?

I look forward to your code and hope that I can work my way through it too (apparently, theoretical CS isn't very good to improve your coding skills :D )

Also, you mention Google and Bing, but don't forget openstreetmap ;)

@Pavol also my idea, but with the post of MelTraX, I think I should wait with those things.

Cheers,
Sander

Sanderd17

unread,
Jun 4, 2012, 7:34:37 AM6/4/12
to osm...@googlegroups.com
New intent found thanks to syryos:

The BBBike app send an intent as following:

Starting: Intent { act=android.intent.action.VIEW dat=geo:0,0?q=http%3A%2F%2Fbbbike.de%2Fcgi-bin%2Fbbbike.cgi%3Fappid%3Dandroid-0%26startc%3D13487%252C15888%26zielc%3D-12493%252C-1896%26pref_seen%3D1%26pref_speed%3D20%26pref_cat%3D%26pref_quality%3D%26pref_green%3D%26pref_specialvehicle%3D%26scope%3D%26output_as%3Dkml-track cmp=android/com.android.internal.app.ResolverActivity }

So with the geo: intent (not with http), but the query is a link to a kml file.

Daniel

unread,
Jun 4, 2012, 4:47:50 PM6/4/12
to osm...@googlegroups.com
Hi,

first I would like to say some words to the bbbike app which I published recently. This app adapts the local site bbbike.de which searches excellent routes for cyclists according to their personal preferences.

I searched for a way to show a computed route in google maps. Thereby I found out that google maps supports the rendering of a track when called by an geo intend like mentioned above by Sanderd17.

Syryos led me to osmand. As a next step I would like to call osmand out of the bbbike app and render a local gpx-file. From my point of view it would be good, if osmand would offer own well documented intents beside the standard android intents. In that way the usage of osmand from other apps would become more handy.

For my needs two intents would be interesting:

1. An intent which starts osmand navigating with a local gpx-file.(Same as if you opened a local gpx-file in the navigation dialog)
For instance:
 Intent { act=android.intent.action.VIEW dat=osmand.navigate:/?file=/sdcard/Downloads/biketour.gpx cmp=android/com.android.internal.app.ResolverActivity }
The support of other formats (kml) or other locations/protocols (http/ftp) could be interesting.

2. An intent which starts osmand rendering a local gpx-file (without navigation)
For instance:
 Intent { act=android.intent.action.VIEW dat=osmand.showtrack:/?file=/sdcard/Downloads/biketour.gpx cmp=android/com.android.internal.app.ResolverActivity }
Again: The support of other formats (kml) or other locations/protocols (http/ftp) could be interesting.

So the idea is not only to focus on how to enable  standard android intents in osmand but also to offer osmand specific intents to other apps.

Cheers,
Daniel

MelTraX

unread,
Jun 4, 2012, 5:36:27 PM6/4/12
to Osmand
Yeah, I still have to look into the whole GPX thing but that's
definitely a parameter I want to add to my intent. So your two use
cases should be covered.

Personally, I mainly want to start a navigation to a given lat/lon
point from another application without any questions asked. The Google
Maps app can do that for example. And I would like to have a shortcut
on my home screen that starts a bike navigation to a certain points
without asking questions.

Feel free to list any use cases here that you (everyone) would like to
see. Maybe I'm still missing a thing or two in my plans.

MelTraX

unread,
Jun 8, 2012, 11:17:50 AM6/8/12
to Osmand
Sorry that this takes a bit longer.

I merged the changes of the last months and that took longer than
expected. I still have some commented out code blocks from the merge
so I don't really want to commit yet.

Some stuff is already working, most isn't. I wrote a little test
application that sends all the different intents.

Now I have other stuff to do though and I'm away for the weekend.

This is my current version: https://www.dropbox.com/s/nhdxbow40uhu9tf/OsmAnd.apk
And this is my test app (quite a few still missing):
https://www.dropbox.com/s/lhgq64gqq056qft/OsmAndIntentTester.apk

Sanderd17

unread,
Jun 11, 2012, 10:00:24 AM6/11/12
to osm...@googlegroups.com
Can I find the code somewhere?
Reply all
Reply to author
Forward
0 new messages