Class LocateFailureException

 1 /*
 2  * Copyright (c) 2016 Vivid Solutions.
 3  *
 4  * All rights reserved. This program and the accompanying materials
 5  * are made available under the terms of the Eclipse Public License 2.0
 6  * and Eclipse Distribution License v. 1.0 which accompanies this distribution.
 7  * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v20.html
 8  * and the Eclipse Distribution License is available at
 9  *
10  * http://www.eclipse.org/org/documents/edl-v10.php.
11  */
12 package org.locationtech.jts.triangulate.quadedge;
13  
14 import org.locationtech.jts.geom.LineSegment;
15  
16 public class LocateFailureException 
17     extends RuntimeException 
18 {
19     private static String msgWithSpatial(String msg, LineSegment seg) {
20         if (seg != null)
21             return msg + " [ " + seg + " ]";
22         return msg;
23     }
24  
25     private LineSegment seg = null;
26  
27     public LocateFailureException(String msg) {
28         super(msg);
29     }
30  
31     public LocateFailureException(String msg, LineSegment seg) {
32         super(msgWithSpatial(msg, seg));
33         this.seg = new LineSegment(seg);
34     }
35  
36     public LocateFailureException(LineSegment seg) {
37         super(
38                 "Locate failed to converge (at edge: "
39                         + seg
40                         + ").  Possible causes include invalid Subdivision topology or very close sites");
41         this.seg = new LineSegment(seg);
42     }
43  
44     public LineSegment getSegment() {
45         return seg;
46     }
47  
48 }
49