Open Bezzu opened 9 years ago
I know that the clipping code of PathLayer is suboptimal and could lead to missing segments. But in this case I'm not sure - Is it an end-segment that is missing or do both red lines belong to the same PathLayer?
Red lines belong to the same PathLayer. By thew way, in the case I posted above the segment is not an end-segment
Hi, this issue appears only when there is a line with the first point outside the clipping view and the end point inside. In the code if a line is clipped the the visible segment is added to the bucket but the end point isn't added though it is inside. To solve this problem I have modified the clipping process in the "doWork" function of the Task class in the PathLayer file and I have added a method in the LineClipper class.
//LineClipperc class
public int getPrevOutcode() { return mPrevOutcode; }
//PathLayer - Task class - doWork function
int clip = mClipper.clipNext(x, y); if (clip < 1) { if (i > 2) ll.addLine(projected, i, false); if (clip < 0) { /* add line segment */ segment = mClipper.getLine(segment, 0); ll.addLine(segment, 4, false); //the prev point is the real point not the clipped point //prevX = mClipper.outX2; //prevY = mClipper.outY2; prevX=x; prevY=y; } i = 0; //if the end point is inside, add it if(mClipper.getPrevOutcode()==0){ projected[i++] = prevX; projected[i++] = prevY; } // continue; } float dx = x - prevX; float dy = y - prevY; if ((i == 0) || FastMath.absMaxCmp(dx, dy, MIN_DIST)) { projected[i++] = prevX = x; projected[i++] = prevY = y; }
The new method of the LineClipper class return the state of the end point of the line (if is inside or outside). If the end point of the line is inside (state == 0) I have added the point to the projection array.
In the fork by Mapsforge I merged @Bezzu 's fix.
Hi, I would like to know if you have any suggestions for my problem. I use the class PathLayer to draw a red line above a blue line added with a VectorTileLayer and a specific VtmTheme over a standard map. Everything works fine until zoom 18![device-2014-12-05-093116](https://cloud.githubusercontent.com/assets/5656682/5313056/ed940abc-7c63-11e4-9f0b-079dcc95e185.png)
A more high zoom the red line disappared in some places![device-2014-12-05-093100](https://cloud.githubusercontent.com/assets/5656682/5313267/ac9f1e5e-7c66-11e4-8129-604bf480ae52.png)
Do you have any idea to resolve mu problem?
Thanks.