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.
Related
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).
I need to create a heatmap for android google maps. I have geolocation and points that have negative and positive weight attributed to them that I would like to visually represent. Unlike the majority of heatmaps, I want these positive and negative weights to destructively interfere; that is, when two points are close to each other and one is positive and the other is negative, the overlap of them destructively interferes, effectively not rendering areas that cancel out completely.
I plan on using the android google map's TileOverlay/TileProvider class that has the job of creating/rendering tiles based a given location and zoom. (I don't have an issue with this part.)
How should I go about rendering these Tiles? I plan on using java's Graphics class but the best that I can think of is going through each pixel, calculating what color it should be based on the surrounding data points, and rendering that pixel. This seems very inefficient, however, and I was looking for suggestions on a better approach.
Edit: I've considered everything from using a non-android Google Map inside of a WebView to using a TileOverlay to using a GroundOverlay. What I am now considering doing is having a large 2 dimensional array of "squares." Each square would have a long, lat, and total +/- weights. When a new data point is added, instead of rendering it exactly where it is, it will be added to the "square" that it is in. The weight of this data point will be added to the square and then I will use the GoogleMap Polygon object to render the square on the map. The ratio of +points to -points will determine the color that is rendered, with a ratio closer to 1:1 being clear, >1 being blue (cold point), and <1 being red (hot point).
Edit: a.k.a. clustering the data into small regional groups
I suggest trying
going through each pixel, calculating what color it should be based on the surrounding data points, and rendering that pixel.
Even if it slow, it will work. There are not too many Tiles on the screen, there are not too many pixels in each Tile and all this is done on a background thread.
All this is still followed by translating Bitmap into byte[]. The byte[] is a representation of PNG or JPG file, so it's not a simple pixel mapping from Bitmap. The last operation takes some time too and may possibly require more processing power than your whole algorithm.
Edit (moved from comment):
What you describe in the edit sounds like a simple clustering on LatLng. I can't say it's a better or worse idea, but it's something worth a try.
I have replicated the classic helicopter game using libgdx. It was fairly easy. Now I want to modify it such a way that the obstacles placement will be a mixture of predefined and randomly generated positions. This way I can also place coins with nice patterns for the predefined groups of obstacles.
To do that, I need to have imaginary grids in the screen using the obstacle size. Then create some groups of predefined positions for both obstacles and coins. Maybe create 10 sets of those predefined levels. Show them once in a certain period of time randomly for the players to have a different feel.
My question is how do I create imaginary grids on a phone screen considering different sizes, resoultion, and densities?
N.B. Please don't give me links of android developer pages for reading on different sizes and how to handle them. I have read many times and still do read once in a while.
You can account for different size screens by using relative instead of absolute values for your grid. E.g., you can set the height of a cell to be screenHeight/8, rather than "40". This way, whether the screen is 320 pixels or 400 pixels tall, you can still be sure that your grid will be 8 "boxes" tall.
If I have an image of a table of boxes, with some coloured in, is there an image processing library that can help me turn this into an array?
Thanks
You can use a thresholding function to binarize the image into dark/light pixels so dark pixels are 0 and light ones are 1.
Then you would want to remove image artifacts using dilation and erosion functions to remove noise (all these are well defined on Wikipedia).
Finally if you know where the boxes are, you can just get the value in the center of each box to determine the array value, or possibly use an area near the center and take the prevailing value (i.e. more 0's is a filled in square, more 1's is and empty square).
If you are scanning these boxes and there is a lot of variation in the position of the boxes, you will have to perform some level of image registration using known points, or fiducials.
As far as what tools to use to do this, I'd recommend first trying this manually using a tool like ImageJ, which has a UI and can also be used programatically since it is written all in Java.
Other good libraries for this include OpenCV and the Java Advanced Imaging API.
Your results will definitely vary depending on the input images and how consistenly lit and positioned they are.
The best way to see how it will do for your data is to try applying these processing steps manually to see where your threshold value should be, how much dilating/eroding you need to get consistent results.
I'm trying to develop a 2D game to android using opengl.
I know how to print images on the screen and animate them. But in my game I have a map and a want to zoom in and out and scroll the map. But I can't figure out the best way of doing it.
Can anybody help me?
I don't have any api examples but I did games design at college so I'll give my two bits.
The method you use will depend on your map style, size, functionality and format.
For example if you are looking for a very static non changing map, use a simple picture image. You can use the API frame for a picture view, enabling you to zoom in and out as you do in the gallery and to scroll on zoomed images, or in this case, zoom locations on your map.
Alternatively, if your map is based off a tiling system, a good example of this is the original Pokémon and Legend of Zelda games from the old game boy, then each area stores a tile 'thumbnail' for itself as a bitmap. These are then put into their appropriate locations on a grid depending on what areas are discovered.
This is the probably the most flexible way to build your map as you are not relying on a set bitmap for the entirety your map meaning it can change its look efficiently; you can build it as desired to show areas of choice (useful for if the map only reveals places the gamer has covered) and it also means you can do tile based overlay:
ie - if a certain area should contain treasure, theres a treasure icon overlayed on that tiles x,y position on the map grid.
I used the tiling option in my game projects from college and it made everything else map related easier. It also made the map side of things smaller storage wise.
The simplest approach would be to just call glTranslatef(-scrollX,-scrollY,0) followed by glScalef(zoom,zoom,zoom) before you render your map.