kopia lustrzana https://github.com/JOSM/MapWithAI
rodzic
3a7e383700
commit
a14502d1d2
|
@ -30,8 +30,7 @@ public final class UpdateProd {
|
|||
public static boolean doProd(int nextMinVersion) {
|
||||
if (nextMinVersion > Version.getInstance().getVersion()) {
|
||||
int doUpdate = ConditionalOptionPaneUtil.showOptionDialog(
|
||||
MapWithAIPlugin.NAME.concat(".ignore_next_version"),
|
||||
MainApplication.getMainFrame(),
|
||||
MapWithAIPlugin.NAME.concat(".ignore_next_version"), MainApplication.getMainFrame(),
|
||||
tr("Please update JOSM -- {0} {1} is the last {0} version to support JOSM {2}",
|
||||
MapWithAIPlugin.NAME, MapWithAIPlugin.getVersionInfo(),
|
||||
Integer.toString(Version.getInstance().getVersion())),
|
||||
|
|
|
@ -34,11 +34,9 @@ public class BoundingBoxMapWithAIDownloader extends BoundingBoxDownloader {
|
|||
@Override
|
||||
protected DataSet parseDataSet(InputStream source, ProgressMonitor progressMonitor) throws IllegalDataException {
|
||||
DataSet ds = OsmReaderCustom.parseDataSet(source, progressMonitor, true);
|
||||
GetDataRunnable.addMapWithAISourceTag(ds,
|
||||
MapWithAIPreferenceHelper.getMapWithAIUrl().stream()
|
||||
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));
|
||||
.map(map -> map.getOrDefault("source", MapWithAIPlugin.NAME)).findFirst().orElse(MapWithAIPlugin.NAME));
|
||||
GetDataRunnable.cleanup(ds, downloadArea);
|
||||
return ds;
|
||||
}
|
||||
|
|
|
@ -75,8 +75,8 @@ public final class MapWithAIAvailability {
|
|||
cachedRapidReleases.setMaxAge(604_800);
|
||||
parser.next();
|
||||
final Stream<Entry<String, JsonValue>> entries = parser.getObjectStream();
|
||||
final Optional<Entry<String, JsonValue>> objects = entries
|
||||
.filter(entry -> "objects".equals(entry.getKey())).findFirst();
|
||||
final Optional<Entry<String, JsonValue>> objects = entries.filter(entry -> "objects".equals(entry.getKey()))
|
||||
.findFirst();
|
||||
if (objects.isPresent()) {
|
||||
final JsonObject value = objects.get().getValue().asJsonObject();
|
||||
if (value != null) {
|
||||
|
@ -120,8 +120,7 @@ public final class MapWithAIAvailability {
|
|||
.orElse(Optional.ofNullable(countryLoop.get("ISO3166-2")).orElse(""));
|
||||
if ("".equals(key)) {
|
||||
Logging.error("{0}: {1} does not have a \"ISO3166-1:alpha2\" or \"ISO3166-2\" key. {2}",
|
||||
MapWithAIPlugin.NAME,
|
||||
countryLoop, countryLoop.getInterestingTags());
|
||||
MapWithAIPlugin.NAME, countryLoop, countryLoop.getInterestingTags());
|
||||
} else {
|
||||
Logging.trace("{0}: {1} has a country code of {2}", MapWithAIPlugin.NAME,
|
||||
countryLoop.get("name:en"), key);
|
||||
|
|
|
@ -87,8 +87,9 @@ public class MapWithAIRemoteControl extends RequestHandler.RawURLParseRequestHan
|
|||
@Override
|
||||
protected void handleRequest() throws RequestHandlerErrorException, RequestHandlerBadRequestException {
|
||||
if (crop != null && crop.isInWorld()) {
|
||||
MainApplication.getLayerManager().addLayer(new GpxLayer(
|
||||
DetectTaskingManagerUtils.createTaskingManagerGpxData(crop), DetectTaskingManagerUtils.MAPWITHAI_CROP_AREA));
|
||||
MainApplication.getLayerManager()
|
||||
.addLayer(new GpxLayer(DetectTaskingManagerUtils.createTaskingManagerGpxData(crop),
|
||||
DetectTaskingManagerUtils.MAPWITHAI_CROP_AREA));
|
||||
}
|
||||
|
||||
final MapWithAILayer layer = MapWithAIDataUtils.getLayer(true);
|
||||
|
|
|
@ -38,8 +38,7 @@ public class MapWithAIUploadHook implements UploadHook, Destroyable {
|
|||
if (MapWithAIPreferenceHelper.getMapWithAIUrl().parallelStream().anyMatch(
|
||||
map -> !MapWithAIPreferenceHelper.DEFAULT_MAPWITHAI_API.equalsIgnoreCase(map.get("url")))) {
|
||||
sb.append(";url=")
|
||||
.append(String.join(";url=",
|
||||
MapWithAIPreferenceHelper.getMapWithAIUrl().parallelStream()
|
||||
.append(String.join(";url=", MapWithAIPreferenceHelper.getMapWithAIUrl().parallelStream()
|
||||
.filter(map -> map.containsKey("url")).map(map -> map.get("url"))
|
||||
.filter(url -> !MapWithAIPreferenceHelper.DEFAULT_MAPWITHAI_API.equalsIgnoreCase(url))
|
||||
.collect(Collectors.toList())));
|
||||
|
|
|
@ -14,11 +14,12 @@ import org.openstreetmap.josm.io.OsmReader;
|
|||
import org.openstreetmap.josm.tools.Logging;
|
||||
|
||||
/**
|
||||
* Parser for the Osm API (XML output). Read from an input stream and construct a dataset out of it.
|
||||
* 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.
|
||||
* The XMLStreamReader cursor points to the start of the element, when the method is
|
||||
* entered, and it must point to the end of the same element, when it is exited.
|
||||
* For each xml element, there is a dedicated method. The XMLStreamReader cursor
|
||||
* points to the start of the element, when the method is entered, and it must
|
||||
* point to the end of the same element, when it is exited.
|
||||
*/
|
||||
public class OsmReaderCustom extends OsmReader {
|
||||
protected OsmReaderCustom(boolean convertUnknownToTags) {
|
||||
|
@ -51,17 +52,19 @@ public class OsmReaderCustom extends OsmReader {
|
|||
* Parse the given input source and return the dataset.
|
||||
*
|
||||
* @param source the source input stream. Must not be null.
|
||||
* @param progressMonitor the progress monitor. If null, {@link NullProgressMonitor#INSTANCE} is assumed
|
||||
* @param convertUnknownToTags true if unknown xml attributes should be kept as tags
|
||||
* @param progressMonitor the progress monitor. If null,
|
||||
* {@link NullProgressMonitor#INSTANCE} is assumed
|
||||
* @param convertUnknownToTags true if unknown xml attributes should be kept as
|
||||
* tags
|
||||
*
|
||||
* @return the dataset with the parsed data
|
||||
* @throws IllegalDataException if an error was found while parsing the data from the source
|
||||
* @throws IllegalDataException if an error was found while parsing the data
|
||||
* from the source
|
||||
* @throws IllegalArgumentException if source is null
|
||||
* @since xxx
|
||||
*/
|
||||
public static DataSet parseDataSet(InputStream source, ProgressMonitor progressMonitor,
|
||||
boolean convertUnknownToTags)
|
||||
throws IllegalDataException {
|
||||
boolean convertUnknownToTags) throws IllegalDataException {
|
||||
return new OsmReaderCustom(convertUnknownToTags).doParseDataSet(source, progressMonitor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.openstreetmap.josm.tools.Pair;
|
|||
|
||||
public abstract class AbstractConflationCommand extends Command {
|
||||
Collection<OsmPrimitive> possiblyAffectedPrimitives;
|
||||
|
||||
public AbstractConflationCommand(DataSet data) {
|
||||
super(data);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,8 @@ public class MapWithAIAddCommand extends Command implements Runnable {
|
|||
* @param editLayer The OSM layer
|
||||
* @param selection The primitives to add from MapWithAI
|
||||
*/
|
||||
public MapWithAIAddCommand(MapWithAILayer mapWithAILayer, OsmDataLayer editLayer, Collection<OsmPrimitive> selection) {
|
||||
public MapWithAIAddCommand(MapWithAILayer mapWithAILayer, OsmDataLayer editLayer,
|
||||
Collection<OsmPrimitive> selection) {
|
||||
this(mapWithAILayer.getDataSet(), editLayer.getDataSet(), selection);
|
||||
lock = mapWithAILayer.getLock();
|
||||
}
|
||||
|
@ -76,8 +77,8 @@ public class MapWithAIAddCommand extends Command implements Runnable {
|
|||
@Override
|
||||
public void run() {
|
||||
if (mapWithAI.equals(editable)) {
|
||||
Logging.error("{0}: DataSet mapWithAI ({1}) should not be the same as DataSet editable ({2})", MapWithAIPlugin.NAME,
|
||||
mapWithAI, editable);
|
||||
Logging.error("{0}: DataSet mapWithAI ({1}) should not be the same as DataSet editable ({2})",
|
||||
MapWithAIPlugin.NAME, mapWithAI, editable);
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
synchronized (this) {
|
||||
|
@ -91,7 +92,8 @@ public class MapWithAIAddCommand extends Command implements Runnable {
|
|||
final Command movePrimitivesCommand = new MovePrimitiveDataSetCommand(editable, mapWithAI,
|
||||
primitives);
|
||||
final Command createConnectionsCommand = createConnections(editable, allPrimitives);
|
||||
command = new SequenceCommand(getDescriptionText(), movePrimitivesCommand, createConnectionsCommand);
|
||||
command = new SequenceCommand(getDescriptionText(), movePrimitivesCommand,
|
||||
createConnectionsCommand);
|
||||
}
|
||||
command.executeCommand();
|
||||
} finally {
|
||||
|
|
|
@ -41,7 +41,6 @@ import org.openstreetmap.josm.tools.ImageProvider;
|
|||
|
||||
public class MapWithAIDownloadReader implements DownloadSource<MapWithAIDownloadReader.MapWithAIDownloadData> {
|
||||
|
||||
|
||||
@Override
|
||||
public AbstractDownloadSourcePanel<MapWithAIDownloadData> createPanel(DownloadDialog dialog) {
|
||||
return new MapWithAIDownloadPanel(this);
|
||||
|
@ -65,8 +64,7 @@ public class MapWithAIDownloadReader implements DownloadSource<MapWithAIDownload
|
|||
sb.append(urlInformation.get("url"));
|
||||
if (urlInformation.containsKey("parameters")) {
|
||||
List<String> parameters = DataUrl.readJsonStringArraySimple(urlInformation.get("parameters"))
|
||||
.parallelStream()
|
||||
.filter(JsonObject.class::isInstance).map(JsonObject.class::cast)
|
||||
.parallelStream().filter(JsonObject.class::isInstance).map(JsonObject.class::cast)
|
||||
.filter(map -> map.getBoolean("enabled", false)).filter(map -> map.containsKey("parameter"))
|
||||
.map(map -> map.getString("parameter")).collect(Collectors.toList());
|
||||
if (!parameters.isEmpty()) {
|
||||
|
|
|
@ -29,11 +29,9 @@ public class UpdateProdTest {
|
|||
String booleanKey = "message.".concat(MapWithAIPlugin.NAME.concat(".ignore_next_version"));
|
||||
String intKey = "message.".concat(MapWithAIPlugin.NAME.concat(".ignore_next_version")).concat(".value"); // "message.MapWithAI.ignore_next_version.value";
|
||||
Config.getPref().putBoolean(booleanKey, false);
|
||||
Config.getPref().putInt(intKey,
|
||||
JOptionPane.YES_OPTION);
|
||||
Config.getPref().putInt(intKey, JOptionPane.YES_OPTION);
|
||||
assertTrue(UpdateProd.doProd(Integer.MAX_VALUE));
|
||||
Config.getPref().putInt(intKey,
|
||||
JOptionPane.NO_OPTION);
|
||||
Config.getPref().putInt(intKey, JOptionPane.NO_OPTION);
|
||||
assertTrue(UpdateProd.doProd(Integer.MAX_VALUE));
|
||||
assertFalse(UpdateProd.doProd(0));
|
||||
}
|
||||
|
|
|
@ -65,7 +65,8 @@ public class DetectTaskingManagerUtilsTest {
|
|||
Assert.assertFalse(DetectTaskingManagerUtils.hasTaskingManagerLayer());
|
||||
|
||||
final BBox bbox = new BBox(0, 0, 1, 1);
|
||||
MainApplication.getLayerManager().addLayer(new GpxLayer(DetectTaskingManagerUtils.createTaskingManagerGpxData(bbox),
|
||||
MainApplication.getLayerManager()
|
||||
.addLayer(new GpxLayer(DetectTaskingManagerUtils.createTaskingManagerGpxData(bbox),
|
||||
DetectTaskingManagerUtils.MAPWITHAI_CROP_AREA));
|
||||
|
||||
Assert.assertTrue(DetectTaskingManagerUtils.hasTaskingManagerLayer());
|
||||
|
|
|
@ -115,8 +115,8 @@ public class GetDataRunnableTest {
|
|||
@Test
|
||||
public void testRegressionTicket46() {
|
||||
DataSet ds = new DataSet();
|
||||
new GetDataRunnable(Arrays.asList(new BBox(-5.7400005, 34.4524384, -5.6686014, 34.5513153)), ds,
|
||||
null).fork().join();
|
||||
new GetDataRunnable(Arrays.asList(new BBox(-5.7400005, 34.4524384, -5.6686014, 34.5513153)), ds, null).fork()
|
||||
.join();
|
||||
assertNotNull(ds);
|
||||
assertFalse(ds.isEmpty());
|
||||
assertFalse(ds.allNonDeletedPrimitives().isEmpty());
|
||||
|
|
|
@ -31,8 +31,8 @@ public class MapWithAIAvailabilityTest {
|
|||
@Before
|
||||
public void setUp() {
|
||||
wireMock.start();
|
||||
MapWithAIAvailability.setReleaseUrl(wireMock.baseUrl()
|
||||
+ "/facebookmicrosites/Open-Mapping-At-Facebook/master/data/rapid_releases.geojson");
|
||||
MapWithAIAvailability.setReleaseUrl(
|
||||
wireMock.baseUrl() + "/facebookmicrosites/Open-Mapping-At-Facebook/master/data/rapid_releases.geojson");
|
||||
Territories.initialize();
|
||||
instance = MapWithAIAvailability.getInstance();
|
||||
LatLon temp = new LatLon(40, -100);
|
||||
|
|
|
@ -35,8 +35,7 @@ public class MapWithAIMoveActionTest {
|
|||
moveAction = new MapWithAIMoveAction();
|
||||
final DataSet osmData = new DataSet();
|
||||
mapWithAIData = new DataSet();
|
||||
way1 = TestUtils.newWay("highway=residential", new Node(new LatLon(0, 0)),
|
||||
new Node(new LatLon(0.1, 0.1)));
|
||||
way1 = TestUtils.newWay("highway=residential", new Node(new LatLon(0, 0)), new Node(new LatLon(0.1, 0.1)));
|
||||
way2 = TestUtils.newWay("highway=residential", new Node(new LatLon(-0.1, -0.1)),
|
||||
new Node(new LatLon(0.1, 0.1)));
|
||||
way1.getNodes().forEach(node -> mapWithAIData.addPrimitive(node));
|
||||
|
@ -45,8 +44,7 @@ public class MapWithAIMoveActionTest {
|
|||
mapWithAIData.addPrimitive(way1);
|
||||
|
||||
osmLayer = new OsmDataLayer(osmData, "osm", null);
|
||||
final MapWithAILayer mapWithAILayer = new MapWithAILayer(mapWithAIData, "MapWithAI",
|
||||
null);
|
||||
final MapWithAILayer mapWithAILayer = new MapWithAILayer(mapWithAIData, "MapWithAI", null);
|
||||
MainApplication.getLayerManager().addLayer(osmLayer);
|
||||
MainApplication.getLayerManager().addLayer(mapWithAILayer);
|
||||
MainApplication.getLayerManager().setActiveLayer(mapWithAILayer);
|
||||
|
|
|
@ -52,10 +52,8 @@ public class MapWithAIRemoteControlTest {
|
|||
@Before
|
||||
public void setUp() {
|
||||
wireMock.start();
|
||||
MapWithAIPreferenceHelper.setMapWithAIURLs(MapWithAIPreferenceHelper.getMapWithAIURLs().stream()
|
||||
.map(map -> {
|
||||
map.put("url",
|
||||
map.getOrDefault("url", MapWithAIPreferenceHelper.DEFAULT_MAPWITHAI_API)
|
||||
MapWithAIPreferenceHelper.setMapWithAIURLs(MapWithAIPreferenceHelper.getMapWithAIURLs().stream().map(map -> {
|
||||
map.put("url", map.getOrDefault("url", MapWithAIPreferenceHelper.DEFAULT_MAPWITHAI_API)
|
||||
.replace("https://www.facebook.com", wireMock.baseUrl()));
|
||||
return map;
|
||||
}).collect(Collectors.toList()));
|
||||
|
@ -76,6 +74,7 @@ public class MapWithAIRemoteControlTest {
|
|||
|
||||
/**
|
||||
* Unit test for bad request - invalid URL.
|
||||
*
|
||||
* @throws Exception if any error occurs
|
||||
*/
|
||||
@Test
|
||||
|
@ -134,8 +133,7 @@ public class MapWithAIRemoteControlTest {
|
|||
|
||||
thrown.expect(RequestHandlerBadRequestException.class);
|
||||
thrown.expectMessage("NumberFormatException (For input string: \"BAD_VALUE\")");
|
||||
newHandler(
|
||||
"http://127.0.0.1:8111/mapwithai?bbox=" + getTestBBox().toStringCSV(",") + "&max_obj=BAD_VALUE")
|
||||
newHandler("http://127.0.0.1:8111/mapwithai?bbox=" + getTestBBox().toStringCSV(",") + "&max_obj=BAD_VALUE")
|
||||
.handle();
|
||||
}
|
||||
|
||||
|
@ -147,7 +145,8 @@ public class MapWithAIRemoteControlTest {
|
|||
|
||||
await().atMost(Durations.TEN_SECONDS)
|
||||
.until(() -> !MapWithAIDataUtils.getLayer(false).getDataSet().getDataSourceBounds().isEmpty());
|
||||
final BBox added = MapWithAIDataUtils.getLayer(false).getDataSet().getDataSourceBounds().iterator().next().toBBox();
|
||||
final BBox added = MapWithAIDataUtils.getLayer(false).getDataSet().getDataSourceBounds().iterator().next()
|
||||
.toBBox();
|
||||
assertTrue(temp.bounds(added));
|
||||
|
||||
MainApplication.getLayerManager().removeLayer(MapWithAIDataUtils.getLayer(false));
|
||||
|
|
Ładowanie…
Reference in New Issue