~ubuntu-branches/ubuntu/natty/jts/natty

« back to all changes in this revision

Viewing changes to src/com/vividsolutions/jts/operation/valid/TopologyValidationError.java

  • Committer: Bazaar Package Importer
  • Author(s): Wolfgang Baer
  • Date: 2005-08-07 14:12:35 UTC
  • Revision ID: james.westby@ubuntu.com-20050807141235-7hy3ll3xpq79djcb
Tags: upstream-1.6
ImportĀ upstreamĀ versionĀ 1.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
 
 
3
/*
 
4
 * The JTS Topology Suite is a collection of Java classes that
 
5
 * implement the fundamental operations required to validate a given
 
6
 * geo-spatial data set to a known topological specification.
 
7
 *
 
8
 * Copyright (C) 2001 Vivid Solutions
 
9
 *
 
10
 * This library is free software; you can redistribute it and/or
 
11
 * modify it under the terms of the GNU Lesser General Public
 
12
 * License as published by the Free Software Foundation; either
 
13
 * version 2.1 of the License, or (at your option) any later version.
 
14
 *
 
15
 * This library is distributed in the hope that it will be useful,
 
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
18
 * Lesser General Public License for more details.
 
19
 *
 
20
 * You should have received a copy of the GNU Lesser General Public
 
21
 * License along with this library; if not, write to the Free Software
 
22
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
23
 *
 
24
 * For more information, contact:
 
25
 *
 
26
 *     Vivid Solutions
 
27
 *     Suite #1A
 
28
 *     2328 Government Street
 
29
 *     Victoria BC  V8T 5G5
 
30
 *     Canada
 
31
 *
 
32
 *     (250)385-6040
 
33
 *     www.vividsolutions.com
 
34
 */
 
35
package com.vividsolutions.jts.operation.valid;
 
36
 
 
37
import com.vividsolutions.jts.geom.Coordinate;
 
38
 
 
39
/**
 
40
 * Contains information about the nature and location of a {@link Geometry}
 
41
 * validation error
 
42
 *
 
43
 * @version 1.6
 
44
 */
 
45
public class TopologyValidationError {
 
46
 
 
47
  public static final int ERROR                   = 0;
 
48
  public static final int REPEATED_POINT          = 1;
 
49
  public static final int HOLE_OUTSIDE_SHELL      = 2;
 
50
  public static final int NESTED_HOLES            = 3;
 
51
  public static final int DISCONNECTED_INTERIOR   = 4;
 
52
  public static final int SELF_INTERSECTION       = 5;
 
53
  public static final int RING_SELF_INTERSECTION  = 6;
 
54
  public static final int NESTED_SHELLS           = 7;
 
55
  public static final int DUPLICATE_RINGS         = 8;
 
56
  public static final int TOO_FEW_POINTS          = 9;
 
57
  public static final int INVALID_COORDINATE      = 10;
 
58
 
 
59
  // these messages must synch up with the indexes above
 
60
  private static String[] errMsg = {
 
61
    "Topology Validation Error",
 
62
    "Repeated Point",
 
63
    "Hole lies outside shell",
 
64
    "Holes are nested",
 
65
    "Interior is disconnected",
 
66
    "Self-intersection",
 
67
    "Ring Self-intersection",
 
68
    "Nested shells",
 
69
    "Duplicate Rings",
 
70
    "Too few points in geometry component",
 
71
    "Invalid Coordinate"
 
72
  };
 
73
 
 
74
 
 
75
  private int errorType;
 
76
  private Coordinate pt;
 
77
 
 
78
  public TopologyValidationError(int errorType, Coordinate pt)
 
79
  {
 
80
    this.errorType = errorType;
 
81
    this.pt = (Coordinate) pt.clone();
 
82
  }
 
83
  public TopologyValidationError(int errorType)
 
84
  {
 
85
    this(errorType, null);
 
86
  }
 
87
 
 
88
  public Coordinate getCoordinate() { return pt; }
 
89
 
 
90
  public int getErrorType() { return errorType; }
 
91
 
 
92
  public String getMessage() { return errMsg[errorType]; }
 
93
 
 
94
  public String toString()
 
95
  {
 
96
    return getMessage() + " at or near point " + pt;
 
97
  }
 
98
}