kopia lustrzana https://github.com/JOSM/MapWithAI
Avoid using worker thread for getting sources -- this can block data downloads
Signed-off-by: Taylor Smock <tsmock@meta.com>pull/43/head v819
rodzic
e8c6e96217
commit
225abbb685
|
@ -3,8 +3,6 @@ package org.openstreetmap.josm.plugins.mapwithai;
|
|||
|
||||
import static org.openstreetmap.josm.tools.I18n.tr;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -12,6 +10,8 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
|
||||
import org.openstreetmap.josm.actions.JosmAction;
|
||||
import org.openstreetmap.josm.actions.PreferencesAction;
|
||||
import org.openstreetmap.josm.data.validation.OsmValidator;
|
||||
|
@ -29,6 +29,7 @@ import org.openstreetmap.josm.plugins.Plugin;
|
|||
import org.openstreetmap.josm.plugins.PluginInformation;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.backend.DownloadListener;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIAction;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIDataUtils;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAILayer;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIMoveAction;
|
||||
import org.openstreetmap.josm.plugins.mapwithai.backend.MapWithAIObject;
|
||||
|
@ -135,7 +136,8 @@ public final class MapWithAIPlugin extends Plugin implements Destroyable {
|
|||
MainApplication.worker.execute(() -> UpdateProd.doProd(info.mainversion));
|
||||
// Preload the MapWithAILayerInfo for the JOSM download window
|
||||
// This reduces the amount of time taken for first button click by 100ms.
|
||||
MainApplication.worker.execute(MapWithAILayerInfo::getInstance);
|
||||
// Don't use the worker thread to avoid blocking user downloads
|
||||
MapWithAIDataUtils.getForkJoinPool().execute(MapWithAILayerInfo::getInstance);
|
||||
|
||||
destroyables.add(new MapWithAICopyProhibit());
|
||||
}
|
||||
|
|
|
@ -165,8 +165,8 @@ public class MergeDuplicateWays extends Command {
|
|||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
for (var i = 0; i < ways.size(); i++) {
|
||||
final var way1 = ways.get(i);
|
||||
final var nearbyWays = dataSet.searchWays(way1.getBBox()).stream()
|
||||
.filter(MergeDuplicateWays::nonDeletedWay).filter(w -> !Objects.equals(w, way1)).toList();
|
||||
final var nearbyWays = dataSet.searchWays(way1.getBBox()).stream().filter(MergeDuplicateWays::nonDeletedWay)
|
||||
.filter(w -> !Objects.equals(w, way1)).toList();
|
||||
for (final Way way2 : nearbyWays) {
|
||||
final var command = checkForDuplicateWays(way1, way2);
|
||||
final var deletedWays = new ArrayList<OsmPrimitive>();
|
||||
|
|
|
@ -28,12 +28,12 @@ import jakarta.annotation.Nonnull;
|
|||
*/
|
||||
public enum MapWithAICategory implements ISourceCategory<MapWithAICategory> {
|
||||
|
||||
BUILDING("data/closedway", "buildings", marktr("Buildings")),
|
||||
HIGHWAY("presets/transport/way/way_road", "highways", marktr("Roads")),
|
||||
ADDRESS("presets/misc/housenumber_small", "addresses", marktr("Addresses")),
|
||||
POWER("presets/power/pole", "pole", marktr("Power")), PRESET("dialogs/search", "presets", marktr("Presets")),
|
||||
FEATURED("presets/service/network-wireless", "featured", marktr("Featured")),
|
||||
PREVIEW("presets/misc/fixme", "preview", marktr("Preview")), OTHER(null, "other", marktr("Other"));
|
||||
BUILDING("data/closedway", "buildings", marktr("Buildings")), HIGHWAY("presets/transport/way/way_road", "highways",
|
||||
marktr("Roads")), ADDRESS("presets/misc/housenumber_small", "addresses",
|
||||
marktr("Addresses")), POWER("presets/power/pole", "pole", marktr("Power")), PRESET("dialogs/search",
|
||||
"presets", marktr("Presets")), FEATURED("presets/service/network-wireless", "featured",
|
||||
marktr("Featured")), PREVIEW("presets/misc/fixme", "preview",
|
||||
marktr("Preview")), OTHER(null, "other", marktr("Other"));
|
||||
|
||||
private static final Map<ImageSizes, Map<MapWithAICategory, ImageIcon>> iconCache = Collections
|
||||
.synchronizedMap(new EnumMap<>(ImageSizes.class));
|
||||
|
|
|
@ -11,8 +11,8 @@ import jakarta.annotation.Nonnull;
|
|||
* @author Taylor Smock
|
||||
*/
|
||||
public enum MapWithAIType implements ISourceType<MapWithAIType> {
|
||||
FACEBOOK("facebook"), THIRD_PARTY("thirdParty"), ESRI("esri"), ESRI_FEATURE_SERVER("esriFeatureServer"),
|
||||
MAPBOX_VECTOR_TILE("mvt"), PMTILES("pmtiles");
|
||||
FACEBOOK("facebook"), THIRD_PARTY("thirdParty"), ESRI("esri"), ESRI_FEATURE_SERVER(
|
||||
"esriFeatureServer"), MAPBOX_VECTOR_TILE("mvt"), PMTILES("pmtiles");
|
||||
|
||||
private final String typeString;
|
||||
|
||||
|
|
|
@ -179,8 +179,10 @@ public class RoutingIslandsTest extends Test {
|
|||
.filter(way -> !incomingWays.contains(way) || !outgoingWays.contains(way))
|
||||
.filter(way -> Access.getPositiveAccessValues().contains(
|
||||
getDefaultAccessTags(way).getOrDefault(currentTransportMode, Access.AccessTags.NO.getKey())))
|
||||
.collect(Collectors.toSet())).stream()
|
||||
.map(way -> new Pair<>((incomingWays.containsAll(way) ? marktr("outgoing") : marktr("incoming")), way))
|
||||
.collect(Collectors.toSet()))
|
||||
.stream()
|
||||
.map(way -> new Pair<>(
|
||||
(incomingWays.containsAll(way) ? marktr("outgoing") : marktr("incoming")), way))
|
||||
.toList();
|
||||
createErrors(problematic, currentTransportMode);
|
||||
}
|
||||
|
@ -328,8 +330,7 @@ public class RoutingIslandsTest extends Test {
|
|||
var isAccessible = true;
|
||||
|
||||
List<Relation> relations = from.getReferrers().stream().distinct().filter(Relation.class::isInstance)
|
||||
.map(Relation.class::cast).filter(relation -> "restriction".equals(relation.get("type")))
|
||||
.toList();
|
||||
.map(Relation.class::cast).filter(relation -> "restriction".equals(relation.get("type"))).toList();
|
||||
for (Relation relation : relations) {
|
||||
if (((relation.hasKey("except") && relation.get("except").contains(currentTransportMode))
|
||||
|| (currentTransportMode == null || currentTransportMode.trim().isEmpty()))
|
||||
|
|
|
@ -60,12 +60,13 @@ public final class MapPaintUtils {
|
|||
* Safe colors
|
||||
*/
|
||||
public enum SafeColors {
|
||||
RED(Color.RED), ORANGE(Color.ORANGE), GOLD(Objects.requireNonNull(ColorHelper.html2color("#ffd700"))),
|
||||
LIME(Objects.requireNonNull(ColorHelper.html2color("#00ff00"))), CYAN(Color.CYAN),
|
||||
DODGER_BLUE(Objects.requireNonNull(ColorHelper.html2color("#1e90ff"))),
|
||||
AI_MAGENTA(Objects.requireNonNull(ColorHelper.html2color("#ff26d4"))), PINK(Color.PINK),
|
||||
LIGHT_GREY(Objects.requireNonNull(ColorHelper.html2color("#d3d3d3"))),
|
||||
LINEN(Objects.requireNonNull(ColorHelper.html2color("#faf0e6")));
|
||||
RED(Color.RED), ORANGE(Color.ORANGE), GOLD(Objects.requireNonNull(ColorHelper.html2color("#ffd700"))), LIME(
|
||||
Objects.requireNonNull(ColorHelper.html2color("#00ff00"))), CYAN(Color.CYAN), DODGER_BLUE(
|
||||
Objects.requireNonNull(ColorHelper.html2color("#1e90ff"))), AI_MAGENTA(
|
||||
Objects.requireNonNull(ColorHelper.html2color("#ff26d4"))), PINK(
|
||||
Color.PINK), LIGHT_GREY(
|
||||
Objects.requireNonNull(ColorHelper.html2color("#d3d3d3"))), LINEN(
|
||||
Objects.requireNonNull(ColorHelper.html2color("#faf0e6")));
|
||||
|
||||
private final Color color;
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue