How to select a region of GPS coordinates from multiple tracks? - java

I have multiple GPS tracks(vector of 2d latitude, longitude coordinates) that I have created using my mobile device. They have different lengths and directions. I want to average this tracks and create just a single one. As a first step I would like to select only the points that are in a certain area. For example in the image bellow I want to select only the points that are between the grey lines.
Given the fact that the tracks might have different shapes and positioning would a bounding rectangle approach make sense? Are there better algorithms to do this?

I would suggest taking a look into these classes for practical use :
https://commons.apache.org/proper/commons-math/apidocs/org/apache/commons/math3/stat/clustering/DBSCANClusterer.html
http://commons.apache.org/proper/commons-math/userguide/filter.html

I would try clustering points from multiple tracks. After that, I would use the center point of each cluster to get my average path.
For clustering, you can use kNN or any other principle where you group points that are near each other.
After getting your average path, you can apply bounds to it (you could also filter your points before clustering).

Related

Heatmap weighted only by value, not concentration

Im trying to make make a heatmap using WeightedLatLng. Right now it shows an increase in "intensity" for high values or for multiple lower values close together.
I want to be able to only take in to account the values of the weights, not the sum of different points.
Anyway you can create custom Ground Overlay or Tile Overlay with your own algorithm for heatmap. As start point for heatmap creation you can use for example AndroidHeatMap project of tredpath.

Check if the mouse is over a circle - Java

I have an array with the coordinates of the center of small circles which have the same radius. I know how to find when the mouse is over a circle, but my array is big and I want the fastest way to calculate this operation.
Is there a way of finding if the mouse is over a circle without looping all the array for each movement of the mouse?
Initially, set up some 'zones' for quicker reference:
Separate the whole surface into a small number of rectangles that don't intersect.
For each of these rectangles, list all circles that are at least partially contained in it. (A circle may end up listed in multiple rectangles, but that's okay.)
Every time you want to check whether the mouse is over a circle, you won't have to go through the whole array of circles. Instead:
Figure out which rectangle you're in.
Check only the circles that are listed under that rectangle.
This looks like a problem of optimizing the boundary check for a large number of items. The approach of going linearly does not scale well for thousands of circles.
This is a good topic to read on the net. But first, without going there, I'll try to explain (as an exercise) what I would explore. I would create a binary tree and partition the space, then instead of using an array I would put the circle points in such a tree. Looking the tree elements that are closer to the actual X,Y location becomes a matter of doing a binary search on the tree. The you have the closest point as a result of that search and can check for collision on it. There is still more to be done to the algorithm, and further optimizations are needed. For example, how to check for more points and not only the final one? Potentially I need a tree for the X coordinate, and another for the Y coordinate, etc... But I would explore these ideas. I will come back to this post and expand my reply with an actual example and a more concrete solution.
What if you check the coordinates that are r(radius) distance from the mouse? Then you could narrow your search down in the array if it is ordered.

Simple map projection

I've a map of 400x400 that approximatively represents an area of 250x250km in that I want to project a GPS coordinate in form of Lat/Lon.
Taking in account that precision is not very important(errors of some km are tolerable) there is any easy formula or algorithm to make the projection and translate to a pixel coordinate? If there is one, what error can I expect?
Or I'm really wrong and there not easy way for the precision that I need?
Notes:
I readed about PROJ.4 but I prefer to don't use any external library because the program has to run in small devices
I haven't any calibration data on the map but I can calibrate it myself using an online map.
From here I documented a little and I know how to convert the lat/lon to x/y/z coordinates. But I don't know how to dial with the Z
Usually, this is done using a transformation matrix and using a Mercarator projection.
Here is a good place to start.
Although it isn't java, there is an open source project called OpenHeatMap which does this within its source code. This might be a good place to look (specifically the setLatLonViewingArea, setLatLonToXYMatrix, mercatorLatitudeToLatitude in maprender/src/maprender.mxml).
Hope this helps!
The GIS people will probably stone me for this, but assuming you're not a a high latitude, you could just figure out the lat/lon of diagonal corners of your map to get the bounding box, pick a corner as your origin, take the difference between your GPS coordinate and the origin, then a simple multiplication to scale that to pixels, then draw the point.
I've used this in the past for a map program I was playing with, and I'm at about the 39th parallel. If it doesn't have to be dead accurate, and not too close to a pole (Though, for a 250km square, you'd have to be close to a pole for gross errors to happen), this would be the quickest and the easiest.

