retrieving the maxspeed tag in openstreetmap - android

I want to create an android application that warns me if I am to exceed the speed limit, and I thought of using the maxspeed tag in openstreetmaps , but when I got the data using the API I can't find the speedmax tag but it's there when I lookup the place in the site. is there any other way to retreive the max speed limit for each road to use it in my app ?

You are searching for the maxspeed=* tag http://wiki.openstreetmap.org/wiki/Key:maxspeed (query taginfo on right sidebar)
Furhtermore there are different solutions for your task:
Ask existing map creators on help/data (lookup "Maps" in OSM Wiki)
Create a query for the Overpass API maybe helpful is Overpass Turbo
Filter OSM Planet extracts on your own using osmosis and appropriate filter expressions
Please keep in mind, that dealing with OSM data can be difficult, as for example speed units depend on the country, same as defaults for untagged roads.
P.S. It's called OpenStreetMap (without -s) ;)

http://www.overpass-api.de/api/xapi?[maxspeed=][bbox=31.454403,30.082119,31.454266,30.082093]
just use two points (LAN/LAT) on the same road to get the road details

Related

Best technique for storing custom map polygons in Android and ray casting

I'm fairly new to Android and trying to develop an app that identifies if a user's location is inside or outside of a given region within a state. My approach is to take the user's latlng and use ray casting to identify which region they are inside (they must be inside 1). My regions are best equated to state park lines, but Google does not have these in Google Maps (and they're too irregular for geofencing). As such, I created customer polygons. I'm not struggling with the code, but struggling with the best way to handle data.
How should I store and access the polygon data for ray casting? I was taking the approach of storing the polygons in an XML file but I'm worried about the time and processing power it may take to parse the XML and run a ray casting across up to 30 polygons in a given state. My polygons are complex enough that the XML file for one state is upwards of 4MB. My polygons only need to be read, not written, as they'll come with the app.
I think that your best option is to store your polygons is a geographic database. The best solution I've found so far to do so is SpatiaLite which is build over SQLite and works really well on Android.
Using this approach you will store you polygons in the database and query what polygons intersect with a given LatLng (Point). The query will look like this (not tested):
select * from polygons_table where st_intersects(Geometry, MakePoint(longitude, latitude, 4326));
Note that I use 4326 as the SRID because I assume that you will store your polygons in WGS84.
Here you can find the SpatiaLite 3.0.0-BETA SQL functions reference list.

Path between two very far points on google map in android

I am trying to develop very basic GPS App and want to highlight path between two cities. I used the code in the following post
Answer : Draw path between two points using Google Maps Android API v2
by zeeshan0026.
And the code works fine but when you highlight path between two very far cities then it shows the straight kind of path. I think the problem with the number of LatLng points return by the decodepoly function i am trying to change the shift but nothing helps.
Please somebody help me in this regard.
Thanks in Advance
Directions API URLs are restricted to approximately 2000 characters, after URL Encoding. As some Directions API URLs may involve many locations along a path, be aware of this limit when constructing your URLs.
For more accurate path between very far cities, we need to use the polyutil.encode and decode functions.

The most compact map file format?

I am trying to understand all this map formats for OpenStreetMap and I really got confused.
The OSM wiki has lots of information, but it looks like it is spread all over different places and i cannot get solid understanding of all the formats.
I am looking for something that can be used in Android for offline use. I know that there are lots of frameworks or even done apps that use different file formats, but as for me they file formats they use are all huge.
As I understand the most lightweight format supported by OSM is PBF-Binary, and it is raster format, right?
I have found that it's possible to convert it to *.map format that is vector, right?
The size then is about 40% less than PBF-Binary, but it has to be rendered and it will not be as fast as raster, right?
So another question is, what is the most compact OSM map format that can be used for android?
I know one app that i use a lot - MapsWithMe and it has small map files and they are very fast, but i don't know if it uses raster or vector, i know only they use OSM maps, but as i understand they have created their own format based on it or smth like that.
I have come across GeoJson and the map files are very small, not more than several megabytes. So now i'm getting confused why it is so, why then it's not used for mobile development, cause i googled 'geojson android' and no information about it.
Are there any comparison tables of these formats?
So if somebody has a link where i can learn about all this things, could you please give it to me?
Thanks
PBF format is a much smaller alternative to XML. It contains the same raw vector data. You can convert from one format into the other without loosing any information. PBF is smaller and faster because it is binary data whereas XML is plaintext. The OSM wiki has a short overview of common OSM file formats.
I don't know where you got the information that GeoJson is small. The size of a map depends on several attributes. Mainly coverage and detail. Usually you don't want to have an offline map covering the whole world on your device because it will be very large. Most of the time you just need a small area, like a country. And often you don't need every information OSM can offer. Roads, cities and important POIs are usually sufficient for routing and searching.
You didn't tell us what you want to do with the map. Just drawing it? Or do you also need a routing and search functionality? What map format would be the most useful for you depends on your use case.
There is already lots of software for Android using OSM, including various open source programs. You can take a look at them if you need inspiration for your software.

Best way to deal with big (shape-)data for map in Android Application

