kopia lustrzana https://github.com/JOSM/MapWithAI
Ensure that we only try to convert to tags when an equals sign is present.
This fixes #90. Signed-off-by: Taylor Smock <taylor.smock@kaart.com>pull/1/head
rodzic
59f6ee8671
commit
786ee5f689
|
@ -66,6 +66,9 @@ public class GetDataRunnable extends RecursiveTask<DataSet> {
|
||||||
private static final int MAX_NUMBER_OF_BBOXES_TO_PROCESS = 1;
|
private static final int MAX_NUMBER_OF_BBOXES_TO_PROCESS = 1;
|
||||||
private static final String SERVER_ID_KEY = "current_id";
|
private static final String SERVER_ID_KEY = "current_id";
|
||||||
|
|
||||||
|
/** An equals sign (=) used for tag splitting */
|
||||||
|
private static final String EQUALS = "=";
|
||||||
|
|
||||||
private static final double ARTIFACT_ANGLE = 0.1745; // 10 degrees in radians
|
private static final double ARTIFACT_ANGLE = 0.1745; // 10 degrees in radians
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -291,6 +294,7 @@ public class GetDataRunnable extends RecursiveTask<DataSet> {
|
||||||
*/
|
*/
|
||||||
public static void replaceTags(DataSet dataSet) {
|
public static void replaceTags(DataSet dataSet) {
|
||||||
final Map<Tag, Tag> replaceTags = MapWithAIPreferenceHelper.getReplacementTags().entrySet().parallelStream()
|
final Map<Tag, Tag> replaceTags = MapWithAIPreferenceHelper.getReplacementTags().entrySet().parallelStream()
|
||||||
|
.filter(entry -> entry.getKey().contains(EQUALS) && entry.getValue().contains(EQUALS))
|
||||||
.map(entry -> new Pair<>(Tag.ofString(entry.getKey()), Tag.ofString(entry.getValue())))
|
.map(entry -> new Pair<>(Tag.ofString(entry.getKey()), Tag.ofString(entry.getValue())))
|
||||||
.collect(Collectors.toMap(pair -> pair.a, pair -> pair.b));
|
.collect(Collectors.toMap(pair -> pair.a, pair -> pair.b));
|
||||||
replaceTags(dataSet, replaceTags);
|
replaceTags(dataSet, replaceTags);
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.openstreetmap.josm.plugins.mapwithai.backend;
|
||||||
|
|
||||||
import static org.junit.Assume.assumeTrue;
|
import static org.junit.Assume.assumeTrue;
|
||||||
import static org.junit.jupiter.api.Assertions.assertAll;
|
import static org.junit.jupiter.api.Assertions.assertAll;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
@ -134,4 +135,15 @@ public class GetDataRunnableTest {
|
||||||
.forEach(node -> assertTrue(node.isDeleted(), "The duplicate way nodes should be deleted")),
|
.forEach(node -> assertTrue(node.isDeleted(), "The duplicate way nodes should be deleted")),
|
||||||
() -> assertFalse(nonDuplicateWay.isDeleted(), "The non-duplicate way should not be deleted"));
|
() -> assertFalse(nonDuplicateWay.isDeleted(), "The non-duplicate way should not be deleted"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Non-regression test for <a
|
||||||
|
* href=https://gitlab.com/gokaart/JOSM_MapWithAI/-/issues/90>#90</a>
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testEmptyTagReplacement() {
|
||||||
|
MapWithAIPreferenceHelper.setReplacementTags(Collections.singletonMap("", ""));
|
||||||
|
DataSet ds = new DataSet();
|
||||||
|
assertDoesNotThrow(() -> GetDataRunnable.replaceTags(ds));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue