kopia lustrzana https://github.com/JOSM/MapWithAI
Fix an issue with duplicate RapiD URL's being added
Signed-off-by: Taylor Smock <smocktaylor@gmail.com>pull/1/head
rodzic
330f18409e
commit
35f1166357
|
@ -149,9 +149,11 @@ public final class RapiDDataUtils {
|
|||
ExtendedSourceEntry rapid = new ExtendedSourceEntry(SourceType.MAP_PAINT_STYLE, "rapid.mapcss",
|
||||
"https://gitlab.com/smocktaylor/rapid/raw/master/src/resources/styles/standard/rapid.mapcss");
|
||||
List<SourceEntry> paintStyles = MapPaintPrefHelper.INSTANCE.get();
|
||||
if (!paintStyles.contains(rapid)) {
|
||||
paintStyles.add(rapid);
|
||||
for (SourceEntry paintStyle : paintStyles) {
|
||||
if (rapid.url.equals(paintStyle.url))
|
||||
return;
|
||||
}
|
||||
paintStyles.add(rapid);
|
||||
MapPaintPrefHelper.INSTANCE.put(paintStyles);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.openstreetmap.josm.plugins.rapid;
|
|||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
@ -15,12 +16,14 @@ import org.openstreetmap.josm.data.osm.DataSet;
|
|||
import org.openstreetmap.josm.data.osm.Node;
|
||||
import org.openstreetmap.josm.data.osm.OsmPrimitive;
|
||||
import org.openstreetmap.josm.data.osm.Way;
|
||||
import org.openstreetmap.josm.data.preferences.sources.MapPaintPrefHelper;
|
||||
import org.openstreetmap.josm.data.preferences.sources.SourceEntry;
|
||||
import org.openstreetmap.josm.plugins.rapid.backend.RapiDDataUtils;
|
||||
import org.openstreetmap.josm.testutils.JOSMTestRules;
|
||||
|
||||
public class RapiDDataUtilsTest {
|
||||
@Rule
|
||||
public JOSMTestRules test = new JOSMTestRules();
|
||||
public JOSMTestRules test = new JOSMTestRules().preferences();
|
||||
|
||||
/**
|
||||
* This gets data from RapiD. This test may fail if someone adds the data to OSM.
|
||||
|
@ -77,4 +80,18 @@ public class RapiDDataUtilsTest {
|
|||
RapiDDataUtils.removePrimitivesFromDataSet(Collections.singleton(way1));
|
||||
Assert.assertEquals(0, ds1.allPrimitives().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddPaintStyle() {
|
||||
List<SourceEntry> paintStyles = MapPaintPrefHelper.INSTANCE.get();
|
||||
// There are two default paint styles
|
||||
Assert.assertEquals(2, paintStyles.size());
|
||||
RapiDDataUtils.addRapiDPaintStyles();
|
||||
paintStyles = MapPaintPrefHelper.INSTANCE.get();
|
||||
Assert.assertEquals(3, paintStyles.size());
|
||||
RapiDDataUtils.addRapiDPaintStyles();
|
||||
paintStyles = MapPaintPrefHelper.INSTANCE.get();
|
||||
Assert.assertEquals(3, paintStyles.size());
|
||||
RapiDDataUtils.addRapiDPaintStyles();
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue