Changeset 11587 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2017-02-19T23:52:08+01:00 (7 years ago)
Author:
Don-vip
Message:

checkstyle - enable BooleanExpressionComplexity / 6

Location:
trunk/src/org/openstreetmap/josm
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/Bounds.java

    r11272 r11587  
    477477    }
    478478
     479    /**
     480     * Determines if these bounds are out of the world.
     481     * @return true if lat outside of range [-90,90] or lon outside of range [-180,180]
     482     */
    479483    public boolean isOutOfTheWorld() {
    480484        return
    481         minLat < -90 || minLat > 90 ||
    482         maxLat < -90 || maxLat > 90 ||
    483         minLon < -180 || minLon > 180 ||
    484         maxLon < -180 || maxLon > 180;
    485     }
    486 
     485        !LatLon.isValidLat(minLat) ||
     486        !LatLon.isValidLat(maxLat) ||
     487        !LatLon.isValidLon(minLon) ||
     488        !LatLon.isValidLon(maxLon);
     489    }
     490
     491    /**
     492     * Clamp the bounds to be inside the world.
     493     */
    487494    public void normalize() {
    488495        minLat = LatLon.toIntervalLat(minLat);
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java

    r11578 r11587  
    499499        }
    500500
     501        // CHECKSTYLE.OFF: BooleanExpressionComplexity
    501502        return
    502503                Objects.equals(this.name, other.name) &&
     
    527528                Objects.equals(this.metadataHeaders, other.metadataHeaders) &&
    528529                Objects.equals(this.defaultLayers, other.defaultLayers);
     530        // CHECKSTYLE.ON: BooleanExpressionComplexity
    529531    }
    530532
  • trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java

    r11452 r11587  
    725725
    726726    /**
     727     * Replies true if this primitive has a tag any of the <code>keys</code>.
     728     *
     729     * @param keys the keys
     730     * @return true, if his primitive has a tag with any of the <code>keys</code>
     731     * @since 11587
     732     */
     733    public boolean hasKey(String ... keys) {
     734        return keys != null && Arrays.stream(keys).anyMatch(this::hasKey);
     735    }
     736
     737    /**
    727738     * What to do, when the tags have changed by one of the tag-changing methods.
    728739     * @param originalKeys original tags
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r11503 r11587  
    11781178     */
    11791179    public boolean hasEqualTechnicalAttributes(OsmPrimitive other) {
     1180        // CHECKSTYLE.OFF: BooleanExpressionComplexity
    11801181        return other != null
    11811182            && timestamp == other.timestamp
     
    11861187            && isVisible() == other.isVisible()
    11871188            && Objects.equals(user, other.user);
     1189        // CHECKSTYLE.ON: BooleanExpressionComplexity
    11881190    }
    11891191
     
    13541356                || "yes".equals(get("area"))
    13551357                || "riverbank".equals(get("waterway"))
    1356                 || hasKey("natural")
    1357                 || hasKey("amenity")
    1358                 || hasKey("leisure")
    1359                 || hasKey("building")
    1360                 || hasKey("building:part");
     1358                || hasKey("natural", "amenity", "leisure", "building", "building:part");
    13611359    }
    13621360
  • trunk/src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java

    r11191 r11587  
    5757            return super.isPrimitiveUsable(w)
    5858                    && !isProposedOrAbandoned(w)
    59                     && ((w.hasKey(HIGHWAY) && !w.hasTag(HIGHWAY, "rest_area", "services"))
     59                    && (isHighway(w)
    6060                    || w.hasKey(WATERWAY)
    61                     || (w.hasKey(RAILWAY) && !isSubwayOrTramOrRazed(w))
     61                    || isRailway(w)
    6262                    || isCoastline(w)
    6363                    || isBuilding(w));
     
    238238    static boolean isCoastline(OsmPrimitive w) {
    239239        return w.hasTag("natural", "water", "coastline") || w.hasTag("landuse", "reservoir");
     240    }
     241
     242    static boolean isHighway(OsmPrimitive w) {
     243        return w.hasKey(HIGHWAY) && !w.hasTag(HIGHWAY, "rest_area", "services");
     244    }
     245
     246    static boolean isRailway(OsmPrimitive w) {
     247        return w.hasKey(RAILWAY) && !isSubwayOrTramOrRazed(w);
    240248    }
    241249
  • trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java

    r11452 r11587  
    111111        @Override
    112112        public boolean isPrimitiveUsable(OsmPrimitive p) {
    113             return super.isPrimitiveUsable(p) && (p.hasKey("natural") || p.hasKey("landuse"));
     113            return super.isPrimitiveUsable(p) && p.hasKey("natural", "landuse");
    114114        }
    115115    }
     
    185185                            || en.hasTag("railway", "buffer_stop")
    186186                            || en.isKeyTrue("noexit")
    187                             || en.hasKey("entrance")
    188                             || en.hasKey("barrier")) {
     187                            || en.hasKey("entrance", "barrier")) {
    189188                        continue;
    190189                    }
     
    451450            ways.addAll(getWaySegments(w));
    452451            QuadBuckets<Node> set = endnodes;
    453             if (w.hasKey("highway") || w.hasKey("railway")) {
     452            if (w.hasKey("highway", "railway")) {
    454453                set = endnodesHighway;
    455454            }
  • trunk/src/org/openstreetmap/josm/data/validation/tests/WayConnectedToArea.java

    r11462 r11587  
    8181
    8282    private static boolean isArea(OsmPrimitive p) {
    83         return (p.hasKey("landuse") || p.hasKey("natural"))
    84                 && ElemStyles.hasAreaElemStyle(p, false);
     83        return p.hasKey("landuse", "natural") && ElemStyles.hasAreaElemStyle(p, false);
    8584    }
    8685
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSortUtils.java

    r9246 r11587  
    77
    88import org.openstreetmap.josm.data.coor.EastNorth;
     9import org.openstreetmap.josm.data.osm.Node;
    910import org.openstreetmap.josm.data.osm.RelationMember;
    1011import org.openstreetmap.josm.data.osm.Way;
     
    2829
    2930    static Direction roundaboutType(Way w) {
    30         if (w != null &&
    31                 "roundabout".equals(w.get("junction")) &&
    32                 w.getNodesCount() < 200 &&
    33                 w.getNodesCount() > 2 &&
    34                 w.getNode(0) != null &&
    35                 w.getNode(1) != null &&
    36                 w.getNode(2) != null &&
    37                 w.isClosed()) {
    38             /** do some simple determinant / cross pruduct test on the first 3 nodes
    39                 to see, if the roundabout goes clock wise or ccw */
    40             EastNorth en1 = w.getNode(0).getEastNorth();
    41             EastNorth en2 = w.getNode(1).getEastNorth();
    42             EastNorth en3 = w.getNode(2).getEastNorth();
    43             if (en1 != null && en2 != null && en3 != null) {
    44                 en1 = en2.subtract(en1);
    45                 en2 = en3.subtract(en2);
    46                 return en1.north() * en2.east() - en2.north() * en1.east() > 0 ? ROUNDABOUT_LEFT : ROUNDABOUT_RIGHT;
     31        if (w != null && "roundabout".equals(w.get("junction"))) {
     32            int nodesCount = w.getNodesCount();
     33            if (nodesCount > 2 && nodesCount < 200) {
     34                Node n1 = w.getNode(0);
     35                Node n2 = w.getNode(1);
     36                Node n3 = w.getNode(2);
     37                if (n1 != null && n2 != null && n3 != null && w.isClosed()) {
     38                    /** do some simple determinant / cross pruduct test on the first 3 nodes
     39                        to see, if the roundabout goes clock wise or ccw */
     40                    EastNorth en1 = n1.getEastNorth();
     41                    EastNorth en2 = n2.getEastNorth();
     42                    EastNorth en3 = n3.getEastNorth();
     43                    if (en1 != null && en2 != null && en3 != null) {
     44                        en1 = en2.subtract(en1);
     45                        en2 = en3.subtract(en2);
     46                        return en1.north() * en2.east() - en2.north() * en1.east() > 0 ? ROUNDABOUT_LEFT : ROUNDABOUT_RIGHT;
     47                    }
     48                }
    4749            }
    4850        }
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java

    r11566 r11587  
    13521352     */
    13531353    private void checkCache() {
     1354        // CHECKSTYLE.OFF: BooleanExpressionComplexity
    13541355        if ((computeCacheMaxLineLengthUsed != maxLineLength)
    13551356                || (computeCacheColored != colored)
     
    13611362                || (computeCacheHeatMapDrawGain != heatMapDrawGain))
    13621363                || (computeCacheHeatMapDrawLowerLimit != heatMapDrawLowerLimit)
    1363       ) {
     1364        ) {
     1365            // CHECKSTYLE.ON: BooleanExpressionComplexity
    13641366            computeCacheMaxLineLengthUsed = maxLineLength;
    13651367            computeCacheInSync = false;
  • trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java

    r11381 r11587  
    268268        return ImageIO.getImageReadersByMIMEType(format).hasNext()
    269269                // handles image/tiff image/tiff8 image/geotiff image/geotiff8
    270                 || ((format.startsWith("image/tiff") || format.startsWith("image/geotiff"))
    271                         && ImageIO.getImageReadersBySuffix("tiff").hasNext())
    272                 || (format.startsWith("image/png") && ImageIO.getImageReadersBySuffix("png").hasNext())
    273                 || (format.startsWith("image/svg") && ImageIO.getImageReadersBySuffix("svg").hasNext())
    274                 || (format.startsWith("image/bmp") && ImageIO.getImageReadersBySuffix("bmp").hasNext());
     270                || isImageFormatSupported(format, "tiff", "geotiff")
     271                || isImageFormatSupported(format, "png")
     272                || isImageFormatSupported(format, "svg")
     273                || isImageFormatSupported(format, "bmp");
     274    }
     275
     276    static boolean isImageFormatSupported(String format, String ... mimeFormats) {
     277        for (String mime : mimeFormats) {
     278            if (format.startsWith("image/" + mime)) {
     279                return ImageIO.getImageReadersBySuffix(mimeFormats[0]).hasNext();
     280            }
     281        }
     282        return false;
    275283    }
    276284
Note: See TracChangeset for help on using the changeset viewer.