I am developing an Android app that plots the gyroscope sensor input in a graph with the GraphView 3.1 library.
The data that I am feeding the GraphView is values between -90 and 90.
Due to that I want the graph to show both positive and negative values, I consequently want origo to be in the middle of the graph (vertically).
Demo of the graph:
http://www.youtube.com/watch?v=NtQOVU0GEEY
As you can see in the video, the graph starts with the x- and y-axis values in the top/bottom, this is unwanted, as it the values are 0 in both cases. They should both be in the middle (vertical center i.e. origo) when the x- and y-axis are 0. The graph should never shift the curve depending on subsequent values either, which is shown as soon as I tilt the device.
Do any of you have an idea of how to fix this?
I would like the plot consistent and not relative to the subsequent values.
The code that I am using is almost identical to the one jjoe64 has created in his demo:
https://github.com/jjoe64/GraphView-Demos/blob/master/src/com/jjoe64/graphviewdemos/RealtimeGraph.java
Thanks!
Best Regards,
Tim
Try to fix the y bounds with the method
graphview.setManualYAxisBounds(-100d, 100d);
http://jjoe64.github.io/GraphView/com/jjoe64/graphview/GraphView.html#setManualYAxisBounds(double, double)
Related
i want to build a global raster over all GPS coordinates.
The cells should be like 20x20 metres...
I want to write an java application and 'work with'/adjust that raster later on.
For example to get the cell for a single gps coordinate or maybe even combine two cells to a bigger one (not necessary).
Can anyone give me an advice for an API or something else that could help me?
As I already answered to a similar question, you cannot create a raster expressed in meters, without prior transforming all coordinates to a meter based x,y (= cartesian) coordinate system.
The GPS coordinates are spherical ones, the cell sizes (especially the y or latitudinal span) would vary from cell to cell, when going North or South.
So either express your raster size in decimal degrees (use an equivalent of your desired with (20m) expressed in meters at center of your area of interest).
Note: The Earth circumfence = 40.000 km, so 40.000 / 360 degrees give 111.111 km as length related to 1 degrees; use this factor to calculate the number of degrees related to 20m.
Or you transform all coordinates to UTM.
Having them in UTM you can then implement a raster expressed in meters.
Difficuties for UTM apporach: This projection is only valid at a longitudinal span of 3 degrees, you will get major problems when the location have to croiss this 3 degree limit.
There is no API for that, that I know, but you can implement that using a 2 dimensional array. (There are APIs for transfroming a lat/lon coordinate to UTM)
If the area of interest is larger then one country this approach may not work (well). The array could be to big.
In that case this task gets more complex, you would need a spatial index, like a quadtree, to limit the number of raster elements, by having an adaptive behaviour for dense locations.
So I am using MPAndroidChart as library for the viewing of graphs in my app. Now I wanted to make a LineGraph with several lines (n). The problem is that those lines do not have the same x-axis labels and I have not found a solution to put the x-axis labels in relation to the entries. Furthermore does the new line start at x-value 0. Therefore my lines do not fill the entire diagram area. Because when I have two lines with 6 entries each, the x-axis labels have the size 12. And therefore the lines end at half of the diagram.
How do I solve that?
Example LineGraph
I assume you mean the library available here: https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/com/xxmassdeveloper/mpchartexample/LineChartActivity2.java
From the code I grasped, LineChart does not support dual x-axis (while it support dual y-axis, left and right). See here , XAxis.java and YAxis.java
On the other hand, looks like the x-axis fits the data range automatically (there is no method to set min/max of x-axis).
An example of the graph >>
I would suggest you to re-organize your chart to switch x and y axis, and use two y axis if your series have different range of y values, but you want to show them in a chart. Double y-axis is more common than double x-axis from my experience, and easier to understand as well.
I'm doing a project on Android for measuring areas of land through photographs taken by a drone.
I have an aerial photograph that contains a GPS coordinate. For practical purposes I assume that coordinate represents the central pixel of the picture.
I need to move pixel by pixel in the picture to reach the corners and know what GPS coordinate represent the corners of the
I have no idea about how to achieve it. I have searched but can not find anything similar to my problem.
Thank You.
enter link description here
If you know the altitude at which the photo was taken and the camera maximum capture angle I believe you can determine (through trigonometry) the deviation of each pixel from the center, in meters, and then determine the GPS coordinate of it.
According to my knowledge,
Height of the drone also matter so first of all with the central coordinate you also need at what height drone take that picture.
Now you need to perform some experiment with reference picture between two known GPS coordinate of two points of picture. Change the height of the drone and plot the number of pixels between two coordinate wrt to the height of drone. Doing some curve fitting and get the function between two variable.
Using the above function you can calculate the "change in GPS coordinate per pixel" at the particular height and by using this parameter we can easily deduce the GPS of picture taken by drone at particular height.
I don't know whether the solution works or not. But this my idea you can use this and develop further.
Thanks
I have done my own function plotter with java which works quite well.
All you have to do is to iterate over the with (pixels) of the panel and calculate the y-value. Then plot it with a poly-line onto the screen and that's it.
But here comes my problem: There is a scale factor between the number of pixels and the value which I want to plot.
For example I'm at the 304' iteration (iterating over the with value of the plot panel). Now I calculate the corresponding value for this pixel position (304) by the rule of three. This gives me 1.45436. Then I calculate the sin based on this value. Which is transcendetal number. Then I use again the rule of tree to determine which y-pixel this value corresponds to. Doing so, I have to round because the pixel is an integer. And there is my data loss. This data loss may give me the following result:
This looks not really nice. If I play around with resizing the window I sometimes get a smooth result.
How can I fix this problem? I've actually never seen such plots in any other function plotter.
If you do this in Java, you might consider composing your data points to a Path2D. That would have floating point coordinates, and the drawing engine would take care of smoothing things down. You might have to disable stroke control, though.
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.