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;
|
||||
static final Object LAYER_LOCK = new Object();
|
||||
|
||||
private static final String PAINT_STYLE_RESOURCE_URL = "resource://styles/standard/mapwithai.mapcss";
|
||||
|
||||
private MapWithAIDataUtils() {
|
||||
// Hide the constructor
|
||||
}
|
||||
|
@ -55,20 +57,32 @@ public final class MapWithAIDataUtils {
|
|||
MapPaintStyles.getStyles().getStyleSources().parallelStream().filter(style -> oldUrls.contains(style.url))
|
||||
.forEach(MapPaintStyles::removeStyle);
|
||||
|
||||
if (MapPaintStyles.getStyles().getStyleSources().parallelStream()
|
||||
.noneMatch(source -> "resource://styles/standard/mapwithai.mapcss".equals(source.url))) {
|
||||
final MapCSSStyleSource style = new MapCSSStyleSource("resource://styles/standard/mapwithai.mapcss",
|
||||
MapWithAIPlugin.NAME, "MapWithAI");
|
||||
MapPaintStyles.addStyle(style);
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
private static final void reallyAddPaintStyle() {
|
||||
final MapCSSStyleSource style = new MapCSSStyleSource(PAINT_STYLE_RESOURCE_URL, MapWithAIPlugin.NAME,
|
||||
"MapWithAI");
|
||||
MapPaintStyles.addStyle(style);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove MapWithAI paint styles
|
||||
*/
|
||||
public static void removeMapWithAIPaintStyles() {
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue