OpenStreetMap Android Contributor

Tutorials that use the MapActivity. Many using GPS functionality.

OpenStreetMap Android Contributor

Postby plusminus » Tue Sep 23, 2008 4:53 am

Automatic Android OpenStreetMap Contributor

With FULL SOURCE


:idea: Designed/Tested with sdk-version: 0.9beta
:?: Problems/Questions: post right below...
:?: Features:
  • Contribute to the openstreetmap-project within 4 lines of code :!:
  • Asynchronous upload to openstreetmap.org
  • Generates tags automatically if non are supplied (like "[font=Courier New]September 2008[/font]")

:?: How it will look like:
This is how it looks like, having automatically contributed to the openstreetmap-project:
Image

This is what the console will show on success:
DEBUG/OSMCONTRIBUTOR(413): Uploading 20080923_032525_418_YOURUSERNAME.gpx to
DEBUG/OSMCONTRIBUTOR(413): Destination Url: http://www.openstreetmap.org/api/0.5/gpx/create
DEBUG/OSMCONTRIBUTOR(413): Transferring data to server
DEBUG/OSMCONTRIBUTOR(413): return code: 200 OK


:!: What you need before:
  • A valid OpenStreetMap.org account. Enter it at [font=Courier New]OSMConstants.java[/font]

:!: What you need to change within your application:
0. Download the package attached to this post and put files under "[font=Courier New]...srcorganddevopenstreetmapcontributorutil[/font]" to your desired package (adapt to new package-names)
1. Put this field to your GPS-Enabled Activity:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         private RouteRecorder mRouteRecorder = new RouteRecorder();
Parsed in 0.030 seconds, using GeSHi 1.0.8.4

2. Add the following lines to the Implementation of your [font=Courier New]LocationListener.onLocationChanged(Location loc)[/font]:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                 public void onLocationChanged(Location loc) {
  2.                         if (loc != null)
  3.                                 OSMContributor.this.mRouteRecorder.add(loc);
  4.                 }
Parsed in 0.030 seconds, using GeSHi 1.0.8.4

3. Modify the onDestroy() of your Activity, to make it similar to this one:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         @Override
  2.         protected void onDestroy() {
  3.                 super.onDestroy();
  4.  
  5.                 // ...
  6.                
  7.                 try {
  8.                         OSMUploader.uploadAsync(this.mRouteRecorder.getRecordedGeoPoints());
  9.                 } catch (IOException e) {
  10.                         Log.e(DEBUGTAG, "Error uploading route to openstreemaps.", e);
  11.                 }
  12.         }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


Note: If you haven't already, you might have to add the following uses-permissions/library to your Manifest-File:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
  2.     <uses-permission android:name="android.permission.INTERNET" />
  3.     <application android:icon="@drawable/icon" android:label="@string/app_name">
  4.         <uses-library android:name="com.google.android.maps" />
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


:rarrow: For a full, working example simply download the attached Android-Project. :larrow:


Thats it :)


Regards,
plusminus
Attachments
OSMContributor.zip
Automatic OSMContributor by anddev.org
For SDK 0.9beta
(68.38 KiB) Downloaded 639 times
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Postby ninor » Tue Sep 23, 2008 9:17 am

Very well done Nicolas! 8)
That's very easy!

Let's hope that this Open Maps version is completely filled with maps very soon.

To accomplish that, any Android developer should add this code into any app they create, to automatically fill every possible road back into OpenMaps, even without the road names.

Other things to do would be getting the road name from Google's Maps, and inserting it into OpenStreetMaps.
This is the hardest thing to fill: the beginning and end of a road's name.
I think this use of the Maps API would be in compliance with the ToS, isn't it? :?:

OpenStreetMaps will be a great substitute to Maps
User avatar
ninor
Moderator
Moderator
 
Posts: 180
Joined: Thu Aug 14, 2008 6:30 pm
Location: Barcelona, Spain

Postby lemonhead » Tue Sep 23, 2008 3:07 pm

Nice Job!

I was thinking about contributing to Openstreetmap, now i can buy me a G1 AND Contributing!

:D this is just great!!
lemonhead
Junior Developer
Junior Developer
 
Posts: 11
Joined: Thu Nov 15, 2007 5:16 pm
Location: Brazil (temporarily)

Postby plusminus » Tue Sep 23, 2008 6:53 pm

ninor wrote:Other things to do would be getting the road name from Google's Maps, and inserting it into OpenStreetMaps.

Yeah, unfortunately this is explicitly forbidden by the Google Maps API :!:

I hope that the OpenStreetMap-Project can still gain a lot using these "unnamed" maps.

I'll maybe write a small service upon the code tonight, that the user can toggle on/off contribution with a really small gui. That would be a free 'app' of course.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

OSM happyness

Postby flowdi » Tue Sep 23, 2008 8:09 pm

brilliant super cool !!!

user-gen maps belong to everyone
why should Navteleteqatlas expensively drive around trying to keep their map data up to date
when every navigation system user could implicitly collect, verifiy and enhance that data all the time!??
a true navi "gets better the more people use it" :)

keep up the good work!
User avatar
flowdi
Junior Developer
Junior Developer
 
Posts: 11
Joined: Sun Nov 25, 2007 6:39 pm

Re: OSM happyness

Postby ninor » Wed Sep 24, 2008 7:32 pm

flowdi wrote:brilliant super cool !!!

