source: osm/applications/editors/josm/plugins/opendata/includes/com/vividsolutions/jts/geom/Dimension.java@ 28000

Last change on this file since 28000 was 28000, checked in by donvip, 12 years ago

Import new "opendata" JOSM plugin

File size: 4.0 KB
Line 
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 */
35package com.vividsolutions.jts.geom;
36
37/**
38 * Provides constants representing the dimensions of a point, a curve and a surface.
39 * Also provides constants representing the dimensions of the empty geometry and
40 * non-empty geometries, and the wildcard constant {@link #DONTCARE} meaning "any dimension".
41 * These constants are used as the entries in {@link IntersectionMatrix}s.
42 *
43 * @version 1.7
44 */
45public class Dimension {
46
47 /**
48 * Dimension value of a point (0).
49 */
50 public final static int P = 0;
51
52 /**
53 * Dimension value of a curve (1).
54 */
55 public final static int L = 1;
56
57 /**
58 * Dimension value of a surface (2).
59 */
60 public final static int A = 2;
61
62 /**
63 * Dimension value of the empty geometry (-1).
64 */
65 public final static int FALSE = -1;
66
67 /**
68 * Dimension value of non-empty geometries (= {P, L, A}).
69 */
70 public final static int TRUE = -2;
71
72 /**
73 * Dimension value for any dimension (= {FALSE, TRUE}).
74 */
75 public final static int DONTCARE = -3;
76
77 /**
78 * Converts the dimension value to a dimension symbol, for example, <code>TRUE => 'T'</code>
79 * .
80 *
81 *@param dimensionValue a number that can be stored in the <code>IntersectionMatrix</code>
82 * . Possible values are <code>{TRUE, FALSE, DONTCARE, 0, 1, 2}</code>.
83 *@return a character for use in the string representation of
84 * an <code>IntersectionMatrix</code>. Possible values are <code>{T, F, * , 0, 1, 2}</code>
85 * .
86 */
87 public static char toDimensionSymbol(int dimensionValue) {
88 switch (dimensionValue) {
89 case FALSE:
90 return 'F';
91 case TRUE:
92 return 'T';
93 case DONTCARE:
94 return '*';
95 case P:
96 return '0';
97 case L:
98 return '1';
99 case A:
100 return '2';
101 }
102 throw new IllegalArgumentException("Unknown dimension value: " + dimensionValue);
103 }
104
105 /**
106 * Converts the dimension symbol to a dimension value, for example, <code>'*' => DONTCARE</code>
107 * .
108 *
109 *@param dimensionSymbol a character for use in the string representation of
110 * an <code>IntersectionMatrix</code>. Possible values are <code>{T, F, * , 0, 1, 2}</code>
111 * .
112 *@return a number that can be stored in the <code>IntersectionMatrix</code>
113 * . Possible values are <code>{TRUE, FALSE, DONTCARE, 0, 1, 2}</code>.
114 */
115 public static int toDimensionValue(char dimensionSymbol) {
116 switch (Character.toUpperCase(dimensionSymbol)) {
117 case 'F':
118 return FALSE;
119 case 'T':
120 return TRUE;
121 case '*':
122 return DONTCARE;
123 case '0':
124 return P;
125 case '1':
126 return L;
127 case '2':
128 return A;
129 }
130 throw new IllegalArgumentException("Unknown dimension symbol: " + dimensionSymbol);
131 }
132}
133
134
Note: See TracBrowser for help on using the repository browser.