kopia lustrzana https://github.com/JOSM/MapWithAI
Start using new features from JOSM (up to r15486, November 2019)
* Use function in JOSM (bboxIsFunctionallyEqual, added in r15486) * Keep attributes as tags (added in r15470) * Add @Override in MapWithAILayer (added in r15371) Signed-off-by: Taylor Smock <taylor.smock@kaart.com>pull/1/head
rodzic
2d97022ee2
commit
17d554850c
|
@ -9,7 +9,6 @@ import java.util.Arrays;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
@ -92,8 +91,8 @@ public final class MapWithAIDataUtils {
|
|||
*/
|
||||
public static void removeMapWithAIPaintStyles() {
|
||||
new ArrayList<>(MapPaintStyles.getStyles().getStyleSources()).parallelStream()
|
||||
.filter(source -> paintStyleResourceUrl.equals(source.url))
|
||||
.forEach(style -> SwingUtilities.invokeLater(() -> MapPaintStyles.removeStyle(style)));
|
||||
.filter(source -> paintStyleResourceUrl.equals(source.url))
|
||||
.forEach(style -> SwingUtilities.invokeLater(() -> MapPaintStyles.removeStyle(style)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -319,28 +318,18 @@ public final class MapWithAIDataUtils {
|
|||
} while (aDRSize != alreadyDownloadedReduced.size());
|
||||
for (final BBox bbox : wantToDownload) {
|
||||
for (final BBox downloaded : alreadyDownloaded) {
|
||||
if (bboxesAreFunctionallyEqual(bbox, downloaded, null)) {
|
||||
Logging.debug("YEP");
|
||||
if (downloaded.bboxIsFunctionallyEqual(downloaded, null)) {
|
||||
Logging.debug("{0}: It looks like we already downloaded {1}", MapWithAIPlugin.NAME,
|
||||
bbox.toStringCSV(","));
|
||||
}
|
||||
}
|
||||
}
|
||||
return wantToDownload.parallelStream()
|
||||
.filter(bbox1 -> alreadyDownloadedReduced.parallelStream()
|
||||
.noneMatch(bbox2 -> bboxesAreFunctionallyEqual(bbox1, bbox2, 0.000_02)))
|
||||
.noneMatch(bbox2 -> bbox2.bboxIsFunctionallyEqual(bbox1, 0.000_02)))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
// TODO replace with {@link BBox.bboxesAreFunctionallyEqual} when version bumped
|
||||
// to >r15483
|
||||
private static boolean bboxesAreFunctionallyEqual(BBox bbox1, BBox bbox2, Double maxDifference) {
|
||||
final double diff = Optional.ofNullable(maxDifference).orElse(LatLon.MAX_SERVER_PRECISION);
|
||||
return ((bbox1 != null) && (bbox2 != null)
|
||||
&& (Math.abs(bbox1.getBottomRightLat() - bbox2.getBottomRightLat()) < diff)
|
||||
&& (Math.abs(bbox1.getBottomRightLon() - bbox2.getBottomRightLon()) < diff)
|
||||
&& (Math.abs(bbox1.getTopLeftLat() - bbox2.getTopLeftLat()) < diff)
|
||||
&& (Math.abs(bbox1.getTopLeftLon() - bbox2.getTopLeftLon()) < diff));
|
||||
}
|
||||
|
||||
private static boolean bboxesShareSide(BBox bbox1, BBox bbox2) {
|
||||
final List<Double> bbox1Lons = Arrays.asList(bbox1.getTopLeftLon(), bbox1.getBottomRightLon());
|
||||
final List<Double> bbox1Lats = Arrays.asList(bbox1.getTopLeftLat(), bbox1.getBottomRightLat());
|
||||
|
|
|
@ -56,7 +56,7 @@ public class MapWithAILayer extends OsmDataLayer implements ActiveLayerChangeLis
|
|||
MainApplication.getLayerManager().addActiveLayerChangeListener(this);
|
||||
}
|
||||
|
||||
// @Override TODO remove comment on 2020-01-01
|
||||
@Override
|
||||
public String getChangesetSourceTag() {
|
||||
return MapWithAIDataUtils.getAddedObjects() > 0 ? String.join("; ", MapWithAIDataUtils.getAddedObjectsSource())
|
||||
: null;
|
||||
|
|
|
@ -14,7 +14,6 @@ import org.openstreetmap.josm.io.OsmReader;
|
|||
import org.openstreetmap.josm.tools.Logging;
|
||||
|
||||
/**
|
||||
* TODO remove this class in January 2019 (if required patch is pulled)
|
||||
* Parser for the Osm API (XML output). Read from an input stream and construct a dataset out of it.
|
||||
*
|
||||
* For each xml element, there is a dedicated method.
|
||||
|
@ -25,16 +24,11 @@ public class OsmReaderCustom extends OsmReader {
|
|||
boolean temporaryConvertUknownToTags;
|
||||
protected OsmReaderCustom(boolean convertUnknownToTags) {
|
||||
// Restricts visibility
|
||||
super();
|
||||
// TODO when we update to r15470 this.convertUnknownToTags
|
||||
temporaryConvertUknownToTags = convertUnknownToTags;
|
||||
}
|
||||
|
||||
// TODO remove with update to r15470
|
||||
protected boolean isConvertUknownToTags() {
|
||||
return temporaryConvertUknownToTags;
|
||||
super(convertUnknownToTags);
|
||||
}
|
||||
|
||||
// check every so often to see if I can keep original negative ids
|
||||
// See https://josm.openstreetmap.de/ticket/18258 (TODO)
|
||||
@Override
|
||||
protected OsmPrimitive buildPrimitive(PrimitiveData pd) {
|
||||
final Long serverId = pd.getUniqueId();
|
||||
|
|
|
@ -59,7 +59,7 @@ public class MapWithAIDownloadReader implements DownloadSource<MapWithAIDownload
|
|||
});
|
||||
}
|
||||
|
||||
private String getUrl(Map<String, String> urlInformation) {
|
||||
private static String getUrl(Map<String, String> urlInformation) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (urlInformation.containsKey("url")) {
|
||||
sb.append(urlInformation.get("url"));
|
||||
|
|
Ładowanie…
Reference in New Issue