| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
package org.locationtech.jts.triangulate; |
| 14 |
|
| 15 |
import org.locationtech.jts.geom.Coordinate; |
| 16 |
import org.locationtech.jts.io.WKTWriter; |
| 17 |
|
| 18 |
/** |
| 19 |
* Indicates a failure during constraint enforcement. |
| 20 |
* |
| 21 |
* @author Martin Davis |
| 22 |
* @version 1.0 |
| 23 |
*/ |
| 24 |
public class ConstraintEnforcementException extends RuntimeException { |
| 25 |
|
| 26 |
private static final long serialVersionUID = 386496846550080140L; |
| 27 |
|
| 28 |
private static String msgWithCoord(String msg, Coordinate pt) { |
| 29 |
if (pt != null) |
| 30 |
return msg + " [ " + WKTWriter.toPoint(pt) + " ]"; |
| 31 |
return msg; |
| 32 |
} |
| 33 |
|
| 34 |
private Coordinate pt = null; |
| 35 |
|
| 36 |
/** |
| 37 |
* Creates a new instance with a given message. |
| 38 |
* |
| 39 |
* @param msg a string |
| 40 |
*/ |
| 41 |
public ConstraintEnforcementException(String msg) { |
| 42 |
super(msg); |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* Creates a new instance with a given message and approximate location. |
| 47 |
* |
| 48 |
* @param msg a string |
| 49 |
* @param pt the location of the error |
| 50 |
*/ |
| 51 |
public ConstraintEnforcementException(String msg, Coordinate pt) { |
| 52 |
super(msgWithCoord(msg, pt)); |
| 53 |
this.pt = new Coordinate(pt); |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* Gets the approximate location of this error. |
| 58 |
* |
| 59 |
* @return a location |
| 60 |
*/ |
| 61 |
public Coordinate getCoordinate() { |
| 62 |
return pt; |
| 63 |
} |
| 64 |
} |
| 65 |
|