Changeset 11009 in josm


Ignore:
Timestamp:
2016-09-17T15:19:44+02:00 (8 years ago)
Author:
Don-vip
Message:

fix recent sonar/checkstyle issues

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java

    r11002 r11009  
    445445            switch(column) {
    446446            case 0:
    447                 setText(sr.name);
     447                setText(sr.getName());
    448448                break;
    449449            case 1:
    450                 setText(sr.info);
     450                setText(sr.getInfo());
    451451                break;
    452452            case 2:
    453                 setText(sr.nearestPlace);
     453                setText(sr.getNearestPlace());
    454454                break;
    455455            case 3:
    456                 if (sr.bounds != null) {
    457                     setText(sr.bounds.toShortString(new DecimalFormat("0.000")));
     456                if (sr.getBounds() != null) {
     457                    setText(sr.getBounds().toShortString(new DecimalFormat("0.000")));
    458458                } else {
    459                     setText(sr.zoom != 0 ? Integer.toString(sr.zoom) : tr("unknown"));
     459                    setText(sr.getZoom() != 0 ? Integer.toString(sr.getZoom()) : tr("unknown"));
    460460                }
    461461                break;
    462462            default: // Do nothing
    463463            }
    464             setToolTipText(lineWrapDescription(sr.description));
     464            setToolTipText(lineWrapDescription(sr.getDescription()));
    465465            return this;
    466466        }
  • trunk/src/org/openstreetmap/josm/io/CachedFile.java

    r10993 r11009  
    528528    /**
    529529     * Clears the cached file
    530      * @throws IOException
     530     * @throws IOException if any I/O error occurs
    531531     * @since 10993
    532532     */
  • trunk/src/org/openstreetmap/josm/io/NameFinder.java

    r11003 r11009  
    3030 * @since 11002
    3131 */
    32 public class NameFinder {
    33 
     32public final class NameFinder {
     33
     34    /**
     35     * Nominatim URL.
     36     */
    3437    public static final String NOMINATIM_URL = "https://nominatim.openstreetmap.org/search?format=xml&q=";
    3538
     
    6265     */
    6366    public static class SearchResult {
    64         public String name;
    65         public String info;
    66         public String nearestPlace;
    67         public String description;
    68         public double lat;
    69         public double lon;
    70         public int zoom;
    71         public Bounds bounds;
    72         public PrimitiveId osmId;
    73 
     67        private String name;
     68        private String info;
     69        private String nearestPlace;
     70        private String description;
     71        private double lat;
     72        private double lon;
     73        private int zoom;
     74        private Bounds bounds;
     75        private PrimitiveId osmId;
     76
     77        /**
     78         * Returns the name.
     79         * @return the name
     80         */
     81        public final String getName() {
     82            return name;
     83        }
     84
     85        /**
     86         * Returns the info.
     87         * @return the info
     88         */
     89        public final String getInfo() {
     90            return info;
     91        }
     92
     93        /**
     94         * Returns the nearest place.
     95         * @return the nearest place
     96         */
     97        public final String getNearestPlace() {
     98            return nearestPlace;
     99        }
     100
     101        /**
     102         * Returns the description.
     103         * @return the description
     104         */
     105        public final String getDescription() {
     106            return description;
     107        }
     108
     109        /**
     110         * Returns the latitude.
     111         * @return the latitude
     112         */
     113        public final double getLat() {
     114            return lat;
     115        }
     116
     117        /**
     118         * Returns the longitude.
     119         * @return the longitude
     120         */
     121        public final double getLon() {
     122            return lon;
     123        }
     124
     125        /**
     126         * Returns the zoom.
     127         * @return the zoom
     128         */
     129        public final int getZoom() {
     130            return zoom;
     131        }
     132
     133        /**
     134         * Returns the bounds.
     135         * @return the bounds
     136         */
     137        public final Bounds getBounds() {
     138            return bounds;
     139        }
     140
     141        /**
     142         * Returns the OSM id.
     143         * @return the OSM id
     144         */
     145        public final PrimitiveId getOsmId() {
     146            return osmId;
     147        }
     148
     149        /**
     150         * Returns the download area.
     151         * @return the download area
     152         */
    74153        public Bounds getDownloadArea() {
    75154            return bounds != null ? bounds : OsmUrlToBounds.positionToBounds(lat, lon, zoom);
  • trunk/src/org/openstreetmap/josm/io/OverpassDownloadReader.java

    r11003 r11009  
    88import java.util.EnumMap;
    99import java.util.List;
     10import java.util.NoSuchElementException;
    1011import java.util.regex.Matcher;
    1112import java.util.regex.Pattern;
     
    5859            return super.getRequestForBbox(lon1, lat1, lon2, lat2);
    5960        else {
    60             final String overpassQuery = this.overpassQuery.replace("{{bbox}}", lat1 + "," + lon1 + "," + lat2 + "," + lon2);
    61             final String expandedOverpassQuery = expandExtendedQueries(overpassQuery);
     61            final String query = this.overpassQuery.replace("{{bbox}}", lat1 + "," + lon1 + "," + lat2 + "," + lon2);
     62            final String expandedOverpassQuery = expandExtendedQueries(query);
    6263            return "interpreter?data=" + Utils.encodeUrl(expandedOverpassQuery);
    6364        }
     
    6768     * Evaluates some features of overpass turbo extended query syntax.
    6869     * See https://wiki.openstreetmap.org/wiki/Overpass_turbo/Extended_Overpass_Turbo_Queries
     70     * @param query unexpanded query
     71     * @return expanded query
    6972     */
    7073    static String expandExtendedQueries(String query) {
     
    7780                        matcher.appendReplacement(sb, geocodeArea(matcher.group(2)));
    7881                }
    79             } catch (Exception ex) {
     82            } catch (UncheckedParseException ex) {
    8083                final String msg = tr("Failed to evaluate {0}", matcher.group());
    8184                Main.warn(ex, msg);
     
    9194        final EnumMap<OsmPrimitiveType, Long> idOffset = new EnumMap<>(OsmPrimitiveType.class);
    9295        idOffset.put(OsmPrimitiveType.NODE, 0L);
    93         idOffset.put(OsmPrimitiveType.WAY, 2400000000L);
    94         idOffset.put(OsmPrimitiveType.RELATION, 3600000000L);
     96        idOffset.put(OsmPrimitiveType.WAY, 2_400_000_000L);
     97        idOffset.put(OsmPrimitiveType.RELATION, 3_600_000_000L);
    9598        try {
    9699            final List<NameFinder.SearchResult> results = NameFinder.queryNominatim(area);
    97             final PrimitiveId osmId = results.iterator().next().osmId;
     100            final PrimitiveId osmId = results.iterator().next().getOsmId();
    98101            return String.format("area(%d)", osmId.getUniqueId() + idOffset.get(osmId.getType()));
    99         } catch (IOException ex) {
     102        } catch (IOException | NoSuchElementException ex) {
    100103            throw new UncheckedParseException(ex);
    101104        }
     
    144147            @Override
    145148            protected void parseUnknown(boolean printWarning) throws XMLStreamException {
    146                 if ("remark".equals(parser.getLocalName())) {
    147                     if (parser.getEventType() == XMLStreamConstants.START_ELEMENT) {
    148                         final String text = parser.getElementText();
    149                         if (text.contains("runtime error")) {
    150                             throw new XMLStreamException(text);
    151                         }
     149                if ("remark".equals(parser.getLocalName()) && parser.getEventType() == XMLStreamConstants.START_ELEMENT) {
     150                    final String text = parser.getElementText();
     151                    if (text.contains("runtime error")) {
     152                        throw new XMLStreamException(text);
    152153                    }
    153154                }
  • trunk/test/unit/org/openstreetmap/josm/io/OverpassDownloadReaderTest.java

    r11003 r11009  
    44import static org.junit.Assert.assertEquals;
    55
    6 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    76import org.junit.Rule;
    87import org.junit.Test;
     
    1211import org.openstreetmap.josm.tools.OverpassTurboQueryWizard;
    1312import org.openstreetmap.josm.tools.Utils;
     13
     14import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1415
    1516/**
     
    7677        assertEquals("// Failed to evaluate {{geocodeArea:foo-bar-baz-does-not-exist}}\n", query);
    7778    }
    78 
    7979}
Note: See TracChangeset for help on using the changeset viewer.