Algorithm to determine which points should be visible on a map based on zoom

I'm making a Google Maps-like application for a course at my Uni (not something complex, it should load the map of a city for example, not the whole world). The map can have many layers, including markers (restaurants, hospitals, etc.)
The problem is that when you have many points and you zoom out the map it doesn't look right. At this zoom level only some points need to be visible (and at the maximum map size, all points).
The question is: how can you determine which points should be visible for a specified zoom level?
Because I have implemented a PR Quadtree to speed up rendering I thought that I could define some "high-priority" markers (that are always visible, defined in the map editor) and put them in a queue. At each step a marker is removed from the queue and all it's neighbors that are at least D units away (D depends on the zoom levels) are chosen and inserted in the queue, and so on.
Is there any better way than the algorithm I thought of?
Thanks in advance!
I had a similar problem and you cannot avoid having overlapped icons regardless the method to mark some icons as high-priority.
What I did(it might not be easy to apply in your case - in my case the map was rendered in a desktop application, with much more control above the rendering process) was to sort based on priority, and paint only markers which are not overlapping - showing also a message like "XXX overlapping markers removed". This way the user doesn't become overwhelmed with information and he still sees the most important information.
I hope this helps.
Not sure I understand completely, but perhaps you can assign each layer a "neighborhood density," based on the inverse of the average distance from each point to its closest neighbor. For a particular zoom level, you would calculate a maximum density that is comfortably viewable and use that as a threshold.
I have some experience in designing a map application from scratch I would recommend you to split the entire world into 16 zoom levels. Zoom Level 0 should show the entire world and Zoom level 15 should cover the street data.
Typically, you would have to use the zoom levels 0 to 3 to have boundaries of the countries. And each zoom level should have a zoom range of 1/4th of the previous zoom range. You can have a zoom to table map (assuming you are using a database to store the spatial related data). Once you define the zoom levels and the range of the zoom levels to table mapping you can have finer control on querying the data. And its recommended to construct a R-Tree indexing for your map data.
Each and everytime you get a layer/table (assuming a layer can be either a country boundary or a railway track or a street), its advisable to define a zoom level by yourself instead of spending time in finding an algorithm since the number of layers are not going to be huge.
I can keep going, but if you want specific answers, I can address them as well.

What is the meaning of jitter in visualize tab of weka

In weka I load an arff file. I can view the relationship between attributes using the visualize tab.
However I can't understand the meaning of the jitter slider. What is its purpose?
You can find the answer in the mailing list archives:
The jitter function in the Visualize panel just adds artificial random
noise to the coordinates of the plotted points in order to spread the
data out a bit (so that you can see points that might have been
obscured by others).
I don't know weka, but generally jitter is a term for the variation of a periodic signal to some reference interval. I'm guessing the slider allows you to set some range or threshold below which data points are treated as being regular, or to modify the output to introduce some variation. The wikipedia entry can give you some background.
Update: from this pdf, the jitter slider is for this purpose:
“Jitter” option to deal with nominal attributes (and to detect “hidden”data points)
Based on the accompanying slide it looks like it introduces some variation in the visualisation, perhaps to show when two data points overlap.
Update 2: This google books extract (to Data mining By Ian H. Witten, Eibe Frank) seems to confirm my guess:
[jitter] is a random displacement applied to X and Y values to separate points that lie on top of one another. Without jitter, 1000 instances at the same data point would look just the same as 1 instance
I don't know the products you mention, but jittering generally means randomising the sample positions. Eg, in ray tracing you would normally render a ray though each pixel on the screen. Jittering adds a random offset to each ray to reduce issues caused by regular aliasing.

Categories

Resources