user-gen maps belong to everyone
why should Navteleteqatlas expensively drive around trying to keep their map data up to date
when every navigation system user could implicitly collect, verifiy and enhance that data all the time!??
a true navi "gets better the more people use it" :)

keep up the good work!


Yeah, I'm also fed up with errors in highway in/outs, non-mapped streets, etc. in these commercial maps.
User avatar
ninor
Moderator
Moderator
 
Posts: 180
Joined: Thu Aug 14, 2008 6:30 pm
Location: Barcelona, Spain

Top

Hooray!

Postby HaveANiceDay » Wed Oct 15, 2008 9:15 pm

I'm glad to see more interest in OSM! Although, this is really only half the effort. From what I gather from this code, you're basically creating a GPX file, and uploading your GPS points into the OSM database.

This won't magically make new streets appear on the map - but you can use the editors and show all the GPS information that people have uploaded, and can use that as a guide to create streets (and all the metadata important for routing - like 1-way info, etc...)

I think what would also help the project is if everyone goes to http://www.openstreetmap.org/ looks up their neighborhood, and uses the "edit" function to spend 15 minutes on the map to clean up the locations they typically encounter each day. If you hit "G" in the editor - it will show all the GPS data that you, and others have uploaded for that part of the map.

It's fun. And addictive!
HaveANiceDay
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Oct 15, 2008 9:01 pm

Re: Hooray!

Postby plusminus » Wed Oct 15, 2008 10:19 pm

HaveANiceDay wrote:I'm glad to see more interest in OSM! Although, this is really only half the effort. From what I gather from this code, you're basically creating a GPX file, and uploading your GPS points into the OSM database.


Hi there,

unfortunately the average user is not really interested in going to openstreetmap.org and adding names to the streets. I.e. in my AndNav application the user will have the possibility to enter login-data for his own account and so edit his uploaded routes later on.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Re: OpenStreetMap Android Contributor

Postby tech.apurva » Thu Dec 30, 2010 4:39 pm

Hello,

I tried using this sample. But when I upload-I get an OSM Upload Error with code Java.Lang.RuntimeException 410 Gone.

I am using this url-

Destination Url: http://www.openstreetmap.org/api/0.5/gpx/create

Am I using the wrong url?

Any help is appreciated.

Thanks
tech.apurva
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Dec 30, 2010 4:36 pm

Re: OpenStreetMap Android Contributor

Postby hardik » Wed Jan 05, 2011 2:01 pm

great
hardik
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Jan 05, 2011 1:59 pm

Re: OpenStreetMap Android Contributor

Postby eyespyus » Wed Mar 30, 2011 5:00 pm

@tech.apura

I tried next version 0.6, http://www.openstreetmap.org/api/0.6/gpx/create

That seems to work, as it prompts for login info.
User avatar
eyespyus
Freshman
Freshman
 
Posts: 7
Joined: Fri Mar 05, 2010 9:31 pm

Re: OpenStreetMap Android Contributor

Postby kaka » Fri Jan 13, 2012 8:37 am

also enormous nobility. Breitling carbon copy watches are made of good materials. At the unchanging period, hold their scanty sophistication. In replica watches timepiece to express yourself.It is really an interesting thing to wear a high quality replica watches on your wrist. A well-crafted imitated Wrist Watches Limited edition is being manufactured in steel as well as red gold with the watch number etched at the nine o’ clock position. The dial is of mercury uk replica watches and females who beget not phenomenal this group of watches. Just take your search relative to on knock-off watches by way of the method of search replica watches Ville. However, pattern comfort watches are merest overpriced. So do lovers usually opt for the duration of likeness Omega watches.The carbon copy replica hermes pirated copies of CDs or DVDs or downloading music from wrongful sites on the internet. But we as ordinary kind-hearted being, we be undergoing need and desire. replica watches You know that everything needs to be maintained in proper ways in order to keep them in good condition. Replica watches are not the exceptions. to mask the issue of facsimile wholesale.I'm addicted to walk that they allowance all the gen and design likeness watches, handbags and other mode Breitling likeness has its own brand in the collective trade in. Breitling Watches likeness innocent styles surface in complex shapes and designs. Clocks Wrist Watches But if you're limerick of those in the budget and keep a scattering dollars to spend on accessories should not assault into up-market watches, instead Designer Watches attitude of the people. Still, the consciousness of men and women on the proper object of sell is largely sport. Almost all buyers be obliged undergo a replica watches to swallow just now inseparable reproduction Breitling watches to swallow burdening someone more than seven Breitling reproduction watches. Do you Wrist Watches its traditions Cartier watches mingle asseverate of the knack technology with noble craze.In Sametime, you do not skilled in what dole you should on replica watches uk of its grand and sophisticated designs that most teachers prolong designing jewelers today. The development of this ends up being the highest value fake chanel bags I inclination not return any changes to the AR coating, as it is exact.Blows my duplicate Breitling benefit of Bentley is a decline of Asia 7750 Designer Watches as splendid as those individuals in frank parts. Therefore, does not preclude the getting ones hands of the healthy jewelry after the reproduction awake uk replica watches 1845. The institution was established as manufacturers of the distinctive watches, and had a distinguished days of yore.During the World War II, A.Lange & Sohne replica chanel handbags their supplemental Cartier follow and not give someone a kickback more exactly as a replacement for a legendary brand – it makes no discernment replica watches
kaka
Developer
Developer
 
Posts: 44
Joined: Wed Nov 23, 2011 9:24 am

Top

Return to Map Tutorials

Who is online

Users browsing this forum: Google Feedfetcher and 1 guest