Skip to content

Commit

Permalink
Merge branch 'JOSM:master' into ticket_21881
Browse files Browse the repository at this point in the history
  • Loading branch information
gabortim authored Apr 25, 2024
2 parents d820d38 + 3ce8b33 commit ae9ca5a
Show file tree
Hide file tree
Showing 242 changed files with 984 additions and 917 deletions.
11 changes: 10 additions & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,16 @@ Build-Date: ${build.tstamp}
<compilerarg value="-Xlint:unchecked"/>
<!-- Undocumented argument to ignore "Sun internal proprietary API" warning, see http://stackoverflow.com/a/13862308/2257172 -->
<compilerarg value="-XDignore.symbol.file"/>
<compilerarg value="-Xplugin:ErrorProne -XepExcludedPaths:.*/parsergen/.* -Xep:ReferenceEquality:OFF -Xep:FutureReturnValueIgnored:OFF -Xep:JdkObsolete:OFF -Xep:EqualsGetClass:OFF -Xep:UndefinedEquals:OFF -Xep:BadImport:OFF -Xep:AnnotateFormatMethod:OFF -Xep:JavaUtilDate:OFF -Xep:DoNotCallSuggester:OFF -Xep:BanSerializableRead:OFF -Xep:InlineMeSuggester:OFF" unless:set="noErrorProne"/>
<!-- -XepExcludedPaths:.*/parsergen/.*: see #16860 - Resolve JavaCC using Apache Ivy -->
<!-- ReferenceEquality: see #12472, fix #13230, fix #13225, fix #13228 - disable ReferenceEquality warning + partial revert of r10656 + r10659, causes too much problems -->
<!-- FutureReturnValueIgnored: update to error_prone 2.0.18 (disabled on purpose?) -->
<!-- JdkObsolete: see #11924 - see #15560 - support jdk10+ in build.xml, update to proguard 6.0beta1 and error_prone 2.1.2 (disabled due to crashes) -->
<!-- EqualsGetClass, UndefinedEquals: see #16498 - update to error_prone 2.3.2-20180817.184126-35 to test JDK 12 compatibility. (disabled due to crashes?) -->
<!-- BadImport, AnnotateFormatMethod: see #17516 - update to error-prone 2.3.5-SNAPSHOT plus following patches for Java 13 compatibility (disabled due to crashes?) -->
<!-- JavaUtilDate, DoNotCallSuggester, BanSerializableRead: see #19724 - update to error-prone 2.5.1, checkstyle 8.36, spotbugs 4.2.1 (disabled due to crashes?) -->
<!-- InlineMeSuggester: See #20522 - Disable https://errorprone.info/bugpattern/InlineMeSuggester (maybe it crashed?) -->
<!-- LongDoubleConversion: Disable due to conflicting with Sonar settings -->
<compilerarg value="-Xplugin:ErrorProne -XepExcludedPaths:.*/parsergen/.* -Xep:ReferenceEquality:OFF -Xep:FutureReturnValueIgnored:OFF -Xep:JdkObsolete:OFF -Xep:EqualsGetClass:OFF -Xep:UndefinedEquals:OFF -Xep:BadImport:OFF -Xep:AnnotateFormatMethod:OFF -Xep:JavaUtilDate:OFF -Xep:DoNotCallSuggester:OFF -Xep:BanSerializableRead:OFF -Xep:InlineMeSuggester:OFF -Xep:LongDoubleConversion:OFF" unless:set="noErrorProne"/>
<compilerarg line="-Xmaxwarns 1000"/>
<compilerarg value="-Xplugin:semanticdb -sourceroot:@{srcdir} -targetroot:${build.dir}/semanticdb" if:set="lsif" />
<classpath>
Expand Down
2 changes: 1 addition & 1 deletion native/windows/win-jpackage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ do
--file-associations native/file-associations/osm.properties \
--file-associations native/file-associations/xz.properties \
--file-associations native/file-associations/zip.properties \
--add-launcher "JOSM HWConsole"=native/windows/MLConsole.properties \
--add-launcher "JOSM (Debug)"=native/windows/MLConsole.properties \
--add-modules java.compiler,java.base,java.datatransfer,java.desktop,java.logging,java.management,java.naming,java.net.http,java.prefs,java.rmi,java.scripting,java.sql,java.transaction.xa,java.xml,jdk.crypto.ec,jdk.jfr,jdk.jsobject,jdk.unsupported,jdk.unsupported.desktop,jdk.xml.dom,javafx.controls,javafx.media,javafx.swing,javafx.web
done

