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


Ignore:
Timestamp:
2014-02-18T17:21:45+01:00 (10 years ago)
Author:
Don-vip
Message:

fix #9731 - fix a bunch of problems occuring when validating incomplete data

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java

    r6691 r6869  
    1313import java.util.Set;
    1414
    15 import org.openstreetmap.josm.data.osm.Node;
     15import org.openstreetmap.josm.Main;
     16import org.openstreetmap.josm.data.coor.EastNorth;
    1617import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1718import org.openstreetmap.josm.data.osm.Relation;
     
    3334public abstract class CrossingWays extends Test {
    3435    protected static final int CROSSING_WAYS = 601;
    35    
     36
    3637    private static final String HIGHWAY = "highway";
    3738    private static final String RAILWAY = "railway";
     
    227228        for (int i = 0; i < nodesSize - 1; i++) {
    228229            final WaySegment es1 = new WaySegment(w, i);
    229             for (List<WaySegment> segments : getSegments(es1.getFirstNode(), es1.getSecondNode())) {
     230            final EastNorth en1 = es1.getFirstNode().getEastNorth();
     231            final EastNorth en2 = es1.getSecondNode().getEastNorth();
     232            if (en1 == null || en2 == null) {
     233                Main.warn("Crossing ways test skipped "+es1);
     234                continue;
     235            }
     236            for (List<WaySegment> segments : getSegments(en1, en2)) {
    230237                for (WaySegment es2 : segments) {
    231238                    List<Way> prims;
     
    265272     * of segments already processed
    266273     *
    267      * @param n1 The first node
    268      * @param n2 The second node
     274     * @param n1 The first EastNorth
     275     * @param n2 The second EastNorth
    269276     * @return A list with all the cells the segment crosses
    270277     */
    271     public List<List<WaySegment>> getSegments(Node n1, Node n2) {
     278    public List<List<WaySegment>> getSegments(EastNorth n1, EastNorth n2) {
    272279
    273280        List<List<WaySegment>> cells = new ArrayList<List<WaySegment>>();
     
    282289        return cells;
    283290    }
    284 
    285291}
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r6773 r6869  
    183183            }));
    184184        }
    185        
     185
    186186        private static void removeMetaRules(MapCSSStyleSource source) {
    187187            for (Iterator<MapCSSRule> it = source.rules.iterator(); it.hasNext(); ) {
     
    270270            while (m.find()) {
    271271                final String argument = determineArgument((Selector.GeneralSelector) matchingSelector, Integer.parseInt(m.group(1)), m.group(2));
    272                 m.appendReplacement(sb, String.valueOf(argument));
     272                try {
     273                    m.appendReplacement(sb, String.valueOf(argument));
     274                } catch (IndexOutOfBoundsException e) {
     275                    Main.error(tr("Unable to replace argument {0} in {1}: {2}", argument, sb, e.getMessage()));
     276                }
    273277            }
    274278            m.appendTail(sb);
  • trunk/src/org/openstreetmap/josm/data/validation/util/ValUtil.java

    r6362 r6869  
    1010import java.util.Set;
    1111
     12import org.openstreetmap.josm.data.coor.EastNorth;
    1213import org.openstreetmap.josm.data.osm.Node;
    1314import org.openstreetmap.josm.data.osm.Way;
    1415import org.openstreetmap.josm.data.validation.OsmValidator;
     16import org.openstreetmap.josm.tools.CheckParameterUtil;
    1517
    1618/**
     
    2022 */
    2123public final class ValUtil {
    22    
     24
    2325    private ValUtil() {
    2426        // Hide default constructor for utils classes
    2527    }
    26    
     28
    2729    /**
    2830     * Returns the start and end cells of a way.
     
    103105
    104106    /**
    105      * Returns the coordinates of all cells in a grid that a line between 2
    106      * nodes intersects with.
     107     * Returns the coordinates of all cells in a grid that a line between 2 nodes intersects with.
    107108     *
    108109     * @param n1 The first node.
     
    111112     * cells, but a bigger number of them.
    112113     * @return A list with the coordinates of all cells
     114     * @throws IllegalArgumentException if n1 or n2 is {@code null} or without coordinates
    113115     */
    114     public static List<Point2D> getSegmentCells(Node n1, Node n2, double gridDetail) {
     116    public static List<Point2D> getSegmentCells(Node n1, Node n2, double gridDetail) throws IllegalArgumentException {
     117        CheckParameterUtil.ensureParameterNotNull(n1, "n1");
     118        CheckParameterUtil.ensureParameterNotNull(n1, "n2");
     119        return getSegmentCells(n1.getEastNorth(), n2.getEastNorth(), gridDetail);
     120    }
     121
     122    /**
     123     * Returns the coordinates of all cells in a grid that a line between 2 nodes intersects with.
     124     *
     125     * @param en1 The first EastNorth.
     126     * @param en2 The second EastNorth.
     127     * @param gridDetail The detail of the grid. Bigger values give smaller
     128     * cells, but a bigger number of them.
     129     * @return A list with the coordinates of all cells
     130     * @throws IllegalArgumentException if en1 or en2 is {@code null}
     131     * @since 6869
     132     */
     133    public static List<Point2D> getSegmentCells(EastNorth en1, EastNorth en2, double gridDetail) throws IllegalArgumentException {
     134        CheckParameterUtil.ensureParameterNotNull(en1, "en1");
     135        CheckParameterUtil.ensureParameterNotNull(en2, "en2");
    115136        List<Point2D> cells = new ArrayList<Point2D>();
    116         double x0 = n1.getEastNorth().east() * gridDetail;
    117         double x1 = n2.getEastNorth().east() * gridDetail;
    118         double y0 = n1.getEastNorth().north() * gridDetail + 1;
    119         double y1 = n2.getEastNorth().north() * gridDetail + 1;
     137        double x0 = en1.east() * gridDetail;
     138        double x1 = en2.east() * gridDetail;
     139        double y0 = en1.north() * gridDetail + 1;
     140        double y1 = en2.north() * gridDetail + 1;
    120141
    121142        if (x0 > x1) {
  • trunk/src/org/openstreetmap/josm/gui/MapStatus.java

    r6852 r6869  
    377377                        });
    378378                    } catch (InterruptedException e) {
    379                         // Occurs frequently during JOSM shutdown, log set to debug only
    380                         Main.debug("InterruptedException in "+MapStatus.class.getSimpleName());
     379                        // Occurs frequently during JOSM shutdown, log set to trace only
     380                        Main.trace("InterruptedException in "+MapStatus.class.getSimpleName());
    381381                    } catch (InvocationTargetException e) {
    382382                        Main.warn(e);
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/RequestHandler.java

    r6798 r6869  
    4848
    4949    /**
    50      * who send th request?
    51      * the host from refrerer header or IP of request sender
     50     * who sent the request?
     51     * the host from referer header or IP of request sender
    5252     */
    5353    protected String sender;
     
    108108
    109109    abstract public String[] getMandatoryParams();
    110    
     110
    111111    public String[] getOptionalParams() {
    112112        return null;
     
    242242                    + Utils.join(", ", missingKeys));
    243243        }
    244        
    245244    }
    246245
  • trunk/src/org/openstreetmap/josm/tools/Geometry.java

    r6841 r6869  
    452452        boolean begin = true;
    453453        for (Node n : polygon) {
    454             if (begin) {
    455                 path.moveTo(n.getEastNorth().getX(), n.getEastNorth().getY());
    456                 begin = false;
    457             } else {
    458                 path.lineTo(n.getEastNorth().getX(), n.getEastNorth().getY());
     454            EastNorth en = n.getEastNorth();
     455            if (en != null) {
     456                if (begin) {
     457                    path.moveTo(en.getX(), en.getY());
     458                    begin = false;
     459                } else {
     460                    path.lineTo(en.getX(), en.getY());
     461                }
    459462            }
    460463        }
Note: See TracChangeset for help on using the changeset viewer.