I have an application that needs to display the path taken.
The coordinates are stored in a database. In a similar question,
it was suggested to use drawTrackElement. That requires the data to come from a file. Is there a way to build the list of points in memory or use the database directly?
Try a polyline: http://developer.skobbler.com/getting-started/android#sec009 and see if the result is acceptable to you (if you have enough points in the polyline then the result should be quite smooth).
Related
I am creating an android app which is notify location to get off from the bus. It shows bus route by using poly lines and when user enter the destination, it also shows the path from current location. My question is how can I get the location of intercept point. I have attached a screen shot here.enter image description here
This question is a bit ambiguous, I recommend you first search and show your effort (or code) or whatever you did to solve your problem and give more context,for instance, ¿are the routes are in lat,lng format? etc.
Regarding this, there is a lot of algorithms to acomplish what you are looking, like:
How to find if an intersection occurs between two line segments represented by a Latitude and Longitude
Efficient list intersection algorithm
or a mathematic aproach in case you want to programme it by youself:
http://www.wikihow.com/Algebraically-Find-the-Intersection-of-Two-Lines
IMHO I would pre-calculate the intersections points before, store it and then compare it with the realtime position (lat,lng) of the users. If the user is near one of the intersections (with algorithms like: How to calculate the bounding box for a given lat/lng location?), show it.
Hope it helps.
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.
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.
What would be the best way to do this?
I have an application that gets two values about each and every 10th second (when user touches the screen). From this i get two values, latitude and longitude of a sphere object that the user has touched.
Now I would like to compare thoose values to values from a file, with the real latitude longitude of a location and then compare thoose values and se how far away the user was.
My file will be built up with two values and one key (location) in each index.
What would be the best way to do this, would it be to read the whole file in the beggining with a bufferedInputStreamReader and store thoose in a
HashMap<String, List<Float>>
or would i be better of using some kind of database structure like SqlLite?
Since Im doing this on a mobile platform performance is quite important and that's mainly why i ask this question.
Depending on the size of the data you need to compare against, you could either look up each time against a database (slower) or do a binary search in memory (faster).
If you store in a HashMap (for the in memory method), then you will need to sort and implement a binary search for maximum speed. Otherwise you will be searching linearly (iterating) throughout the collection of values (that might be acceptable to you).
I would say if you have a few thousands entries, then do it in memory, if you have more then go down the database route.
I am looking into writing an Android app that has a database of approximately 2000 longitudes and latitudes which are effectively hard coded.
I assume that once my app is installed, I can put this information into the SQLite database, but how should I distribute this information when the app is downloaded?
One option I thought of was some kind of Patricia Trie to minimise the size of the data (the points will be in a number of clusters, rather than evenly distributed), but I'm not sure whether such a collection would work when there are two associated numbers to store, along with perhaps some other information such as place name.
Does anyone have any thoughts, input or suggestions?
Rich
2000 ints is not many.
In fact I recently tried to load up my web app that has similar numbers for lat lon. I realized i need to optimize a bit, but its load time wasn't completely terrible.
You may want to just request the data you need at any given moment. There must be some other data associated with the lat lons that can help you with that... or maybe you should only display pins within some boundary of lat lon, like +1,-1 in every direction of the center of your map or something.