Expand Down
18 changes: 10 additions & 8 deletions scripts/TagInfoExtract.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// License: GPL. For details, see LICENSE file.

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
Expand Down Expand Up @@ -31,11 +32,6 @@
import java.util.stream.Stream;

import javax.imageio.ImageIO;
import jakarta.json.Json;
import jakarta.json.JsonArrayBuilder;
import jakarta.json.JsonObjectBuilder;
import jakarta.json.JsonWriter;
import jakarta.json.stream.JsonGenerator;

import org.openstreetmap.josm.actions.DeleteAction;
import org.openstreetmap.josm.command.DeleteCommand;
Expand Down Expand Up @@ -84,6 +80,12 @@
import org.openstreetmap.josm.tools.Utils;
import org.xml.sax.SAXException;

import jakarta.json.Json;
import jakarta.json.JsonArrayBuilder;
import jakarta.json.JsonObjectBuilder;
import jakarta.json.JsonWriter;
import jakarta.json.stream.JsonGenerator;

/**
* Extracts tag information for the taginfo project.
* <p>
Expand Down Expand Up @@ -162,7 +164,7 @@ private void usage() {
System.exit(0);
}

private static class Options {
private static final class Options {
Mode mode;
int josmSvnRevision = Version.getInstance().getVersion();
Path baseDir = Paths.get("");
Expand Down Expand Up @@ -313,7 +315,7 @@ private Collection<String> values(KeyedItem item) {
}
}

private class ExternalPresets extends Presets {
private final class ExternalPresets extends Presets {

@Override
void run() throws IOException, OsmTransferException, SAXException {
Expand All @@ -340,7 +342,7 @@ void run() throws IOException, OsmTransferException, SAXException {
}
}

private class StyleSheet extends Extractor {
private final class StyleSheet extends Extractor {
private MapCSSStyleSource styleSource;

@Override
Expand Down
2 changes: 1 addition & 1 deletion scripts/TaggingPresetSchemeWikiGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private static void printAttributes() throws XPathExpressionException {
node.getTextContent().trim()));
}

private static class TaggingNamespaceContext implements NamespaceContext {
private static final class TaggingNamespaceContext implements NamespaceContext {
@Override
public String getNamespaceURI(String prefix) {
switch (prefix) {
Expand Down
55 changes: 29 additions & 26 deletions src/org/openstreetmap/josm/actions/AddImageryLayerAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.nio.file.InvalidPathException;
import java.time.Year;
import java.time.ZoneOffset;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
Expand All @@ -25,6 +26,8 @@
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import org.openstreetmap.josm.data.coor.LatLon;
import org.openstreetmap.josm.data.imagery.DefaultLayer;
import org.openstreetmap.josm.data.imagery.ImageryInfo;
import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
import org.openstreetmap.josm.data.imagery.LayerDetails;
Expand Down Expand Up @@ -59,9 +62,9 @@ public class AddImageryLayerAction extends JosmAction implements AdaptableAction
static class SelectWmsLayersDialog extends ExtendedDialog {
SelectWmsLayersDialog(WMSLayerTree tree, JComboBox<String> formats) {
super(MainApplication.getMainFrame(), tr("Select WMS layers"), tr("Add layers"), tr("Cancel"));
final var scrollPane = new JScrollPane(tree.getLayerTree());
final JScrollPane scrollPane = new JScrollPane(tree.getLayerTree());
scrollPane.setPreferredSize(new Dimension(400, 400));
final var panel = new JPanel(new GridBagLayout());
final JPanel panel = new JPanel(new GridBagLayout());
panel.add(scrollPane, GBC.eol().fill());
panel.add(formats, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
setContent(panel);
Expand All @@ -81,7 +84,7 @@ public AddImageryLayerAction(ImageryInfo info) {
installAdapters();

// change toolbar icon from if specified
var icon = info.getIcon();
String icon = info.getIcon();
if (icon != null) {
new ImageProvider(icon).setOptional(true).getResourceAsync(result -> {
if (result != null) {
Expand All @@ -100,10 +103,10 @@ public AddImageryLayerAction(ImageryInfo info) {
private static ImageryInfo convertImagery(ImageryInfo info) {
try {
if (info.getUrl() != null && info.getUrl().contains("{time}")) {
final var instant = Year.now(ZoneOffset.UTC).atDay(1).atStartOfDay(ZoneOffset.UTC).toInstant().toString();
final var example = String.join("/", instant, instant);
final var initialSelectionValue = info.getDate() != null ? info.getDate() : example;
final var userDate = JOptionPane.showInputDialog(MainApplication.getMainFrame(),
final String instant = Year.now(ZoneOffset.UTC).atDay(1).atStartOfDay(ZoneOffset.UTC).toInstant().toString();
final String example = String.join("/", instant, instant);
final String initialSelectionValue = info.getDate() != null ? info.getDate() : example;
final String userDate = JOptionPane.showInputDialog(MainApplication.getMainFrame(),
tr("Time filter for \"{0}\" such as \"{1}\"", info.getName(), example),
initialSelectionValue);
if (userDate == null) {
Expand All @@ -123,12 +126,12 @@ private static ImageryInfo convertImagery(ImageryInfo info) {
case WMTS:
// specify which layer to use
if (Utils.isEmpty(info.getDefaultLayers())) {
var tileSource = new WMTSTileSource(info);
var layerId = tileSource.userSelectLayer();
WMTSTileSource tileSource = new WMTSTileSource(info);
DefaultLayer layerId = tileSource.userSelectLayer();
if (layerId != null) {
var copy = new ImageryInfo(info);
ImageryInfo copy = new ImageryInfo(info);
copy.setDefaultLayers(Collections.singletonList(layerId));
var layerName = tileSource.getLayers().stream()
String layerName = tileSource.getLayers().stream()
.filter(x -> x.getIdentifier().equals(layerId.getLayerName()))
.map(Layer::getUserTitle)
.findFirst()
Expand Down Expand Up @@ -162,7 +165,7 @@ public void actionPerformed(ActionEvent e) {
if (!isEnabled()) return;
ImageryLayer layer = null;
try {
final var infoToAdd = convertImagery(info);
final ImageryInfo infoToAdd = convertImagery(info);
if (infoToAdd != null) {
layer = ImageryLayer.create(infoToAdd);
getLayerManager().addLayer(layer);
Expand Down Expand Up @@ -204,16 +207,16 @@ public LayerSelection(List<LayerDetails> layers, String format, boolean transpar
}

private static LayerSelection askToSelectLayers(WMSImagery wms) {
final var tree = new WMSLayerTree();
final WMSLayerTree tree = new WMSLayerTree();

var wmsFormats = wms.getFormats();
final var formats = new JComboBox<String>(wmsFormats.toArray(new String[0]));
Collection<String> wmsFormats = wms.getFormats();
final JComboBox<String> formats = new JComboBox<>(wmsFormats.toArray(new String[0]));
formats.setSelectedItem(wms.getPreferredFormat());
formats.setToolTipText(tr("Select image format for WMS layer"));

var checkBounds = new JCheckBox(tr("Show only layers for current view"), true);
JCheckBox checkBounds = new JCheckBox(tr("Show only layers for current view"), true);
Runnable updateTree = () -> {
var latLon = checkBounds.isSelected() && MainApplication.isDisplayingMapView()
LatLon latLon = checkBounds.isSelected() && MainApplication.isDisplayingMapView()
? MainApplication.getMap().mapView.getProjection().eastNorth2latlon(MainApplication.getMap().mapView.getCenter())
: null;
tree.setCheckBounds(latLon);
Expand All @@ -224,11 +227,11 @@ private static LayerSelection askToSelectLayers(WMSImagery wms) {
updateTree.run();

if (!GraphicsEnvironment.isHeadless()) {
var dialog = new ExtendedDialog(MainApplication.getMainFrame(),
ExtendedDialog dialog = new ExtendedDialog(MainApplication.getMainFrame(),
tr("Select WMS layers"), tr("Add layers"), tr("Cancel"));
final var scrollPane = new JScrollPane(tree.getLayerTree());
final JScrollPane scrollPane = new JScrollPane(tree.getLayerTree());
scrollPane.setPreferredSize(new Dimension(400, 400));
final var panel = new JPanel(new GridBagLayout());
final JPanel panel = new JPanel(new GridBagLayout());
panel.add(scrollPane, GBC.eol().fill());
panel.add(checkBounds, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
panel.add(formats, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
Expand Down Expand Up @@ -280,25 +283,25 @@ public static ImageryInfo getWMSLayerInfo(ImageryInfo info, Function<WMSImagery,
throws IOException, WMSGetCapabilitiesException {
CheckParameterUtil.ensureThat(ImageryType.WMS_ENDPOINT == info.getImageryType(), "wms_endpoint imagery type expected");
// We need to get the URL with {apikey} replaced. See #22642.
final var tileSource = new TemplatedWMSTileSource(info, ProjectionRegistry.getProjection());
final var wms = new WMSImagery(tileSource.getBaseUrl(), info.getCustomHttpHeaders());
var selection = choice.apply(wms);
final TemplatedWMSTileSource tileSource = new TemplatedWMSTileSource(info, ProjectionRegistry.getProjection());
final WMSImagery wms = new WMSImagery(tileSource.getBaseUrl(), info.getCustomHttpHeaders());
LayerSelection selection = choice.apply(wms);
if (selection == null) {
return null;
}

final var url = wms.buildGetMapUrl(
final String url = wms.buildGetMapUrl(
selection.layers.stream().map(LayerDetails::getName).collect(Collectors.toList()),
(List<String>) null,
selection.format,
selection.transparent
);

var selectedLayers = selection.layers.stream()
String selectedLayers = selection.layers.stream()
.map(LayerDetails::getName)
.collect(Collectors.joining(", "));
// Use full copy of original Imagery info to copy all attributes. Only overwrite what's different
var ret = new ImageryInfo(info);
ImageryInfo ret = new ImageryInfo(info);
ret.setUrl(url);
ret.setImageryType(ImageryType.WMS);
ret.setName(info.getName() + " - " + selectedLayers);
Expand Down
15 changes: 9 additions & 6 deletions src/org/openstreetmap/josm/actions/AutoScaleAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.geom.Area;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
Expand All @@ -21,6 +22,7 @@
import org.openstreetmap.josm.data.Bounds;
import org.openstreetmap.josm.data.DataSource;
import org.openstreetmap.josm.data.conflict.Conflict;
import org.openstreetmap.josm.data.osm.DataSet;
import org.openstreetmap.josm.data.osm.IPrimitive;
import org.openstreetmap.josm.data.osm.OsmData;
import org.openstreetmap.josm.data.osm.OsmPrimitive;
Expand All @@ -31,6 +33,7 @@
import org.openstreetmap.josm.gui.MapFrameListener;
import org.openstreetmap.josm.gui.MapView;
import org.openstreetmap.josm.gui.NavigatableComponent.ZoomChangeListener;
import org.openstreetmap.josm.gui.dialogs.ConflictDialog;
import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
import org.openstreetmap.josm.gui.dialogs.ValidatorDialog.ValidatorBoundingXYVisitor;
import org.openstreetmap.josm.gui.layer.Layer;
Expand Down Expand Up @@ -142,7 +145,7 @@ public static void zoomToSelection() {
* @param sel The primitives to zoom to, e.g. the current selection.
*/
public static void zoomTo(Collection<? extends IPrimitive> sel) {
final var bboxCalculator = new BoundingXYVisitor();
BoundingXYVisitor bboxCalculator = new BoundingXYVisitor();
bboxCalculator.computeBoundingBox(sel);
if (bboxCalculator.getBounds() != null) {
MainApplication.getMap().mapView.zoomTo(bboxCalculator);
Expand Down Expand Up @@ -240,7 +243,7 @@ public AutoScaleAction(final AutoScaleMode mode) {
*/
public void autoScale() {
if (MainApplication.isDisplayingMapView()) {
final var mapView = MainApplication.getMap().mapView;
MapView mapView = MainApplication.getMap().mapView;
switch (mode) {
case PREVIOUS:
mapView.zoomPrevious();
Expand Down Expand Up @@ -308,7 +311,7 @@ private static void modeData(BoundingXYVisitor v) {

private void modeLayer(BoundingXYVisitor v) {
// try to zoom to the first selected layer
final var l = getFirstSelectedLayer();
Layer l = getFirstSelectedLayer();
if (l == null)
return;
l.visitBoundingBox(v);
Expand All @@ -323,7 +326,7 @@ private void modeSelectionOrConflict(BoundingXYVisitor v) {
sel.addAll(dataSet.getSelected());
}
} else {
final var conflictDialog = MainApplication.getMap().conflictDialog;
ConflictDialog conflictDialog = MainApplication.getMap().conflictDialog;
Conflict<? extends IPrimitive> c = conflictDialog.getSelectedConflict();
if (c != null) {
sel.add(c.getMy());
Expand Down Expand Up @@ -355,7 +358,7 @@ private void modeDownload() {
lastZoomTime = -1;
}
Bounds bbox = null;
final var dataset = getLayerManager().getActiveDataSet();
final DataSet dataset = getLayerManager().getActiveDataSet();
if (dataset != null) {
List<DataSource> dataSources = new ArrayList<>(dataset.getDataSources());
int s = dataSources.size();
Expand All @@ -368,7 +371,7 @@ private void modeDownload() {
bbox = dataSources.get(lastZoomArea).bounds;
} else {
lastZoomArea = -1;
final var sourceArea = getLayerManager().getActiveDataSet().getDataSourceArea();
Area sourceArea = getLayerManager().getActiveDataSet().getDataSourceArea();
if (sourceArea != null) {
bbox = new Bounds(sourceArea.getBounds2D());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public DownloadOsmInViewAction() {

@Override
public void actionPerformed(ActionEvent e) {
final var bounds = MainApplication.getMap().mapView.getRealBounds();
final var task = new DownloadOsmInViewTask();
final Bounds bounds = MainApplication.getMap().mapView.getRealBounds();
DownloadOsmInViewTask task = new DownloadOsmInViewTask();
task.setZoomAfterDownload(false);
Future<?> future = task.download(bounds);
MainApplication.worker.submit(new PostDownloadHandler(task, future));
Expand All @@ -54,7 +54,7 @@ protected void updateEnabledState() {
&& !NetworkManager.isOffline(OnlineResource.OSM_API));
}

private static class DownloadOsmInViewTask extends DownloadOsmTask {
private static final class DownloadOsmInViewTask extends DownloadOsmTask {
Future<?> download(Bounds downloadArea) {
return download(new DownloadTask(new DownloadParams(), new BoundingBoxDownloader(downloadArea), null, false), downloadArea);
}
Expand Down
Loading

0 comments on commit ae9ca5a

Please sign in to comment.