kopia lustrzana https://github.com/JOSM/MapWithAI
FIXUP: Avoid crash when user may have modified conn/dupe tags
Signed-off-by: Taylor Smock <taylor.smock@kaart.com>pull/1/head
rodzic
93938afc77
commit
5d35fb36f3
|
@ -100,10 +100,17 @@ public abstract class AbstractConflationCommand extends Command {
|
|||
final OsmPrimitive[] primitiveConnections = new OsmPrimitive[connections.length];
|
||||
for (int i = 0; i < connections.length; i++) {
|
||||
final String member = connections[i];
|
||||
SimplePrimitiveId primitiveId = SimplePrimitiveId.fromString(member);
|
||||
primitiveConnections[i] = dataSet.getPrimitiveById(primitiveId);
|
||||
if (primitiveConnections[i] == null) {
|
||||
missingPrimitives.put(i, new Pair<>(primitiveId.getUniqueId(), primitiveId.getType()));
|
||||
try {
|
||||
SimplePrimitiveId primitiveId = SimplePrimitiveId.fromString(member);
|
||||
primitiveConnections[i] = dataSet.getPrimitiveById(primitiveId);
|
||||
if (primitiveConnections[i] == null) {
|
||||
missingPrimitives.put(i, new Pair<>(primitiveId.getUniqueId(), primitiveId.getType()));
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
// Assume someone fiddled with the tag if the pattern doesn't match.
|
||||
if (!e.getMessage().contains("n|node|w|way|r|rel|relation")) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
obtainMissingPrimitives(dataSet, primitiveConnections, missingPrimitives);
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
// License: GPL. For details, see LICENSE file.
|
||||
package org.openstreetmap.josm.plugins.mapwithai.commands.conflation;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openstreetmap.josm.data.osm.DataSet;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.backend.commands.conflation.AbstractConflationCommand;
|
||||
|
||||
public class AbstractConflationCommandTest {
|
||||
/**
|
||||
* Non-regression test for
|
||||
* <a href="https://josm.openstreetmap.de/ticket/19495">#19495</a>
|
||||
*/
|
||||
@Test
|
||||
public void testBadPrimitive() {
|
||||
assertDoesNotThrow(() -> AbstractConflationCommand.getPrimitives(new DataSet(), "Linie 401699530"));
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue