From 46731a7438f684900abef83891677bffbdfe2dfe Mon Sep 17 00:00:00 2001 From: fokin33 Date: Sat, 21 Dec 2013 15:27:14 +0400 Subject: [PATCH] points up of gpx --- .../osmand/plus/osmodroid/OsMoDroidLayer.java | 59 ++++++++++--------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/osmodroid/OsMoDroidLayer.java b/OsmAnd/src/net/osmand/plus/osmodroid/OsMoDroidLayer.java index 4039549638..7ad675e076 100644 --- a/OsmAnd/src/net/osmand/plus/osmodroid/OsMoDroidLayer.java +++ b/OsmAnd/src/net/osmand/plus/osmodroid/OsMoDroidLayer.java @@ -136,6 +136,36 @@ public class OsMoDroidLayer extends OsmandMapLayer implements ContextMenuLayer.I @Override public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) { + for (ColoredGPX cg : gpxArrayList){ + cg.gpxFile.proccessPoints(); + List> points = cg.gpxFile.processedPointsToDisplay; + + paint.setColor(cg.color); + + final QuadRect latLonBounds = tileBox.getLatLonBounds(); + for (List l : points) { + path.rewind(); + int startIndex = -1; + + for (int i = 0; i < l.size(); i++) { + WptPt ls = l.get(i); + if (startIndex == -1) { + if (ls.lat >= latLonBounds.bottom - 0.1 && ls.lat <= latLonBounds.top + 0.1 && ls.lon >= latLonBounds.left - 0.1 + && ls.lon <= latLonBounds.right + 0.1) { + startIndex = i > 0 ? i - 1 : i; + } + } else if (!(latLonBounds.left <= ls.lon + 0.1 && ls.lon - 0.1 <= latLonBounds.right + && latLonBounds.bottom <= ls.lat + 0.1 && ls.lat - 0.1 <= latLonBounds.top)) { + drawSegment(canvas, tileBox, l, startIndex, i); + startIndex = -1; + } + } + if (startIndex != -1) { + drawSegment(canvas, tileBox, l, startIndex, l.size() - 1); + continue; + } + } + } for (OsMoDroidPoint op : osMoDroidPointArrayList) { if(seekOsMoDroidPoint!=null&&seekOsMoDroidPoint.equals(op)){ @@ -200,36 +230,7 @@ public class OsMoDroidLayer extends OsmandMapLayer implements ContextMenuLayer.I canvas.drawRect(new Rect(locationX-radius, locationY-radius, locationX+radius, locationY+radius), textPaint); } - for (ColoredGPX cg : gpxArrayList){ - cg.gpxFile.proccessPoints(); - List> points = cg.gpxFile.processedPointsToDisplay; - - paint.setColor(cg.color); - final QuadRect latLonBounds = tileBox.getLatLonBounds(); - for (List l : points) { - path.rewind(); - int startIndex = -1; - - for (int i = 0; i < l.size(); i++) { - WptPt ls = l.get(i); - if (startIndex == -1) { - if (ls.lat >= latLonBounds.bottom - 0.1 && ls.lat <= latLonBounds.top + 0.1 && ls.lon >= latLonBounds.left - 0.1 - && ls.lon <= latLonBounds.right + 0.1) { - startIndex = i > 0 ? i - 1 : i; - } - } else if (!(latLonBounds.left <= ls.lon + 0.1 && ls.lon - 0.1 <= latLonBounds.right - && latLonBounds.bottom <= ls.lat + 0.1 && ls.lat - 0.1 <= latLonBounds.top)) { - drawSegment(canvas, tileBox, l, startIndex, i); - startIndex = -1; - } - } - if (startIndex != -1) { - drawSegment(canvas, tileBox, l, startIndex, l.size() - 1); - continue; - } - } - } } private void drawSegment(Canvas canvas, RotatedTileBox tb, List l, int startIndex, int endIndex) {