kopia lustrzana https://github.com/JOSM/MapWithAI
Fix a bug where connected ways would be deleted
Signed-off-by: Taylor Smock <taylor.smock@kaart.com>pull/1/head
rodzic
20ac384229
commit
6490070f45
|
@ -257,8 +257,10 @@ public class GetDataRunnable extends RecursiveTask<DataSet> implements CancelLis
|
||||||
BBox tBBox = new BBox();
|
BBox tBBox = new BBox();
|
||||||
tBBox.addPrimitive(way, 0.001);
|
tBBox.addPrimitive(way, 0.001);
|
||||||
if (way.getDataSet().searchWays(tBBox).parallelStream()
|
if (way.getDataSet().searchWays(tBBox).parallelStream()
|
||||||
.filter(tWay -> !way.equals(tWay) && !tWay.isDeleted()).anyMatch(
|
.filter(tWay -> !way.equals(tWay) && !tWay.isDeleted())
|
||||||
tWay -> Geometry.getDistance(way, tWay) < MapWithAIPreferenceHelper.getMaxNodeDistance())) {
|
.anyMatch(tWay -> way.getNodes().parallelStream().filter(
|
||||||
|
tNode -> Geometry.getDistance(tNode, tWay) < MapWithAIPreferenceHelper.getMaxNodeDistance())
|
||||||
|
.count() == way.getNodesCount())) {
|
||||||
way.setDeleted(true);
|
way.setDeleted(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,11 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.openstreetmap.josm.TestUtils;
|
import org.openstreetmap.josm.TestUtils;
|
||||||
import org.openstreetmap.josm.data.coor.LatLon;
|
import org.openstreetmap.josm.data.coor.LatLon;
|
||||||
|
import org.openstreetmap.josm.data.osm.DataSet;
|
||||||
import org.openstreetmap.josm.data.osm.Node;
|
import org.openstreetmap.josm.data.osm.Node;
|
||||||
import org.openstreetmap.josm.data.osm.Way;
|
import org.openstreetmap.josm.data.osm.Way;
|
||||||
import org.openstreetmap.josm.data.osm.WaySegment;
|
import org.openstreetmap.josm.data.osm.WaySegment;
|
||||||
|
@ -23,7 +23,6 @@ public class GetDataRunnableTest {
|
||||||
public JOSMTestRules rule = new JOSMTestRules().projection();
|
public JOSMTestRules rule = new JOSMTestRules().projection();
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore("Failing on GitLab CI")
|
|
||||||
public void testAddMissingElement() {
|
public void testAddMissingElement() {
|
||||||
Way way1 = TestUtils.newWay("", new Node(new LatLon(-5.7117803, 34.5011898)),
|
Way way1 = TestUtils.newWay("", new Node(new LatLon(-5.7117803, 34.5011898)),
|
||||||
new Node(new LatLon(-5.7111915, 34.5013994)), new Node(new LatLon(-5.7104175, 34.5016354)));
|
new Node(new LatLon(-5.7111915, 34.5013994)), new Node(new LatLon(-5.7104175, 34.5016354)));
|
||||||
|
@ -49,4 +48,26 @@ public class GetDataRunnableTest {
|
||||||
assertTrue(way1.getNodes().containsAll(way2.getNodes()));
|
assertTrue(way1.getNodes().containsAll(way2.getNodes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCleanupArtifacts() {
|
||||||
|
Way way1 = TestUtils.newWay("", new Node(new LatLon(0, 0)), new Node(new LatLon(1, 1)));
|
||||||
|
Way way2 = TestUtils.newWay("", way1.firstNode(), new Node(new LatLon(-1, -1)));
|
||||||
|
DataSet ds = new DataSet();
|
||||||
|
way1.getNodes().forEach(ds::addPrimitive);
|
||||||
|
ds.addPrimitive(way1);
|
||||||
|
way2.getNodes().stream().filter(node -> node.getDataSet() == null).forEach(ds::addPrimitive);
|
||||||
|
ds.addPrimitive(way2);
|
||||||
|
|
||||||
|
GetDataRunnable.cleanupArtifacts(way1);
|
||||||
|
|
||||||
|
assertEquals(2, ds.getWays().parallelStream().filter(way -> !way.isDeleted()).count());
|
||||||
|
|
||||||
|
Node tNode = new Node(way1.lastNode(), true);
|
||||||
|
ds.addPrimitive(tNode);
|
||||||
|
way2.addNode(tNode);
|
||||||
|
|
||||||
|
GetDataRunnable.cleanupArtifacts(way1);
|
||||||
|
assertEquals(1, ds.getWays().parallelStream().filter(way -> !way.isDeleted()).count());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue