Menu

#7 Prevent NPE in LineDissolver on zero-length edge

Unstable (example)
open
nobody
None
5
2015-09-01
2015-09-01
No

When adding a line with a zero-length first edge the LineDissolver throws a NullPointerException at line 111.

This simple patch prevents the NPE:

private void add(LineString lineString) {
if (factory == null) {
this.factory = lineString.getFactory();
}
CoordinateSequence seq = lineString.getCoordinateSequence();
boolean first = true;
for (int i = 1; i < seq.size(); i++) {
DissolveHalfEdge e = (DissolveHalfEdge) graph.addEdge(seq.getCoordinate(i-1), seq.getCoordinate(i));
/*
* Record source initial segments, so that they can be reflected in output when needed
* (i.e. during formation of isolated rings)
/
if (e != null && first) {
e.setStart();
first = false;
}
}
}

Discussion


Log in to post a comment.