Ignore:
Timestamp:
2014-09-03T22:48:35+02:00 (10 years ago)
Author:
donvip
Message:

[josm_simplifyarea] fix #josm10473 - NPE

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/simplifyarea/src/sk/zdila/josm/plugin/simplify/SimplifyAreaAction.java

    r30145 r30623  
    4040public class SimplifyAreaAction extends JosmAction {
    4141
    42     private static final long serialVersionUID = 6854238214548011750L;
    43 
    4442    public SimplifyAreaAction() {
    4543        super(tr("Simplify Area"), "simplify", tr("Delete unnecessary nodes from an area."),
     
    4846    }
    4947
    50 
    5148    private List<Bounds> getCurrentEditBounds() {
    5249        return Main.main.getEditLayer().data.getDataSourceBounds();
    5350    }
    54 
    5551
    5652    private boolean isInBounds(final Node node, final List<Bounds> bounds) {
     
    6258        return false;
    6359    }
    64 
    6560
    6661    private boolean confirmWayWithNodesOutsideBoundingBox() {
     
    7671    }
    7772
    78 
    7973    private void alertSelectAtLeastOneWay() {
    8074        HelpAwareOptionPane.showOptionDialog(Main.parent, tr("Please select at least one way to simplify."), tr("Warning"), JOptionPane.WARNING_MESSAGE, null);
    8175    }
    82 
    8376
    8477    private boolean confirmSimplifyManyWays(final int numWays) {
     
    9083        return ret == 0;
    9184    }
    92 
    9385
    9486    @Override
     
    190182    }
    191183
    192 
    193184    // average nearby nodes
    194185    private Collection<Command> averageNearbyNodes(final Collection<Way> ways, final Collection<Node> nodesAlreadyDeleted) {
     
    250241                    }
    251242
    252                     final double dist = coordMap.get(n1).greatCircleDistance(coordMap.get(n2));
    253                     if (dist < minDist && dist < mergeThreshold) {
    254                         minDist = dist;
    255                         node1 = n1;
    256                         node2 = n2;
     243                    final LatLon a = coordMap.get(n1);
     244                    final LatLon b = coordMap.get(n2);
     245                   
     246                    if (a != null && b != null) {
     247                        final double dist = a.greatCircleDistance(b);
     248                        if (dist < minDist && dist < mergeThreshold) {
     249                            minDist = dist;
     250                            node1 = n1;
     251                            node2 = n2;
     252                        }
    257253                    }
    258254                }
     
    269265            }
    270266        }
    271 
    272267
    273268        final Collection<Command> commands = new ArrayList<Command>();
     
    311306    }
    312307
    313 
    314308    private void addNodesToDelete(final Collection<Node> nodesToDelete, final Way w) {
    315309        final double angleThreshold = Main.pref.getDouble(SimplifyAreaPreferenceSetting.ANGLE_THRESHOLD, 10);
     
    408402    }
    409403
    410 
    411404    public static double computeConvectAngle(final LatLon coord1, final LatLon coord2, final LatLon coord3) {
    412405        final double angle =  Math.abs(heading(coord2, coord3) - heading(coord1, coord2));
    413406        return Math.toDegrees(angle < Math.PI ? angle : 2 * Math.PI - angle);
    414407    }
    415 
    416408
    417409    public static double computeArea(final LatLon coord1, final LatLon coord2, final LatLon coord3) {
     
    426418    }
    427419
    428 
    429420    public static double R = 6378135;
    430421
     
    432423        return R * Math.asin(sin(l1.greatCircleDistance(l2) / R) * sin(heading(l1, l2) - heading(l1, l3)));
    433424    }
    434 
    435425
    436426    public static double heading(final LatLon a, final LatLon b) {
     
    445435    }
    446436
    447 
    448437    @Override
    449438    protected void updateEnabledState() {
     
    455444    }
    456445
    457 
    458446    @Override
    459447    protected void updateEnabledState(final Collection<? extends OsmPrimitive> selection) {
    460448        setEnabled(selection != null && !selection.isEmpty());
    461449    }
    462 
    463450}
Note: See TracChangeset for help on using the changeset viewer.