Add filtering
This commit is contained in:
parent
6c03572c25
commit
fcd837321e
2 changed files with 41 additions and 2 deletions
|
@ -85,7 +85,7 @@ public class MapillaryPlugin extends OsmandPlugin {
|
||||||
|
|
||||||
private void createLayers() {
|
private void createLayers() {
|
||||||
rasterLayer = new MapillaryRasterLayer();
|
rasterLayer = new MapillaryRasterLayer();
|
||||||
vectorLayer = new MapillaryVectorLayer();
|
vectorLayer = new MapillaryVectorLayer(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -22,6 +22,7 @@ import net.osmand.data.QuadRect;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.map.ITileSource;
|
import net.osmand.map.ITileSource;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||||
import net.osmand.plus.resources.ResourceManager;
|
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.plus.views.OsmandMapTileView;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -48,9 +50,11 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont
|
||||||
private Paint paintLine;
|
private Paint paintLine;
|
||||||
private Bitmap point;
|
private Bitmap point;
|
||||||
private Map<QuadPointDouble, Map> visiblePoints = new HashMap<>();
|
private Map<QuadPointDouble, Map> visiblePoints = new HashMap<>();
|
||||||
|
private OsmandSettings settings;
|
||||||
|
|
||||||
MapillaryVectorLayer() {
|
MapillaryVectorLayer(OsmandSettings settings) {
|
||||||
super(false);
|
super(false);
|
||||||
|
this.settings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -181,6 +185,9 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont
|
||||||
tx = (tileX + px) * mult;
|
tx = (tileX + px) * mult;
|
||||||
ty = (tileY + py) * mult;
|
ty = (tileY + py) * mult;
|
||||||
if (tileBounds.contains(tx, ty, tx, ty)) {
|
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);
|
x = tileBox.getPixXFromTile(tileX + px, tileY + py, TILE_ZOOM);
|
||||||
y = tileBox.getPixYFromTile(tileX + px, tileY + py, TILE_ZOOM);
|
y = tileBox.getPixYFromTile(tileX + px, tileY + py, TILE_ZOOM);
|
||||||
canvas.drawBitmap(point, x - pwd, y - phd, paintPoint);
|
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<String, Object> userData = (HashMap<String, Object>) 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) {
|
protected void drawLines(Canvas canvas, RotatedTileBox tileBox, int tileX, int tileY, GeometryTile tile) {
|
||||||
for (Geometry g : tile.getData()) {
|
for (Geometry g : tile.getData()) {
|
||||||
if (g instanceof LineString && !g.isEmpty()) {
|
if (g instanceof LineString && !g.isEmpty()) {
|
||||||
|
|
Loading…
Reference in a new issue