Fix some sonarlint warnings and remove some todo's that aren't needed

Also fix compilation warnings

Signed-off-by: Taylor Smock <taylor.smock@kaart.com>
pull/1/head
Taylor Smock 2019-12-06 08:17:17 -07:00
rodzic 6d78e812ab
commit 6127d2398e
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 625F6A74A3E4311A
5 zmienionych plików z 27 dodań i 8 usunięć

Wyświetl plik

@ -31,6 +31,18 @@ public class BoundingBoxMapWithAIDownloader extends BoundingBoxDownloader {
+ (crop ? "crop_bbox=" + lon1 + ',' + lat1 + ',' + lon2 + ',' + lat2 : "");
}
@Override
protected DataSet parseDataSet(InputStream source, ProgressMonitor progressMonitor) throws IllegalDataException {
DataSet ds = OsmReaderCustom.parseDataSet(source, progressMonitor, true);
GetDataRunnable.addMapWithAISourceTag(ds,
MapWithAIPreferenceHelper.getMapWithAIUrl().stream()
.filter(map -> map.getOrDefault("url", "no-url").equals(url))
.map(map -> map.getOrDefault("source", MapWithAIPlugin.NAME)).findFirst()
.orElse(MapWithAIPlugin.NAME));
GetDataRunnable.cleanup(ds, downloadArea);
return ds;
}
/**
* Returns the name of the download task to be displayed in the
* {@link ProgressMonitor}.

Wyświetl plik

@ -196,13 +196,18 @@ public final class MapWithAIDataUtils {
return forkJoinPool;
}
/**
* Get the height of a bbox
*
* @param bbox The bbox with lat/lon information
* @return The height in meters (see {@link LatLon#greatCircleDistance})
*/
public static double getHeight(BBox bbox) {
final LatLon bottomRight = bbox.getBottomRight();
final LatLon topLeft = bbox.getTopLeft();
final double minx = topLeft.getX();
final double miny = bottomRight.getY();
final LatLon bottomLeft = new LatLon(miny, minx);
// TODO handle poles
return topLeft.greatCircleDistance(bottomLeft);
}
@ -309,13 +314,17 @@ public final class MapWithAIDataUtils {
final BBox bbox1 = alreadyDownloadedReduced.get(i);
for (int j = 0; j < alreadyDownloadedReduced.size(); j++) {
final BBox bbox2 = alreadyDownloadedReduced.get(j);
if (!bbox1.equals(bbox2) && bboxesShareSide(bbox1, bbox2)) {
if (!bbox1.bboxIsFunctionallyEqual(bbox2, null) && bboxesShareSide(bbox1, bbox2)) {
bbox1.add(bbox2);
alreadyDownloadedReduced.remove(bbox2);
}
}
}
} while (aDRSize != alreadyDownloadedReduced.size());
return removeDuplicateBBoxes(wantToDownload, alreadyDownloadedReduced);
}
private static List<BBox> removeDuplicateBBoxes(List<BBox> wantToDownload, List<BBox> alreadyDownloaded) {
for (final BBox bbox : wantToDownload) {
for (final BBox downloaded : alreadyDownloaded) {
if (downloaded.bboxIsFunctionallyEqual(downloaded, null)) {
@ -325,9 +334,10 @@ public final class MapWithAIDataUtils {
}
}
return wantToDownload.parallelStream()
.filter(bbox1 -> alreadyDownloadedReduced.parallelStream()
.filter(bbox1 -> alreadyDownloaded.parallelStream()
.noneMatch(bbox2 -> bbox2.bboxIsFunctionallyEqual(bbox1, 0.000_02)))
.collect(Collectors.toList());
}
private static boolean bboxesShareSide(BBox bbox1, BBox bbox2) {
@ -352,7 +362,6 @@ public final class MapWithAIDataUtils {
final double maxy = topLeft.getY();
final LatLon bottomLeft = new LatLon(miny, minx);
final LatLon topRight = new LatLon(maxy, maxx);
// TODO handle meridian
return Math.max(bottomRight.greatCircleDistance(bottomLeft), topRight.greatCircleDistance(topLeft));
}

Wyświetl plik

@ -28,7 +28,7 @@ public class OsmReaderCustom extends OsmReader {
}
// check every so often to see if I can keep original negative ids
// See https://josm.openstreetmap.de/ticket/18258 (TODO)
// See https://josm.openstreetmap.de/ticket/18258 (TODO) // NOSONAR
@Override
protected OsmPrimitive buildPrimitive(PrimitiveData pd) {
final Long serverId = pd.getUniqueId();

Wyświetl plik

@ -126,7 +126,6 @@ public class MapWithAIDownloadReader implements DownloadSource<MapWithAIDownload
@Override
public MapWithAIDownloadData getData() {
Consumer<Collection<Object>> errorReporter = errors -> {
boolean onlyNoDataError = errors.size() == 1 && errors.contains("No data found in this area.");
};
return new MapWithAIDownloadData(MapWithAIPreferenceHelper.getMapWithAIUrl(), errorReporter);
}

Wyświetl plik

@ -23,7 +23,6 @@ import org.openstreetmap.josm.plugins.PluginInformation;
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIDataUtils;
import org.openstreetmap.josm.spi.preferences.Config;
import org.openstreetmap.josm.testutils.JOSMTestRules;
import org.openstreetmap.josm.tools.Logging;
import com.github.tomakehurst.wiremock.WireMockServer;