I am building the prototype for an Android app that should result in a versatile map that can deal with a large but static amount of environmental data combined with (user-generated) data that will be hosted on a separate platform.
My current approach is to fetch the large static data via Google Fusion Tables (in original a shape file - .shp, .dbf, .shx that I have exported as a .kml with QGisMaps - the "smaller" .kml I am using is already 66.4MB, the one intended for final use over 140 MB...) I know it is possible to slice down .kml but will this have an effect on loading times?
You can see a current example of the shape data on Google Maps here https://www.google.com/fusiontables/DataSource?snapid=S717313eWaJ
But now I am wondering if I am on the right path at all since this one layer of data is loading very slowly on my machine and I am not aware of the hassle to put this map into an Android app - and more importantly also fetching more data from a separate server and putting it as another (filterable) layer on top of it. This layer will be collected data from users, thus not "static" but regularly updated - integer values displayed in color per geodata.
Several people hinted me to use Open Street Maps but some advised that Android is very eloquent with Google Maps - in the middle of development I thought maybe someone can tell me whether I chose the right direction to go for or are most likely facing less problems with an alternative solution.
I would be really glad if someone could advise me on the issue with combining map data from two different sources layerd onto one map in Android whereas one bunch of data is huge but static and the other user-generated values.
Thanks so much for your time and looking over this
best
Birgit
EDIT #1: I am now switching to Open Street Maps, hoping to be able to set up a GeoServer myself hosting the data and querying the WMS with the App. It seems like the size of the data still has to be compressed in some way, I will keep you updated.
I'll not be able to address all of your concernes, but I can share some of my experience with maps and ovelays.
The most important concept you must be aware is the memory heap. Each android application has a maximum memory amount that can be used to allocate data objects, called memory heap. This limit is different from device to device and can go from 16MB in small older devices to 64MB in new tablets.
Having said that, you will never be able to load all your data at one shot if the data structure required to hold it exceeds the maximum heap available for the application.
Also, usaging large amounts of memory makes your application better candidate to be terminated by users or by the SO when additional memory is required by critical activities (like a phone call).
Now, going to the maps part...
I've used Google maps as well as mapsforge api for OpenStreet maps. Google maps requires internet connection, while mapsforge enables you to use a local map file or online connection. OpenStree maps don't provide the sattelite view.
Regarding performance, online connection tends to be faster, as they download already rendered map images, while offline map requires the images to be rendered as needed. Mapforges can use a local cache to improve this a little.
Displaying Overlays:
I've used both API's to display paths with arround 10.000 points over a map, together with additional overlays (compass, scale bar, pop-ups, etc.) and the code runs smoothly in a mid-rande device. However, my code have some optimizations to reduce recreation of paths (when user zoom or move map) by transforming the already existing path.
good luck.
So this is how I eventually converted a .shp file into a format that could be displayed by OSMdroid's XYTilesource.
I exported the layers separately as .kml projected WGS84 and imported them as layers to TileMill. After having defied the colors for each layer in CSS, I exported my map as a set of MBTiles. I uploaded them to Mapbox.com. From there I can fetch the tiles which are in the format a.tiles.mapbox.com/v3/myUsername.myTiles/{z}/{x}/{y}.png in my OSMdroid Mapview.
final myTileSource tileSource = new XYTileSource("myTiles", null, 10, 16, 256, ".png", "http://a.tiles.mapbox.com/v3/myUserName.myTiles/");

getting multiple marker coordinates in google map android

Hi to all the members of this great community!
This is my first question so forgive me for possible mistakes. I hope that from this day on i can be helpful for some of you as hopefully you will be for me.Getting to the question:
I am building an android app whose purpose is to search for nearest fuel-points and nearest care-repair-centers. I am very new to android and thx to the numerous posts about android in here I have managed to reach the point where i have build the map and animate it to my current location while updating my location.
Now i have to add the markers of the points of interest. Since they are at least 10 (I will add them only for demonstration purposes) i think it's not wise to add them through 10+ repetitive calls to itemizedOverlay.addOverlayItem(). My idea was to save them in a file in the format ( " latitude " , "longitude" , simple_description_title , other info ) and than in some way import the first 2 fields for the geopoint and the 3rd for the title.
I will use than the 4th later for some type of tooltip text (for example tel_number).
Do you think this is a good approach? And how can I implement the file reading(if) in the code that extends ItemizeOverlay().
I didn't post the code until this point since it's irrelevant.
Welcome to SO, let's jump right into your problem/question.
1.) Since you are only adding 10 points of interest it won't matter if you just call itemizedOverlay.addOverlayItem() for all 10 because the trick is to call itemizedOverlay.populate() only after you have added all the overlayItems using itemizedOverlay.addOverlayItem(), this way you don't compromise on performance.
2.) Now, once again, since you are only doing a demonstration I would advise you to simply hard-code all the 10 overlays with their respective geolocations into the Android code itself. This way you WON'T have to worry about reading data. Also, using a txt file to store data isn't the best option both performance and convenience wise. This is what databases exist for.
3.) If, and when you do this in the future, you do need to use some dynamic data to populate your markers with, then I'd STRONGLY advise you to use either
SQLite: The embedded database that Android offers, it's great for storing small bits of information that's required for your application such as description title, other info, the latitude, longitude, however, if you have some sort of a connection based application where you need to update globally accessible data every once in a while I'd advise you to use the next option,
MySQL: This is an online database that you have to interface with using a server and PHP. The advantage of using an online database is that you can now share information between different users (friends, contacts, followers etc.) by reading and writing to and from the database.

Categories

Resources