diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java index da3220afb5..f7df400693 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java @@ -85,7 +85,7 @@ public class MapillaryPlugin extends OsmandPlugin { private void createLayers() { rasterLayer = new MapillaryRasterLayer(); - vectorLayer = new MapillaryVectorLayer(); + vectorLayer = new MapillaryVectorLayer(settings); } @Override diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryVectorLayer.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryVectorLayer.java index acff984a8a..fc5a30b969 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryVectorLayer.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryVectorLayer.java @@ -22,6 +22,7 @@ import net.osmand.data.QuadRect; import net.osmand.data.RotatedTileBox; import net.osmand.map.ITileSource; import net.osmand.plus.OsmandPlugin; +import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin; import net.osmand.plus.resources.ResourceManager; @@ -30,6 +31,7 @@ import net.osmand.plus.views.MapTileLayer; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.util.MapUtils; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -48,9 +50,11 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont private Paint paintLine; private Bitmap point; private Map visiblePoints = new HashMap<>(); + private OsmandSettings settings; - MapillaryVectorLayer() { + MapillaryVectorLayer(OsmandSettings settings) { super(false); + this.settings = settings; } @Override @@ -181,6 +185,9 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont tx = (tileX + px) * mult; ty = (tileY + py) * mult; if (tileBounds.contains(tx, ty, tx, ty)) { + if (settings.USE_MAPILLARY_FILTER.get()) { + if (skipPoint(p)) continue; + } x = tileBox.getPixXFromTile(tileX + px, tileY + py, TILE_ZOOM); y = tileBox.getPixYFromTile(tileX + px, tileY + py, TILE_ZOOM); canvas.drawBitmap(point, x - pwd, y - phd, paintPoint); @@ -190,6 +197,38 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont } } + private boolean skipPoint(Point p) { + String userKey = settings.MAPILLARY_FILTER_USER_KEY.get(); + HashMap userData = (HashMap) p.getUserData(); + Date capturedAt = new Date((long) userData.get("captured_at")); + long from = settings.MAPILLARY_FILTER_FROM_DATE.get(); + long to = settings.MAPILLARY_FILTER_TO_DATE.get(); + if (!userKey.equals("")) { + String key = (String) userData.get("userkey"); + if (!userKey.equals(key)) { + return true; + } + } + if (from != 0 && to != 0) { + Date fromDate = new Date(from); + Date toDate = new Date(to); + if (capturedAt.before(fromDate) || capturedAt.after(toDate)) { + return true; + } + } else if (from != 0) { + Date fromDate = new Date(from); + if (capturedAt.before(fromDate)) { + return true; + } + } else if (to != 0) { + Date toDate = new Date(to); + if (capturedAt.after(toDate)) { + return true; + } + } + return false; + } + protected void drawLines(Canvas canvas, RotatedTileBox tileBox, int tileX, int tileY, GeometryTile tile) { for (Geometry g : tile.getData()) { if (g instanceof LineString && !g.isEmpty()) {