Point to url on JOSM wiki for MapWithAI paint style

Signed-off-by: Taylor Smock <taylor.smock@kaart.com>
pull/1/head v0.1.9
Taylor Smock 2019-10-30 13:01:38 -06:00
rodzic a3563d354e
commit 1b6d07c6d1
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 625F6A74A3E4311A
4 zmienionych plików z 26 dodań i 21 usunięć

Wyświetl plik

@ -33,12 +33,15 @@ import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIObject;
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIRemoteControl;
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIUploadHook;
import org.openstreetmap.josm.plugins.mapwithai.backend.MergeDuplicateWaysAction;
import org.openstreetmap.josm.spi.preferences.Config;
import org.openstreetmap.josm.tools.Destroyable;
import org.openstreetmap.josm.tools.Logging;
public final class MapWithAIPlugin extends Plugin implements Destroyable {
/** The name of the plugin */
public static final String NAME = "MapWithAI";
private static final String PAINTSTYLE_PREEXISTS = NAME.concat(".paintstyleprexists");
private static String versionInfo;
private final PreferenceSetting preferenceSetting;
@ -72,6 +75,10 @@ public final class MapWithAIPlugin extends Plugin implements Destroyable {
}
}
if (!Config.getPref().getKeySet().contains(PAINTSTYLE_PREEXISTS)) {
Config.getPref().putBoolean(PAINTSTYLE_PREEXISTS, MapWithAIDataUtils.checkIfMapWithAIPaintStyleExists());
}
MapWithAIDataUtils.addMapWithAIPaintStyles();
setVersionInfo(info.localversion);
@ -134,7 +141,9 @@ public final class MapWithAIPlugin extends Plugin implements Destroyable {
MainApplication.getLayerManager().getLayersOfType(MapWithAILayer.class).stream()
.forEach(layer -> MainApplication.getLayerManager().removeLayer(layer));
MapWithAIDataUtils.removeMapWithAIPaintStyles();
if (Config.getPref().getBoolean(PAINTSTYLE_PREEXISTS)) {
MapWithAIDataUtils.removeMapWithAIPaintStyles();
}
destroyables.forEach(Destroyable::destroy);
}

Wyświetl plik

@ -40,7 +40,7 @@ public final class MapWithAIDataUtils {
private static ForkJoinPool forkJoinPool;
static final Object LAYER_LOCK = new Object();
private static final String PAINT_STYLE_RESOURCE_URL = "resource://styles/standard/mapwithai.mapcss";
private static final String PAINT_STYLE_RESOURCE_URL = "https://josm.openstreetmap.de/josmfile?page=Styles/MapWithAI&zip=1";
private MapWithAIDataUtils() {
// Hide the constructor
@ -53,28 +53,24 @@ public final class MapWithAIDataUtils {
// Remove old url's that were automatically added -- remove after Jan 01, 2020
final List<String> oldUrls = Arrays.asList(
"https://gitlab.com/gokaart/JOSM_MapWithAI/raw/master/src/resources/styles/standard/mapwithai.mapcss",
"https://gitlab.com/smocktaylor/rapid/raw/master/src/resources/styles/standard/rapid.mapcss");
"https://gitlab.com/smocktaylor/rapid/raw/master/src/resources/styles/standard/rapid.mapcss",
"resource://styles/standard/mapwithai.mapcss");
MapPaintStyles.getStyles().getStyleSources().parallelStream().filter(style -> oldUrls.contains(style.url))
.forEach(MapPaintStyles::removeStyle);
Optional<MapCSSStyleSource> possiblePaintStyle = MapPaintStyles.getStyles().getStyleSources().parallelStream()
.filter(MapCSSStyleSource.class::isInstance).map(MapCSSStyleSource.class::cast)
.filter(source -> PAINT_STYLE_RESOURCE_URL.equals(source.url)).findFirst();
if (possiblePaintStyle.isPresent()) {
MapCSSStyleSource source = possiblePaintStyle.get();
if (!source.getErrors().isEmpty()) {
MapPaintStyles.removeStyle(source);
reallyAddPaintStyle();
}
} else {
reallyAddPaintStyle();
if (!checkIfMapWithAIPaintStyleExists()) {
final MapCSSStyleSource style = new MapCSSStyleSource(PAINT_STYLE_RESOURCE_URL, MapWithAIPlugin.NAME,
"MapWithAI");
MapPaintStyles.addStyle(style);
}
}
private static final void reallyAddPaintStyle() {
final MapCSSStyleSource style = new MapCSSStyleSource(PAINT_STYLE_RESOURCE_URL, MapWithAIPlugin.NAME,
"MapWithAI");
MapPaintStyles.addStyle(style);
/**
* @return true if a MapWithAI paint style exists
*/
public static boolean checkIfMapWithAIPaintStyleExists() {
return MapPaintStyles.getStyles().getStyleSources().parallelStream().filter(MapCSSStyleSource.class::isInstance)
.map(MapCSSStyleSource.class::cast).anyMatch(source -> PAINT_STYLE_RESOURCE_URL.equals(source.url));
}
/**

Wyświetl plik

@ -15,8 +15,8 @@ way[source=~/^(?i)(microsoft|digitalglobe)$/] {
}
way.mapwithai {
color: fuchsia;
color: mapwithai#FF00FF;
}
way.mapwithai:closed2 {
fill-color: fuchsia;
fill-color: mapwithai#FF00FF;
}

Wyświetl plik

@ -60,7 +60,7 @@ public class MapWithAIPluginTest {
plugin = new MapWithAIPlugin(info);
Assert.assertEquals(dataMenuSize + 4, dataMenu.getMenuComponentCount());
Assert.assertEquals(1, MapPaintStyles.getStyles().getStyleSources().parallelStream()
.filter(source -> source.url != null && source.url.contains("mapwithai")).count());
.filter(source -> source.url != null && source.name.contains("MapWithAI")).count());
}
/**