kopia lustrzana https://github.com/JOSM/MapWithAI
Attempt to workaround JOSM not loading resource urls
Signed-off-by: Taylor Smock <taylor.smock@kaart.com>pull/1/head
rodzic
cc953c799e
commit
a3563d354e
|
@ -40,6 +40,8 @@ public final class MapWithAIDataUtils {
|
||||||
private static ForkJoinPool forkJoinPool;
|
private static ForkJoinPool forkJoinPool;
|
||||||
static final Object LAYER_LOCK = new Object();
|
static final Object LAYER_LOCK = new Object();
|
||||||
|
|
||||||
|
private static final String PAINT_STYLE_RESOURCE_URL = "resource://styles/standard/mapwithai.mapcss";
|
||||||
|
|
||||||
private MapWithAIDataUtils() {
|
private MapWithAIDataUtils() {
|
||||||
// Hide the constructor
|
// Hide the constructor
|
||||||
}
|
}
|
||||||
|
@ -55,20 +57,32 @@ public final class MapWithAIDataUtils {
|
||||||
MapPaintStyles.getStyles().getStyleSources().parallelStream().filter(style -> oldUrls.contains(style.url))
|
MapPaintStyles.getStyles().getStyleSources().parallelStream().filter(style -> oldUrls.contains(style.url))
|
||||||
.forEach(MapPaintStyles::removeStyle);
|
.forEach(MapPaintStyles::removeStyle);
|
||||||
|
|
||||||
if (MapPaintStyles.getStyles().getStyleSources().parallelStream()
|
Optional<MapCSSStyleSource> possiblePaintStyle = MapPaintStyles.getStyles().getStyleSources().parallelStream()
|
||||||
.noneMatch(source -> "resource://styles/standard/mapwithai.mapcss".equals(source.url))) {
|
.filter(MapCSSStyleSource.class::isInstance).map(MapCSSStyleSource.class::cast)
|
||||||
final MapCSSStyleSource style = new MapCSSStyleSource("resource://styles/standard/mapwithai.mapcss",
|
.filter(source -> PAINT_STYLE_RESOURCE_URL.equals(source.url)).findFirst();
|
||||||
MapWithAIPlugin.NAME, "MapWithAI");
|
if (possiblePaintStyle.isPresent()) {
|
||||||
MapPaintStyles.addStyle(style);
|
MapCSSStyleSource source = possiblePaintStyle.get();
|
||||||
|
if (!source.getErrors().isEmpty()) {
|
||||||
|
MapPaintStyles.removeStyle(source);
|
||||||
|
reallyAddPaintStyle();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
reallyAddPaintStyle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final void reallyAddPaintStyle() {
|
||||||
|
final MapCSSStyleSource style = new MapCSSStyleSource(PAINT_STYLE_RESOURCE_URL, MapWithAIPlugin.NAME,
|
||||||
|
"MapWithAI");
|
||||||
|
MapPaintStyles.addStyle(style);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove MapWithAI paint styles
|
* Remove MapWithAI paint styles
|
||||||
*/
|
*/
|
||||||
public static void removeMapWithAIPaintStyles() {
|
public static void removeMapWithAIPaintStyles() {
|
||||||
MapPaintStyles.getStyles().getStyleSources().parallelStream()
|
MapPaintStyles.getStyles().getStyleSources().parallelStream()
|
||||||
.filter(source -> "resource://styles/standard/mapwithai.mapcss".equals(source.url))
|
.filter(source -> PAINT_STYLE_RESOURCE_URL.equals(source.url))
|
||||||
.forEach(MapPaintStyles::removeStyle);
|
.forEach(MapPaintStyles::removeStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue