kopia lustrzana https://github.com/JOSM/MapWithAI
rodzic
3b94fe1150
commit
4ed09dd7e1
|
@ -53,7 +53,7 @@ import org.openstreetmap.josm.tools.Pair;
|
||||||
*/
|
*/
|
||||||
public class GetDataRunnable extends RecursiveTask<DataSet> {
|
public class GetDataRunnable extends RecursiveTask<DataSet> {
|
||||||
private static final long serialVersionUID = 258423685658089715L;
|
private static final long serialVersionUID = 258423685658089715L;
|
||||||
private final List<BBox> bbox;
|
private final transient List<BBox> bbox;
|
||||||
private final transient DataSet dataSet;
|
private final transient DataSet dataSet;
|
||||||
private final transient ProgressMonitor monitor;
|
private final transient ProgressMonitor monitor;
|
||||||
private static final float DEGREE_BUFFER = 0.001f;
|
private static final float DEGREE_BUFFER = 0.001f;
|
||||||
|
@ -61,7 +61,7 @@ public class GetDataRunnable extends RecursiveTask<DataSet> {
|
||||||
private static final int MAX_LONGITUDE = 180;
|
private static final int MAX_LONGITUDE = 180;
|
||||||
|
|
||||||
private Integer maximumDimensions;
|
private Integer maximumDimensions;
|
||||||
private MapWithAIInfo info;
|
private transient MapWithAIInfo info;
|
||||||
|
|
||||||
private static final int MAX_NUMBER_OF_BBOXES_TO_PROCESS = 1;
|
private static final int MAX_NUMBER_OF_BBOXES_TO_PROCESS = 1;
|
||||||
private static final String SERVER_ID_KEY = "current_id";
|
private static final String SERVER_ID_KEY = "current_id";
|
||||||
|
|
|
@ -6,6 +6,7 @@ import static org.openstreetmap.josm.tools.I18n.tr;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -238,7 +239,7 @@ public class MapWithAILayer extends OsmDataLayer implements ActiveLayerChangeLis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class OsmComparator implements Comparator<OsmPrimitive> {
|
private static class OsmComparator implements Comparator<OsmPrimitive>, Serializable {
|
||||||
final Collection<OsmPrimitive> previousSelection;
|
final Collection<OsmPrimitive> previousSelection;
|
||||||
|
|
||||||
public OsmComparator(Collection<OsmPrimitive> previousSelection) {
|
public OsmComparator(Collection<OsmPrimitive> previousSelection) {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.openstreetmap.josm.plugins.mapwithai.data.mapwithai;
|
||||||
|
|
||||||
import static org.openstreetmap.josm.tools.I18n.marktr;
|
import static org.openstreetmap.josm.tools.I18n.marktr;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
|
@ -22,7 +23,7 @@ import org.openstreetmap.josm.tools.ImageProvider.ImageSizes;
|
||||||
* @author Taylor Smock
|
* @author Taylor Smock
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public enum MapWithAICategory implements ISourceCategory<MapWithAICategory> {
|
public enum MapWithAICategory implements ISourceCategory<MapWithAICategory>, Serializable {
|
||||||
|
|
||||||
BUILDING("data/closedway", "buildings", marktr("Buildings")),
|
BUILDING("data/closedway", "buildings", marktr("Buildings")),
|
||||||
HIGHWAY("presets/transport/way/way_road", "highways", marktr("Roads")),
|
HIGHWAY("presets/transport/way/way_road", "highways", marktr("Roads")),
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.openstreetmap.josm.plugins.mapwithai.data.mapwithai;
|
||||||
|
|
||||||
import static org.openstreetmap.josm.tools.I18n.tr;
|
import static org.openstreetmap.josm.tools.I18n.tr;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -120,7 +121,7 @@ public class MapWithAIInfo extends
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MapWithAIInfoCategoryComparator implements Comparator<MapWithAIInfo> {
|
public static class MapWithAIInfoCategoryComparator implements Comparator<MapWithAIInfo>, Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(MapWithAIInfo o1, MapWithAIInfo o2) {
|
public int compare(MapWithAIInfo o1, MapWithAIInfo o2) {
|
||||||
|
|
|
@ -69,12 +69,17 @@ public class MapWithAILayerInfo {
|
||||||
private static MapWithAILayerInfo instance;
|
private static MapWithAILayerInfo instance;
|
||||||
|
|
||||||
public static MapWithAILayerInfo getInstance() {
|
public static MapWithAILayerInfo getInstance() {
|
||||||
|
AtomicBoolean finished;
|
||||||
synchronized (DEFAULT_LAYER_SITES) {
|
synchronized (DEFAULT_LAYER_SITES) {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
AtomicBoolean finished = new AtomicBoolean();
|
finished = new AtomicBoolean();
|
||||||
instance = new MapWithAILayerInfo(() -> finished.set(true));
|
instance = new MapWithAILayerInfo(() -> finished.set(true));
|
||||||
|
} else {
|
||||||
|
finished = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
// Avoid a deadlock in the EDT.
|
// Avoid a deadlock in the EDT.
|
||||||
if (!SwingUtilities.isEventDispatchThread()) {
|
if (finished != null && !SwingUtilities.isEventDispatchThread()) {
|
||||||
while (!finished.get()) {
|
while (!finished.get()) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
|
@ -84,8 +89,6 @@ public class MapWithAILayerInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ class AddMapWithAIPanel extends JPanel {
|
||||||
private TimeUnit currentUnit;
|
private TimeUnit currentUnit;
|
||||||
private MapWithAIType type;
|
private MapWithAIType type;
|
||||||
|
|
||||||
private MapWithAIInfo info;
|
private transient MapWithAIInfo info;
|
||||||
private JComboBox<MapWithAIType> typeBox;
|
private JComboBox<MapWithAIType> typeBox;
|
||||||
|
|
||||||
protected AddMapWithAIPanel(LayoutManager layout) {
|
protected AddMapWithAIPanel(LayoutManager layout) {
|
||||||
|
|
|
@ -442,7 +442,6 @@ public class MapWithAIProvidersPanel extends JPanel {
|
||||||
int tenXWidth = defaultTable.getFontMetrics(defaultTable.getFont()).stringWidth("XXXXXXXXXX");
|
int tenXWidth = defaultTable.getFontMetrics(defaultTable.getFont()).stringWidth("XXXXXXXXXX");
|
||||||
TableColumnModel mod = defaultTable.getColumnModel();
|
TableColumnModel mod = defaultTable.getColumnModel();
|
||||||
int urlWidth = (showActive ? 3 : 0) * tenXWidth;
|
int urlWidth = (showActive ? 3 : 0) * tenXWidth;
|
||||||
mod.getColumns();
|
|
||||||
mod.getColumn(6).setCellRenderer(defaultTable.getDefaultRenderer(Boolean.class));
|
mod.getColumn(6).setCellRenderer(defaultTable.getDefaultRenderer(Boolean.class));
|
||||||
mod.getColumn(6).setMaxWidth(20);
|
mod.getColumn(6).setMaxWidth(20);
|
||||||
mod.getColumn(5).setMaxWidth((!showActive ? 1 : 0) * tenXWidth);
|
mod.getColumn(5).setMaxWidth((!showActive ? 1 : 0) * tenXWidth);
|
||||||
|
|
|
@ -12,6 +12,7 @@ import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.json.Json;
|
import javax.json.Json;
|
||||||
import javax.json.JsonArray;
|
import javax.json.JsonArray;
|
||||||
import javax.json.JsonNumber;
|
import javax.json.JsonNumber;
|
||||||
|
@ -20,6 +21,7 @@ import javax.json.JsonReader;
|
||||||
import javax.json.JsonString;
|
import javax.json.JsonString;
|
||||||
import javax.json.JsonStructure;
|
import javax.json.JsonStructure;
|
||||||
import javax.json.JsonValue;
|
import javax.json.JsonValue;
|
||||||
|
|
||||||
import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryBounds;
|
import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryBounds;
|
||||||
import org.openstreetmap.josm.io.CachedFile;
|
import org.openstreetmap.josm.io.CachedFile;
|
||||||
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAICategory;
|
import org.openstreetmap.josm.plugins.mapwithai.data.mapwithai.MapWithAICategory;
|
||||||
|
@ -35,7 +37,7 @@ import org.openstreetmap.josm.tools.Utils;
|
||||||
*/
|
*/
|
||||||
public class ESRISourceReader implements Closeable {
|
public class ESRISourceReader implements Closeable {
|
||||||
private final MapWithAIInfo source;
|
private final MapWithAIInfo source;
|
||||||
private CachedFile cachedFile;
|
private List<CachedFile> cachedFiles = new ArrayList<>();
|
||||||
private boolean fastFail;
|
private boolean fastFail;
|
||||||
private final List<MapWithAICategory> ignoreConflationCategories;
|
private final List<MapWithAICategory> ignoreConflationCategories;
|
||||||
private static final String JSON_QUERY_PARAM = "?f=json";
|
private static final String JSON_QUERY_PARAM = "?f=json";
|
||||||
|
@ -85,6 +87,7 @@ public class ESRISourceReader implements Closeable {
|
||||||
try (CachedFile layers = new CachedFile(url + "content/groups/" + group + searchUrl);
|
try (CachedFile layers = new CachedFile(url + "content/groups/" + group + searchUrl);
|
||||||
BufferedReader i = layers.getContentReader();
|
BufferedReader i = layers.getContentReader();
|
||||||
JsonReader reader = Json.createReader(i)) {
|
JsonReader reader = Json.createReader(i)) {
|
||||||
|
cachedFiles.add(layers);
|
||||||
layers.setFastFail(fastFail);
|
layers.setFastFail(fastFail);
|
||||||
JsonStructure parser = reader.read();
|
JsonStructure parser = reader.read();
|
||||||
if (parser.getValueType() == JsonValue.ValueType.OBJECT) {
|
if (parser.getValueType() == JsonValue.ValueType.OBJECT) {
|
||||||
|
@ -215,7 +218,7 @@ public class ESRISourceReader implements Closeable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
Utils.close(cachedFile);
|
cachedFiles.forEach(Utils::close);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue