Draw many (250 k) polylines (a trail) - android

I have to draw a trail that contains more than 250.000 polylines with more than 500.000 coordinates. For my mobile deca core (10) and android 6.0 it takes more 1 minute to draw trail and the map become very slowly.
Is there a solution to draw it more quickly with a fast map ?
Note:
The same approach is executed in iOS speedly without problem, it takes 3 seconds to draw and the map is super fast.
The same question exists, but the proposed solutions do not work for me.

That is, perhaps, iOS doesn't draw all of them, obly approximated part, fitting current screen scale. You can do the same.
Take maximal area, fitting current zoom and suggest, that there should not be more than 100 lines. Add approximation algorithm, using fewer key points and calculate new lines

Related

Android OpenGL 2 ES how to generate an infinite 3D grid

Hello I am quite new to OPEN GL ES android.
My task is to generate a 3D grid terrain that is infinite.
The task is tree planting. I am using an RTK system of pretty accurate coordinates that I convent into UTM and then mark points on my lines in the grid.(I won't go into further details).
I want to be able to draw virtual lines that are n metres away from each other on my screen using a given scale, for example 3 metres in the real world may be equal to 0.3 on the screen, my problem is if I have an area of 6 square kilometres in the real world, this will definitely require that my grid on the device is scrollable.
So how do I come up with an infinite scrollable 3D grid in order to solve that problem on android?
Thank you very much.

How to solve precision errors in GLES2.0

I have a map of Brazil composed of about 5000 polygons that each represent it's cities.
Although they share points, they are each their own polygon.
The problem is, that when i draw them all, they form holes in between them, which i assume comes from rounding errors, since these holes disappear/move when zooming/moving the camera.
The problem is even worse when the map is zoomed out.
How do i solve this kind of problem in GLES2.0 (Android)?
Unfortunately i can't enlarge each polygon, and although i could fuse them all into a 'Brazil' polygon and draw it below them, i'd rather avoid doing so since the frame rate is already lower than what i need it to be.
I also tried to add 'precision highp float;' to the start of the shaders, but that didn't change a thing
Two images to illustrate the problem. The first is the zoomed in map, and the other is a zoomed out map, both images are cropped to show only the map

Android MapView path.draw draws crazy polygon lines all over the place

I've been struggling for a couple of weeks now with google's android mapview.
I'm drawing a large amount of polygons with a large amount of points. on average 15 polygons and around 1000 points each.
The first issue I experienced was performance... No surprise. After doing some testing I realised the culprit is projection.ToPixel() which I successfully bypass when the users pans by simply moving all my points in the direction by x amount of pixels (the difference), however when zooming I have no choice but to make use of the toPixel method.
Is there possibly a more efficient way of modifying my points depending on the zoom level? after some research I've found examples on how to do this with circles and other shapes, but I have no clue where to begin with reshaping polygons, any ideas on this?
The second issue i'm having is that when I have the entire polygon in view all is grand, but when I pan over the map bounds (where the map is effectively starting again to the left and right) on any side the polygon lines seem to reach and stretch out across the map bounds causing crazy spaghetti lines all over the place! I take it what's happening is that the path.close() or path.LineTo() methods think the shortest path is flying halfway across the world to reach the next point which causes these lines. I have no idea how to address this. I simply can't ignore points that do not fall within the current lon/lat spans because that (obviously) causes the polygon to change shape al the time!
Has anyone experienced this issue and how can one go about solving it? I'm not even sure what I should be googling!?
UPDATE 1:
The problem can be easily solved by preventing the mapview from looping. Is there some way to prevent the mapview from looping the world!?!?

Android canvas path real-time performance

I want to draw (4 or 5) real-time charts visualizing a lot of data (a new value every 30ms) within 15 minutes. I am using Path but it seems to work very slowly when I want to display over 20000 values and translate the canvas and it gets worse every second. I also tried using drawLine but it doesn't work fluently at all.
Does anyone have any ideas about a better solution than Path? Or maybe I am doing something wrong? My current solutio is : I initialize the Path in the beginning and then just add a new line to it every time I get a new value, then I translate the canvas.
Displaying a path of 20 000 values will probably be slow whatever you use, even in OpenGL, it's just a lot of data to send to the graphics chip to draw...
The "correct" way to do it (performance-wise) is probably to cache as much stuff as possible, and draw only what needs to be drawn. You could for example draw to a bitmap the first N points, and then only use a path for the next M points (and draw the bitmaps for the previous ones). Drawing a bitmap is pretty fast. So once in a while, you could just refresh your bitmap (which will take a bit more time) and then plot the remaining points.
You could also decide to have a shorter path : do you really need 20 000 values ? Couldn't you be grouping points 5 by 5 or 10 by ten (or even more) ? Currently, the screens are at most 1280 pixels wide anyways...
Are drawing all of that in every onDraw()? That's why it's slow. First of all, nobody can see changes every 30ms. So keep drawing updates into a cache bitmap, then call invalidate(). Then in onDraw() just copy that bitmap onto the canvas.
Drawing over 20000 lines with canvas is going to be slow, no matter what. My bet is that you have to go with openGL on this one. This link might be helpful: http://obviam.net/index.php/opengl-es-with-android-switching-from-canvas-to-opengl/

Determining where to animate the map given a list of GeoPoints

My android application loads some markers on an overlay onto a MapView.
The markers are placed based on a dynamic list of GeoPoints.
I want to move the map center and zoom into the area with most items.
Naively, I can calculate the superposition of all the points, but I would like to remove the points that are very far from the mass of points from the calculation.
Is there a known way to calculate this ? (e.g. probability, statistics .. ?)
I once solved the exact same problem you describe for a real estate app I wrote a little while ago. What worked for me was:
Calculate a center point somehow
(centroid, average the lats and
lons, or whatever)
Calc the distances between this imaginary point and each of your real pins
Use a Standard Deviation algorithm and remove any pin whose distance has a StdDev >
2 (or whatever threshold for you)
Repeat steps 1 - 3 (you'll be using a new center point each time
you loop) until there are no more
outliers to remove at step 3
This approach work great for my needs. But I'm sure there's more interesting ways to solve the same problem if you look around. For example, I found this interesting CompSci paper...
http://people.scs.carleton.ca/~michiel/outliers.pdf
Good luck!

Categories

Resources