9 |
9 |
import org.gvsig.fmap.geom.Geometry;
|
10 |
10 |
import org.gvsig.fmap.geom.GeometryLocator;
|
11 |
11 |
import org.gvsig.fmap.geom.GeometryManager;
|
|
12 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
|
|
13 |
import org.gvsig.fmap.geom.Geometry.TYPES;
|
|
14 |
import org.gvsig.fmap.geom.aggregate.MultiPoint;
|
12 |
15 |
import org.gvsig.fmap.geom.primitive.GeneralPathX;
|
|
16 |
import org.gvsig.fmap.geom.primitive.Point;
|
|
17 |
import org.gvsig.fmap.geom.primitive.Surface;
|
13 |
18 |
|
14 |
19 |
import com.vividsolutions.jts.geom.Coordinate;
|
15 |
20 |
import com.vividsolutions.jts.io.ParseException;
|
... | ... | |
48 |
53 |
public class WKTParser {
|
49 |
54 |
|
50 |
55 |
private GeometryManager manager = GeometryLocator.getGeometryManager();
|
51 |
|
/**
|
52 |
|
* Creates a WKTReader that creates objects using a basic GeometryFactory.
|
53 |
|
*/
|
54 |
|
public WKTParser() {
|
55 |
|
}
|
|
56 |
/**
|
|
57 |
* Creates a WKTReader that creates objects using a basic GeometryFactory.
|
|
58 |
*/
|
|
59 |
public WKTParser() {
|
|
60 |
}
|
56 |
61 |
|
57 |
|
|
58 |
62 |
|
|
63 |
|
59 |
64 |
/**
|
60 |
|
* Converts a Well-known Text representation to a <code>Geometry</code>.
|
61 |
|
*
|
62 |
|
* @param wellKnownText
|
63 |
|
* one or more <Geometry Tagged Text>strings (see the OpenGIS
|
64 |
|
* Simple Features Specification) separated by whitespace
|
65 |
|
* @return a <code>Geometry</code> specified by <code>wellKnownText</code>
|
66 |
|
* @throws ParseException
|
67 |
|
* if a parsing problem occurs
|
|
65 |
* Converts a Well-known Text representation to a <code>Geometry</code>.
|
|
66 |
*
|
|
67 |
* @param wellKnownText
|
|
68 |
* one or more <Geometry Tagged Text>strings (see the OpenGIS
|
|
69 |
* Simple Features Specification) separated by whitespace
|
|
70 |
* @return a <code>Geometry</code> specified by <code>wellKnownText</code>
|
|
71 |
* @throws ParseException
|
|
72 |
* if a parsing problem occurs
|
68 |
73 |
*/
|
69 |
|
public Geometry read(String wellKnownText) throws ParseException {
|
70 |
|
StringReader reader = new StringReader(wellKnownText);
|
71 |
|
try {
|
72 |
|
return read(reader);
|
73 |
|
}
|
74 |
|
finally {
|
75 |
|
reader.close();
|
76 |
|
}
|
77 |
|
}
|
|
74 |
public Geometry read(String wellKnownText) throws ParseException {
|
|
75 |
StringReader reader = new StringReader(wellKnownText);
|
|
76 |
try {
|
|
77 |
return read(reader);
|
|
78 |
}
|
|
79 |
finally {
|
|
80 |
reader.close();
|
|
81 |
}
|
|
82 |
}
|
78 |
83 |
|
79 |
|
/**
|
80 |
|
* Converts a Well-known Text representation to a <code>Geometry</code>.
|
81 |
|
*
|
82 |
|
*@param reader a Reader which will return a <Geometry Tagged Text>
|
83 |
|
* string (see the OpenGIS Simple Features Specification)
|
84 |
|
*@return a <code>Geometry</code> read from <code>reader</code>
|
85 |
|
*@throws ParseException if a parsing problem occurs
|
86 |
|
*/
|
87 |
|
public Geometry read(Reader reader) throws ParseException {
|
88 |
|
StreamTokenizer tokenizer = new StreamTokenizer(reader);
|
89 |
|
try {
|
90 |
|
return readGeometryTaggedText(tokenizer);
|
91 |
|
}
|
92 |
|
catch (IOException e) {
|
93 |
|
throw new ParseException(e.toString());
|
94 |
|
}
|
95 |
|
}
|
|
84 |
/**
|
|
85 |
* Converts a Well-known Text representation to a <code>Geometry</code>.
|
|
86 |
*
|
|
87 |
*@param reader a Reader which will return a <Geometry Tagged Text>
|
|
88 |
* string (see the OpenGIS Simple Features Specification)
|
|
89 |
*@return a <code>Geometry</code> read from <code>reader</code>
|
|
90 |
*@throws ParseException if a parsing problem occurs
|
|
91 |
*/
|
|
92 |
public Geometry read(Reader reader) throws ParseException {
|
|
93 |
StreamTokenizer tokenizer = new StreamTokenizer(reader);
|
|
94 |
try {
|
|
95 |
return readGeometryTaggedText(tokenizer);
|
|
96 |
}
|
|
97 |
catch (IOException e) {
|
|
98 |
throw new ParseException(e.toString());
|
|
99 |
} catch (InstantiationException e) {
|
|
100 |
throw new ParseException(e.toString());
|
|
101 |
} catch (IllegalAccessException e) {
|
|
102 |
throw new ParseException(e.toString());
|
|
103 |
}
|
|
104 |
}
|
96 |
105 |
|
97 |
|
/**
|
98 |
|
* Returns the next array of <code>Coordinate</code>s in the stream.
|
99 |
|
*
|
100 |
|
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
101 |
|
* format. The next element returned by the stream should be "(" (the
|
102 |
|
* beginning of "(x1 y1, x2 y2, ..., xn yn)") or "EMPTY".
|
103 |
|
*@return the next array of <code>Coordinate</code>s in the
|
104 |
|
* stream, or an empty array if "EMPTY" is the next element returned by
|
105 |
|
* the stream.
|
106 |
|
*@throws IOException if an I/O error occurs
|
107 |
|
*@throws ParseException if an unexpected token was encountered
|
108 |
|
*/
|
109 |
|
private Coordinate[] getCoordinates(StreamTokenizer tokenizer)
|
110 |
|
throws IOException, ParseException
|
111 |
|
{
|
112 |
|
String nextToken = getNextEmptyOrOpener(tokenizer);
|
113 |
|
if (nextToken.equals("EMPTY")) {
|
114 |
|
return new Coordinate[]{};
|
115 |
|
}
|
116 |
|
ArrayList coordinates = new ArrayList();
|
117 |
|
coordinates.add(getPreciseCoordinate(tokenizer));
|
118 |
|
nextToken = getNextCloserOrComma(tokenizer);
|
119 |
|
while (nextToken.equals(",")) {
|
120 |
|
coordinates.add(getPreciseCoordinate(tokenizer));
|
121 |
|
nextToken = getNextCloserOrComma(tokenizer);
|
122 |
|
}
|
123 |
|
Coordinate[] array = new Coordinate[coordinates.size()];
|
124 |
|
return (Coordinate[]) coordinates.toArray(array);
|
125 |
|
}
|
|
106 |
/**
|
|
107 |
* Returns the next array of <code>Coordinate</code>s in the stream.
|
|
108 |
*
|
|
109 |
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
|
110 |
* format. The next element returned by the stream should be "(" (the
|
|
111 |
* beginning of "(x1 y1, x2 y2, ..., xn yn)") or "EMPTY".
|
|
112 |
*@return the next array of <code>Coordinate</code>s in the
|
|
113 |
* stream, or an empty array if "EMPTY" is the next element returned by
|
|
114 |
* the stream.
|
|
115 |
*@throws IOException if an I/O error occurs
|
|
116 |
*@throws ParseException if an unexpected token was encountered
|
|
117 |
*/
|
|
118 |
private Coordinate[] getCoordinates(StreamTokenizer tokenizer)
|
|
119 |
throws IOException, ParseException
|
|
120 |
{
|
|
121 |
String nextToken = getNextEmptyOrOpener(tokenizer);
|
|
122 |
if (nextToken.equals("EMPTY")) {
|
|
123 |
return new Coordinate[]{};
|
|
124 |
}
|
|
125 |
ArrayList coordinates = new ArrayList();
|
|
126 |
coordinates.add(getPreciseCoordinate(tokenizer));
|
|
127 |
nextToken = getNextCloserOrComma(tokenizer);
|
|
128 |
while (nextToken.equals(",")) {
|
|
129 |
coordinates.add(getPreciseCoordinate(tokenizer));
|
|
130 |
nextToken = getNextCloserOrComma(tokenizer);
|
|
131 |
}
|
|
132 |
Coordinate[] array = new Coordinate[coordinates.size()];
|
|
133 |
return (Coordinate[]) coordinates.toArray(array);
|
|
134 |
}
|
126 |
135 |
|
127 |
|
private Coordinate getPreciseCoordinate(StreamTokenizer tokenizer)
|
128 |
|
throws IOException, ParseException
|
129 |
|
{
|
130 |
|
Coordinate coord = new Coordinate();
|
131 |
|
coord.x = getNextNumber(tokenizer);
|
132 |
|
coord.y = getNextNumber(tokenizer);
|
133 |
|
if (isNumberNext(tokenizer)) {
|
134 |
|
coord.z = getNextNumber(tokenizer);
|
135 |
|
}
|
136 |
|
return coord;
|
137 |
|
}
|
138 |
|
private boolean isNumberNext(StreamTokenizer tokenizer) throws IOException {
|
139 |
|
try {
|
140 |
|
return tokenizer.nextToken() == StreamTokenizer.TT_NUMBER;
|
141 |
|
}
|
142 |
|
finally {
|
143 |
|
tokenizer.pushBack();
|
144 |
|
}
|
145 |
|
}
|
146 |
|
/**
|
147 |
|
* Returns the next number in the stream.
|
148 |
|
*
|
149 |
|
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
150 |
|
* format. The next token must be a number.
|
151 |
|
*@return the next number in the stream
|
152 |
|
*@throws ParseException if the next token is not a number
|
153 |
|
*@throws IOException if an I/O error occurs
|
154 |
|
*/
|
155 |
|
private double getNextNumber(StreamTokenizer tokenizer) throws IOException,
|
156 |
|
ParseException {
|
157 |
|
int type = tokenizer.nextToken();
|
158 |
|
switch (type) {
|
159 |
|
case StreamTokenizer.TT_EOF:
|
160 |
|
throw new ParseException("Expected number but encountered end of stream");
|
161 |
|
case StreamTokenizer.TT_EOL:
|
162 |
|
throw new ParseException("Expected number but encountered end of line");
|
163 |
|
case StreamTokenizer.TT_NUMBER:
|
164 |
|
return tokenizer.nval;
|
165 |
|
case StreamTokenizer.TT_WORD:
|
166 |
|
throw new ParseException("Expected number but encountered word: " +
|
167 |
|
tokenizer.sval);
|
168 |
|
case '(':
|
169 |
|
throw new ParseException("Expected number but encountered '('");
|
170 |
|
case ')':
|
171 |
|
throw new ParseException("Expected number but encountered ')'");
|
172 |
|
case ',':
|
173 |
|
throw new ParseException("Expected number but encountered ','");
|
174 |
|
}
|
175 |
|
return 0;
|
176 |
|
}
|
|
136 |
private Coordinate getPreciseCoordinate(StreamTokenizer tokenizer)
|
|
137 |
throws IOException, ParseException
|
|
138 |
{
|
|
139 |
Coordinate coord = new Coordinate();
|
|
140 |
coord.x = getNextNumber(tokenizer);
|
|
141 |
coord.y = getNextNumber(tokenizer);
|
|
142 |
if (isNumberNext(tokenizer)) {
|
|
143 |
coord.z = getNextNumber(tokenizer);
|
|
144 |
}
|
|
145 |
return coord;
|
|
146 |
}
|
|
147 |
private boolean isNumberNext(StreamTokenizer tokenizer) throws IOException {
|
|
148 |
try {
|
|
149 |
return tokenizer.nextToken() == StreamTokenizer.TT_NUMBER;
|
|
150 |
}
|
|
151 |
finally {
|
|
152 |
tokenizer.pushBack();
|
|
153 |
}
|
|
154 |
}
|
|
155 |
/**
|
|
156 |
* Returns the next number in the stream.
|
|
157 |
*
|
|
158 |
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
|
159 |
* format. The next token must be a number.
|
|
160 |
*@return the next number in the stream
|
|
161 |
*@throws ParseException if the next token is not a number
|
|
162 |
*@throws IOException if an I/O error occurs
|
|
163 |
*/
|
|
164 |
private double getNextNumber(StreamTokenizer tokenizer) throws IOException,
|
|
165 |
ParseException {
|
|
166 |
int type = tokenizer.nextToken();
|
|
167 |
switch (type) {
|
|
168 |
case StreamTokenizer.TT_EOF:
|
|
169 |
throw new ParseException("Expected number but encountered end of stream");
|
|
170 |
case StreamTokenizer.TT_EOL:
|
|
171 |
throw new ParseException("Expected number but encountered end of line");
|
|
172 |
case StreamTokenizer.TT_NUMBER:
|
|
173 |
return tokenizer.nval;
|
|
174 |
case StreamTokenizer.TT_WORD:
|
|
175 |
throw new ParseException("Expected number but encountered word: " +
|
|
176 |
tokenizer.sval);
|
|
177 |
case '(':
|
|
178 |
throw new ParseException("Expected number but encountered '('");
|
|
179 |
case ')':
|
|
180 |
throw new ParseException("Expected number but encountered ')'");
|
|
181 |
case ',':
|
|
182 |
throw new ParseException("Expected number but encountered ','");
|
|
183 |
}
|
|
184 |
return 0;
|
|
185 |
}
|
177 |
186 |
|
178 |
|
/**
|
179 |
|
* Returns the next "EMPTY" or "(" in the stream as uppercase text.
|
180 |
|
*
|
181 |
|
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
182 |
|
* format. The next token must be "EMPTY" or "(".
|
183 |
|
*@return the next "EMPTY" or "(" in the stream as uppercase
|
184 |
|
* text.
|
185 |
|
*@throws ParseException if the next token is not "EMPTY" or "("
|
186 |
|
*@throws IOException if an I/O error occurs
|
187 |
|
*/
|
188 |
|
private String getNextEmptyOrOpener(StreamTokenizer tokenizer) throws IOException, ParseException {
|
189 |
|
String nextWord = getNextWord(tokenizer);
|
190 |
|
if (nextWord.equals("EMPTY") || nextWord.equals("(")) {
|
191 |
|
return nextWord;
|
192 |
|
}
|
193 |
|
throw new ParseException("Expected 'EMPTY' or '(' but encountered '" +
|
194 |
|
nextWord + "'");
|
195 |
|
}
|
|
187 |
/**
|
|
188 |
* Returns the next "EMPTY" or "(" in the stream as uppercase text.
|
|
189 |
*
|
|
190 |
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
|
191 |
* format. The next token must be "EMPTY" or "(".
|
|
192 |
*@return the next "EMPTY" or "(" in the stream as uppercase
|
|
193 |
* text.
|
|
194 |
*@throws ParseException if the next token is not "EMPTY" or "("
|
|
195 |
*@throws IOException if an I/O error occurs
|
|
196 |
*/
|
|
197 |
private String getNextEmptyOrOpener(StreamTokenizer tokenizer) throws IOException, ParseException {
|
|
198 |
String nextWord = getNextWord(tokenizer);
|
|
199 |
if (nextWord.equals("EMPTY") || nextWord.equals("(")) {
|
|
200 |
return nextWord;
|
|
201 |
}
|
|
202 |
throw new ParseException("Expected 'EMPTY' or '(' but encountered '" +
|
|
203 |
nextWord + "'");
|
|
204 |
}
|
196 |
205 |
|
197 |
|
/**
|
198 |
|
* Returns the next ")" or "," in the stream.
|
199 |
|
*
|
200 |
|
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
201 |
|
* format. The next token must be ")" or ",".
|
202 |
|
*@return the next ")" or "," in the stream
|
203 |
|
*@throws ParseException if the next token is not ")" or ","
|
204 |
|
*@throws IOException if an I/O error occurs
|
205 |
|
*/
|
206 |
|
private String getNextCloserOrComma(StreamTokenizer tokenizer) throws IOException, ParseException {
|
207 |
|
String nextWord = getNextWord(tokenizer);
|
208 |
|
if (nextWord.equals(",") || nextWord.equals(")")) {
|
209 |
|
return nextWord;
|
210 |
|
}
|
211 |
|
throw new ParseException("Expected ')' or ',' but encountered '" + nextWord
|
212 |
|
+ "'");
|
213 |
|
}
|
|
206 |
/**
|
|
207 |
* Returns the next ")" or "," in the stream.
|
|
208 |
*
|
|
209 |
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
|
210 |
* format. The next token must be ")" or ",".
|
|
211 |
*@return the next ")" or "," in the stream
|
|
212 |
*@throws ParseException if the next token is not ")" or ","
|
|
213 |
*@throws IOException if an I/O error occurs
|
|
214 |
*/
|
|
215 |
private String getNextCloserOrComma(StreamTokenizer tokenizer) throws IOException, ParseException {
|
|
216 |
String nextWord = getNextWord(tokenizer);
|
|
217 |
if (nextWord.equals(",") || nextWord.equals(")")) {
|
|
218 |
return nextWord;
|
|
219 |
}
|
|
220 |
throw new ParseException("Expected ')' or ',' but encountered '" + nextWord
|
|
221 |
+ "'");
|
|
222 |
}
|
214 |
223 |
|
215 |
|
/**
|
216 |
|
* Returns the next ")" in the stream.
|
217 |
|
*
|
218 |
|
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
219 |
|
* format. The next token must be ")".
|
220 |
|
*@return the next ")" in the stream
|
221 |
|
*@throws ParseException if the next token is not ")"
|
222 |
|
*@throws IOException if an I/O error occurs
|
223 |
|
*/
|
224 |
|
private String getNextCloser(StreamTokenizer tokenizer) throws IOException, ParseException {
|
225 |
|
String nextWord = getNextWord(tokenizer);
|
226 |
|
if (nextWord.equals(")")) {
|
227 |
|
return nextWord;
|
228 |
|
}
|
229 |
|
throw new ParseException("Expected ')' but encountered '" + nextWord + "'");
|
230 |
|
}
|
|
224 |
/**
|
|
225 |
* Returns the next ")" in the stream.
|
|
226 |
*
|
|
227 |
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
|
228 |
* format. The next token must be ")".
|
|
229 |
*@return the next ")" in the stream
|
|
230 |
*@throws ParseException if the next token is not ")"
|
|
231 |
*@throws IOException if an I/O error occurs
|
|
232 |
*/
|
|
233 |
private String getNextCloser(StreamTokenizer tokenizer) throws IOException, ParseException {
|
|
234 |
String nextWord = getNextWord(tokenizer);
|
|
235 |
if (nextWord.equals(")")) {
|
|
236 |
return nextWord;
|
|
237 |
}
|
|
238 |
throw new ParseException("Expected ')' but encountered '" + nextWord + "'");
|
|
239 |
}
|
231 |
240 |
|
232 |
|
/**
|
233 |
|
* Returns the next word in the stream as uppercase text.
|
234 |
|
*
|
235 |
|
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
236 |
|
* format. The next token must be a word.
|
237 |
|
*@return the next word in the stream as uppercase text
|
238 |
|
*@throws ParseException if the next token is not a word
|
239 |
|
*@throws IOException if an I/O error occurs
|
240 |
|
*/
|
241 |
|
private String getNextWord(StreamTokenizer tokenizer) throws IOException, ParseException {
|
242 |
|
int type = tokenizer.nextToken();
|
243 |
|
switch (type) {
|
244 |
|
case StreamTokenizer.TT_EOF:
|
245 |
|
throw new ParseException("Expected word but encountered end of stream");
|
246 |
|
case StreamTokenizer.TT_EOL:
|
247 |
|
throw new ParseException("Expected word but encountered end of line");
|
248 |
|
case StreamTokenizer.TT_NUMBER:
|
249 |
|
throw new ParseException("Expected word but encountered number: " +
|
250 |
|
tokenizer.nval);
|
251 |
|
case StreamTokenizer.TT_WORD:
|
252 |
|
return tokenizer.sval.toUpperCase();
|
253 |
|
case '(':
|
254 |
|
return "(";
|
255 |
|
case ')':
|
256 |
|
return ")";
|
257 |
|
case ',':
|
258 |
|
return ",";
|
259 |
|
}
|
260 |
|
// Assert.shouldNeverReachHere("Encountered unexpected StreamTokenizer type: " + type);
|
261 |
|
return null;
|
262 |
|
}
|
|
241 |
/**
|
|
242 |
* Returns the next word in the stream as uppercase text.
|
|
243 |
*
|
|
244 |
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
|
245 |
* format. The next token must be a word.
|
|
246 |
*@return the next word in the stream as uppercase text
|
|
247 |
*@throws ParseException if the next token is not a word
|
|
248 |
*@throws IOException if an I/O error occurs
|
|
249 |
*/
|
|
250 |
private String getNextWord(StreamTokenizer tokenizer) throws IOException, ParseException {
|
|
251 |
int type = tokenizer.nextToken();
|
|
252 |
switch (type) {
|
|
253 |
case StreamTokenizer.TT_EOF:
|
|
254 |
throw new ParseException("Expected word but encountered end of stream");
|
|
255 |
case StreamTokenizer.TT_EOL:
|
|
256 |
throw new ParseException("Expected word but encountered end of line");
|
|
257 |
case StreamTokenizer.TT_NUMBER:
|
|
258 |
throw new ParseException("Expected word but encountered number: " +
|
|
259 |
tokenizer.nval);
|
|
260 |
case StreamTokenizer.TT_WORD:
|
|
261 |
return tokenizer.sval.toUpperCase();
|
|
262 |
case '(':
|
|
263 |
return "(";
|
|
264 |
case ')':
|
|
265 |
return ")";
|
|
266 |
case ',':
|
|
267 |
return ",";
|
|
268 |
}
|
|
269 |
// Assert.shouldNeverReachHere("Encountered unexpected StreamTokenizer type: " + type);
|
|
270 |
return null;
|
|
271 |
}
|
263 |
272 |
|
264 |
|
/**
|
265 |
|
* Creates a <code>Geometry</code> using the next token in the stream.
|
266 |
|
*
|
267 |
|
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
268 |
|
* format. The next tokens must form a <Geometry Tagged Text>.
|
269 |
|
*@return a <code>Geometry</code> specified by the next token
|
270 |
|
* in the stream
|
271 |
|
*@throws ParseException if the coordinates used to create a <code>Polygon</code>
|
272 |
|
* shell and holes do not form closed linestrings, or if an unexpected
|
273 |
|
* token was encountered
|
274 |
|
*@throws IOException if an I/O error occurs
|
275 |
|
*/
|
276 |
|
private Geometry readGeometryTaggedText(StreamTokenizer tokenizer) throws IOException, ParseException {
|
277 |
|
String type = getNextWord(tokenizer);
|
278 |
|
if (type.equals("POINT")) {
|
279 |
|
return readPointText(tokenizer);
|
280 |
|
}
|
281 |
|
else if (type.equals("LINESTRING")) {
|
282 |
|
return readLineStringText(tokenizer);
|
283 |
|
}
|
284 |
|
else if (type.equals("LINEARRING")) {
|
285 |
|
return readLinearRingText(tokenizer);
|
286 |
|
}
|
287 |
|
else if (type.equals("POLYGON")) {
|
288 |
|
return readPolygonText(tokenizer);
|
289 |
|
}
|
290 |
|
else if (type.equals("MULTIPOINT")) {
|
291 |
|
return readMultiPointText(tokenizer);
|
292 |
|
}
|
293 |
|
else if (type.equals("MULTILINESTRING")) {
|
294 |
|
return readMultiLineStringText(tokenizer);
|
295 |
|
}
|
296 |
|
else if (type.equals("MULTIPOLYGON")) {
|
297 |
|
return readMultiPolygonText(tokenizer);
|
298 |
|
}
|
299 |
|
/* else if (type.equals("GEOMETRYCOLLECTION")) {
|
|
273 |
/**
|
|
274 |
* Creates a <code>Geometry</code> using the next token in the stream.
|
|
275 |
*
|
|
276 |
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
|
277 |
* format. The next tokens must form a <Geometry Tagged Text>.
|
|
278 |
*@return a <code>Geometry</code> specified by the next token
|
|
279 |
* in the stream
|
|
280 |
*@throws ParseException if the coordinates used to create a <code>Polygon</code>
|
|
281 |
* shell and holes do not form closed linestrings, or if an unexpected
|
|
282 |
* token was encountered
|
|
283 |
*@throws IOException if an I/O error occurs
|
|
284 |
* @throws IllegalAccessException
|
|
285 |
* @throws InstantiationException
|
|
286 |
*/
|
|
287 |
private Geometry readGeometryTaggedText(StreamTokenizer tokenizer) throws IOException, ParseException, InstantiationException, IllegalAccessException {
|
|
288 |
String type = getNextWord(tokenizer);
|
|
289 |
if (type.equals("POINT")) {
|
|
290 |
return readPointText(tokenizer);
|
|
291 |
}
|
|
292 |
else if (type.equals("LINESTRING")) {
|
|
293 |
return readLineStringText(tokenizer);
|
|
294 |
}
|
|
295 |
else if (type.equals("LINEARRING")) {
|
|
296 |
return readLinearRingText(tokenizer);
|
|
297 |
}
|
|
298 |
else if (type.equals("POLYGON")) {
|
|
299 |
return readPolygonText(tokenizer);
|
|
300 |
}
|
|
301 |
else if (type.equals("MULTIPOINT")) {
|
|
302 |
return readMultiPointText(tokenizer);
|
|
303 |
}
|
|
304 |
else if (type.equals("MULTILINESTRING")) {
|
|
305 |
return readMultiLineStringText(tokenizer);
|
|
306 |
}
|
|
307 |
else if (type.equals("MULTIPOLYGON")) {
|
|
308 |
return readMultiPolygonText(tokenizer);
|
|
309 |
}
|
|
310 |
/* else if (type.equals("GEOMETRYCOLLECTION")) {
|
300 |
311 |
return readGeometryCollectionText(tokenizer);
|
301 |
312 |
} */
|
302 |
|
System.err.println("Unknown type: " + type);
|
303 |
|
throw new ParseException("Unknown type: " + type);
|
304 |
|
}
|
|
313 |
System.err.println("Unknown type: " + type);
|
|
314 |
throw new ParseException("Unknown type: " + type);
|
|
315 |
}
|
305 |
316 |
|
306 |
|
/**
|
307 |
|
* Creates a <code>Point</code> using the next token in the stream.
|
308 |
|
*
|
309 |
|
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
310 |
|
* format. The next tokens must form a <Point Text>.
|
311 |
|
*@return a <code>Point</code> specified by the next token in
|
312 |
|
* the stream
|
313 |
|
*@throws IOException if an I/O error occurs
|
314 |
|
*@throws ParseException if an unexpected token was encountered
|
315 |
|
*/
|
316 |
|
private Geometry readPointText(StreamTokenizer tokenizer) throws IOException, ParseException {
|
317 |
|
String nextToken = getNextEmptyOrOpener(tokenizer);
|
318 |
|
if (nextToken.equals("EMPTY")) {
|
319 |
|
return null;
|
320 |
|
}
|
321 |
|
Coordinate c = getPreciseCoordinate(tokenizer);
|
322 |
|
Geometry point = manager.getGeometryFactory().createPoint2D(c.x, c.y );
|
323 |
|
getNextCloser(tokenizer);
|
324 |
|
|
325 |
|
return point;
|
326 |
|
}
|
|
317 |
/**
|
|
318 |
* Creates a <code>Point</code> using the next token in the stream.
|
|
319 |
*
|
|
320 |
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
|
321 |
* format. The next tokens must form a <Point Text>.
|
|
322 |
*@return a <code>Point</code> specified by the next token in
|
|
323 |
* the stream
|
|
324 |
*@throws IOException if an I/O error occurs
|
|
325 |
*@throws ParseException if an unexpected token was encountered
|
|
326 |
* @throws IllegalAccessException
|
|
327 |
* @throws InstantiationException
|
|
328 |
*/
|
|
329 |
private Geometry readPointText(StreamTokenizer tokenizer) throws IOException, ParseException, InstantiationException, IllegalAccessException {
|
|
330 |
String nextToken = getNextEmptyOrOpener(tokenizer);
|
|
331 |
if (nextToken.equals("EMPTY")) {
|
|
332 |
return null;
|
|
333 |
}
|
|
334 |
Coordinate c = getPreciseCoordinate(tokenizer);
|
|
335 |
Point point = (Point)manager.create(TYPES.POINT, SUBTYPES.GEOM2D);
|
|
336 |
point.setX(c.x);
|
|
337 |
point.setY(c.y);
|
|
338 |
getNextCloser(tokenizer);
|
327 |
339 |
|
328 |
|
/**
|
329 |
|
* Creates a <code>LineString</code> using the next token in the stream.
|
330 |
|
*
|
331 |
|
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
332 |
|
* format. The next tokens must form a <LineString Text>.
|
333 |
|
*@return a <code>LineString</code> specified by the next
|
334 |
|
* token in the stream
|
335 |
|
*@throws IOException if an I/O error occurs
|
336 |
|
*@throws ParseException if an unexpected token was encountered
|
337 |
|
*/
|
338 |
|
private Geometry readLineStringText(StreamTokenizer tokenizer) throws IOException, ParseException {
|
339 |
|
Coordinate[] arrayC = getCoordinates(tokenizer);
|
340 |
|
GeneralPathX gp = new GeneralPathX();
|
341 |
|
gp.moveTo(arrayC[0].x,arrayC[0].y);
|
342 |
|
for (int i=1;i < arrayC.length; i++)
|
343 |
|
{
|
344 |
|
gp.lineTo(arrayC[i].x, arrayC[i].y);
|
345 |
|
}
|
346 |
|
return manager.getGeometryFactory().createPolygon2D(gp);
|
347 |
|
}
|
|
340 |
return point;
|
|
341 |
}
|
348 |
342 |
|
349 |
|
/**
|
350 |
|
* Creates a <code>LinearRing</code> using the next token in the stream.
|
351 |
|
*
|
352 |
|
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
353 |
|
* format. The next tokens must form a <LineString Text>.
|
354 |
|
*@return a <code>LinearRing</code> specified by the next
|
355 |
|
* token in the stream
|
356 |
|
*@throws IOException if an I/O error occurs
|
357 |
|
*@throws ParseException if the coordinates used to create the <code>LinearRing</code>
|
358 |
|
* do not form a closed linestring, or if an unexpected token was
|
359 |
|
* encountered
|
360 |
|
*/
|
361 |
|
private Geometry readLinearRingText(StreamTokenizer tokenizer)
|
362 |
|
throws IOException, ParseException
|
363 |
|
{
|
364 |
|
Coordinate[] arrayC = getCoordinates(tokenizer);
|
365 |
|
GeneralPathX gp = new GeneralPathX();
|
366 |
|
gp.moveTo(arrayC[0].x, arrayC[0].y);
|
367 |
|
for (int i=1;i < arrayC.length; i++)
|
368 |
|
{
|
369 |
|
gp.lineTo(arrayC[i].x, arrayC[i].y);
|
370 |
|
}
|
371 |
|
return manager.getGeometryFactory().createPolygon2D(gp);
|
|
343 |
/**
|
|
344 |
* Creates a <code>LineString</code> using the next token in the stream.
|
|
345 |
*
|
|
346 |
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
|
347 |
* format. The next tokens must form a <LineString Text>.
|
|
348 |
*@return a <code>LineString</code> specified by the next
|
|
349 |
* token in the stream
|
|
350 |
*@throws IOException if an I/O error occurs
|
|
351 |
*@throws ParseException if an unexpected token was encountered
|
|
352 |
* @throws IllegalAccessException
|
|
353 |
* @throws InstantiationException
|
|
354 |
*/
|
|
355 |
private Geometry readLineStringText(StreamTokenizer tokenizer) throws IOException, ParseException, InstantiationException, IllegalAccessException {
|
|
356 |
Coordinate[] arrayC = getCoordinates(tokenizer);
|
|
357 |
GeneralPathX gp = new GeneralPathX();
|
|
358 |
gp.moveTo(arrayC[0].x,arrayC[0].y);
|
|
359 |
for (int i=1;i < arrayC.length; i++)
|
|
360 |
{
|
|
361 |
gp.lineTo(arrayC[i].x, arrayC[i].y);
|
|
362 |
}
|
|
363 |
Surface surface = (Surface)manager.create(TYPES.SURFACE, SUBTYPES.GEOM2D);
|
|
364 |
surface.setGeneralPath(gp);
|
|
365 |
return surface;
|
|
366 |
}
|
372 |
367 |
|
373 |
|
}
|
|
368 |
/**
|
|
369 |
* Creates a <code>LinearRing</code> using the next token in the stream.
|
|
370 |
*
|
|
371 |
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
|
372 |
* format. The next tokens must form a <LineString Text>.
|
|
373 |
*@return a <code>LinearRing</code> specified by the next
|
|
374 |
* token in the stream
|
|
375 |
*@throws IOException if an I/O error occurs
|
|
376 |
*@throws ParseException if the coordinates used to create the <code>LinearRing</code>
|
|
377 |
* do not form a closed linestring, or if an unexpected token was
|
|
378 |
* encountered
|
|
379 |
* @throws IllegalAccessException
|
|
380 |
* @throws InstantiationException
|
|
381 |
*/
|
|
382 |
private Geometry readLinearRingText(StreamTokenizer tokenizer)
|
|
383 |
throws IOException, ParseException, InstantiationException, IllegalAccessException
|
|
384 |
{
|
|
385 |
Coordinate[] arrayC = getCoordinates(tokenizer);
|
|
386 |
GeneralPathX gp = new GeneralPathX();
|
|
387 |
gp.moveTo(arrayC[0].x, arrayC[0].y);
|
|
388 |
for (int i=1;i < arrayC.length; i++)
|
|
389 |
{
|
|
390 |
gp.lineTo(arrayC[i].x, arrayC[i].y);
|
|
391 |
}
|
|
392 |
Surface surface = (Surface)manager.create(TYPES.SURFACE, SUBTYPES.GEOM2D);
|
|
393 |
surface.setGeneralPath(gp);
|
|
394 |
return surface;
|
|
395 |
}
|
374 |
396 |
|
375 |
|
/**
|
376 |
|
* Creates a <code>MultiPoint</code> using the next token in the stream.
|
377 |
|
*
|
378 |
|
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
379 |
|
* format. The next tokens must form a <MultiPoint Text>.
|
380 |
|
*@return a <code>MultiPoint</code> specified by the next
|
381 |
|
* token in the stream
|
382 |
|
*@throws IOException if an I/O error occurs
|
383 |
|
*@throws ParseException if an unexpected token was encountered
|
384 |
|
*/
|
385 |
|
private Geometry readMultiPointText(StreamTokenizer tokenizer) throws IOException, ParseException {
|
386 |
|
Coordinate[] coords = getCoordinates(tokenizer);
|
387 |
|
double[] x = new double[coords.length];
|
388 |
|
double[] y = new double[coords.length];
|
389 |
|
for (int i=0; i < coords.length; i++)
|
390 |
|
{
|
391 |
|
x[i] = coords[i].x;
|
392 |
|
y[i] = coords[i].y;
|
393 |
|
}
|
394 |
|
Geometry multi = manager.getGeometryFactory().createMultipoint2D(x, y);
|
395 |
|
return multi;
|
396 |
|
}
|
|
397 |
/**
|
|
398 |
* Creates a <code>MultiPoint</code> using the next token in the stream.
|
|
399 |
*
|
|
400 |
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
|
401 |
* format. The next tokens must form a <MultiPoint Text>.
|
|
402 |
*@return a <code>MultiPoint</code> specified by the next
|
|
403 |
* token in the stream
|
|
404 |
*@throws IOException if an I/O error occurs
|
|
405 |
*@throws ParseException if an unexpected token was encountered
|
|
406 |
* @throws IllegalAccessException
|
|
407 |
* @throws InstantiationException
|
|
408 |
*/
|
|
409 |
private Geometry readMultiPointText(StreamTokenizer tokenizer) throws IOException, ParseException, InstantiationException, IllegalAccessException {
|
|
410 |
Coordinate[] coords = getCoordinates(tokenizer);
|
|
411 |
MultiPoint multiPoint = (MultiPoint)manager.create(TYPES.MULTIPOINT, SUBTYPES.GEOM2D);
|
|
412 |
for (int i=0; i < coords.length; i++)
|
|
413 |
{
|
|
414 |
Point point = (Point)manager.create(TYPES.POINT, SUBTYPES.GEOM2D);
|
|
415 |
point.setX(coords[i].x);
|
|
416 |
point.setY(coords[i].y);
|
|
417 |
multiPoint.addPoint(point);
|
|
418 |
}
|
397 |
419 |
|
|
420 |
return multiPoint;
|
|
421 |
}
|
398 |
422 |
|
399 |
|
/**
|
400 |
|
* Creates a <code>Polygon</code> using the next token in the stream.
|
401 |
|
*
|
402 |
|
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
403 |
|
* format. The next tokens must form a <Polygon Text>.
|
404 |
|
*@return a <code>Polygon</code> specified by the next token
|
405 |
|
* in the stream
|
406 |
|
*@throws ParseException if the coordinates used to create the <code>Polygon</code>
|
407 |
|
* shell and holes do not form closed linestrings, or if an unexpected
|
408 |
|
* token was encountered.
|
409 |
|
*@throws IOException if an I/O error occurs
|
410 |
|
*/
|
411 |
|
private Geometry readPolygonText(StreamTokenizer tokenizer) throws IOException, ParseException {
|
412 |
|
String nextToken = getNextEmptyOrOpener(tokenizer);
|
413 |
|
if (nextToken.equals("EMPTY")) {
|
414 |
|
return null;
|
415 |
|
}
|
416 |
|
ArrayList holes = new ArrayList();
|
417 |
|
Geometry shell = readLinearRingText(tokenizer);
|
418 |
|
nextToken = getNextCloserOrComma(tokenizer);
|
419 |
|
while (nextToken.equals(",")) {
|
420 |
|
Geometry hole = readLinearRingText(tokenizer);
|
421 |
|
holes.add(hole);
|
422 |
|
nextToken = getNextCloserOrComma(tokenizer);
|
423 |
|
}
|
424 |
|
// LinearRing[] array = new LinearRing[holes.size()];
|
425 |
|
return shell; //geometryFactory.createPolygon(shell, (LinearRing[]) holes.toArray(array));
|
426 |
|
}
|
427 |
423 |
|
428 |
|
/**
|
429 |
|
* Creates a <code>MultiLineString</code> using the next token in the stream.
|
430 |
|
*
|
431 |
|
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
432 |
|
* format. The next tokens must form a <MultiLineString Text>.
|
433 |
|
*@return a <code>MultiLineString</code> specified by the
|
434 |
|
* next token in the stream
|
435 |
|
*@throws IOException if an I/O error occurs
|
436 |
|
*@throws ParseException if an unexpected token was encountered
|
437 |
|
*/
|
438 |
|
private Geometry readMultiLineStringText(StreamTokenizer tokenizer) throws IOException, ParseException {
|
439 |
|
// TODO: HACER ESTO BIEN, CON UN GENERAL PATH
|
440 |
|
String nextToken = getNextEmptyOrOpener(tokenizer);
|
441 |
|
if (nextToken.equals("EMPTY")) {
|
442 |
|
return null;
|
443 |
|
}
|
444 |
|
ArrayList lineStrings = new ArrayList();
|
445 |
|
Geometry lineString = readLineStringText(tokenizer);
|
446 |
|
lineStrings.add(lineString);
|
447 |
|
nextToken = getNextCloserOrComma(tokenizer);
|
448 |
|
while (nextToken.equals(",")) {
|
449 |
|
lineString = readLineStringText(tokenizer);
|
450 |
|
lineStrings.add(lineString);
|
451 |
|
nextToken = getNextCloserOrComma(tokenizer);
|
452 |
|
}
|
453 |
|
// LineString[] array = new LineString[lineStrings.size()];
|
454 |
|
return lineString; // geometryFactory.createMultiLineString((LineString[]) lineStrings.toArray(array));
|
455 |
|
}
|
|
424 |
/**
|
|
425 |
* Creates a <code>Polygon</code> using the next token in the stream.
|
|
426 |
*
|
|
427 |
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
|
428 |
* format. The next tokens must form a <Polygon Text>.
|
|
429 |
*@return a <code>Polygon</code> specified by the next token
|
|
430 |
* in the stream
|
|
431 |
*@throws ParseException if the coordinates used to create the <code>Polygon</code>
|
|
432 |
* shell and holes do not form closed linestrings, or if an unexpected
|
|
433 |
* token was encountered.
|
|
434 |
*@throws IOException if an I/O error occurs
|
|
435 |
* @throws IllegalAccessException
|
|
436 |
* @throws InstantiationException
|
|
437 |
*/
|
|
438 |
private Geometry readPolygonText(StreamTokenizer tokenizer) throws IOException, ParseException, InstantiationException, IllegalAccessException {
|
|
439 |
String nextToken = getNextEmptyOrOpener(tokenizer);
|
|
440 |
if (nextToken.equals("EMPTY")) {
|
|
441 |
return null;
|
|
442 |
}
|
|
443 |
ArrayList holes = new ArrayList();
|
|
444 |
Geometry shell = readLinearRingText(tokenizer);
|
|
445 |
nextToken = getNextCloserOrComma(tokenizer);
|
|
446 |
while (nextToken.equals(",")) {
|
|
447 |
Geometry hole = readLinearRingText(tokenizer);
|
|
448 |
holes.add(hole);
|
|
449 |
nextToken = getNextCloserOrComma(tokenizer);
|
|
450 |
}
|
|
451 |
// LinearRing[] array = new LinearRing[holes.size()];
|
|
452 |
return shell; //geometryFactory.createPolygon(shell, (LinearRing[]) holes.toArray(array));
|
|
453 |
}
|
456 |
454 |
|
457 |
|
/**
|
458 |
|
* Creates a <code>MultiPolygon</code> using the next token in the stream.
|
459 |
|
*
|
460 |
|
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
461 |
|
* format. The next tokens must form a <MultiPolygon Text>.
|
462 |
|
*@return a <code>MultiPolygon</code> specified by the next
|
463 |
|
* token in the stream, or if if the coordinates used to create the
|
464 |
|
* <code>Polygon</code> shells and holes do not form closed linestrings.
|
465 |
|
*@throws IOException if an I/O error occurs
|
466 |
|
*@throws ParseException if an unexpected token was encountered
|
467 |
|
*/
|
468 |
|
// TODO:
|
469 |
|
private Geometry readMultiPolygonText(StreamTokenizer tokenizer) throws IOException, ParseException {
|
470 |
|
String nextToken = getNextEmptyOrOpener(tokenizer);
|
471 |
|
if (nextToken.equals("EMPTY")) {
|
472 |
|
return null;
|
473 |
|
}
|
474 |
|
ArrayList polygons = new ArrayList();
|
475 |
|
Geometry polygon = readPolygonText(tokenizer);
|
476 |
|
/* polygons.add(polygon);
|
|
455 |
/**
|
|
456 |
* Creates a <code>MultiLineString</code> using the next token in the stream.
|
|
457 |
*
|
|
458 |
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
|
459 |
* format. The next tokens must form a <MultiLineString Text>.
|
|
460 |
*@return a <code>MultiLineString</code> specified by the
|
|
461 |
* next token in the stream
|
|
462 |
*@throws IOException if an I/O error occurs
|
|
463 |
*@throws ParseException if an unexpected token was encountered
|
|
464 |
* @throws IllegalAccessException
|
|
465 |
* @throws InstantiationException
|
|
466 |
*/
|
|
467 |
private Geometry readMultiLineStringText(StreamTokenizer tokenizer) throws IOException, ParseException, InstantiationException, IllegalAccessException {
|
|
468 |
// TODO: HACER ESTO BIEN, CON UN GENERAL PATH
|
|
469 |
String nextToken = getNextEmptyOrOpener(tokenizer);
|
|
470 |
if (nextToken.equals("EMPTY")) {
|
|
471 |
return null;
|
|
472 |
}
|
|
473 |
ArrayList lineStrings = new ArrayList();
|
|
474 |
Geometry lineString = readLineStringText(tokenizer);
|
|
475 |
lineStrings.add(lineString);
|
|
476 |
nextToken = getNextCloserOrComma(tokenizer);
|
|
477 |
while (nextToken.equals(",")) {
|
|
478 |
lineString = readLineStringText(tokenizer);
|
|
479 |
lineStrings.add(lineString);
|
|
480 |
nextToken = getNextCloserOrComma(tokenizer);
|
|
481 |
}
|
|
482 |
// LineString[] array = new LineString[lineStrings.size()];
|
|
483 |
return lineString; // geometryFactory.createMultiLineString((LineString[]) lineStrings.toArray(array));
|
|
484 |
}
|
|
485 |
|
|
486 |
/**
|
|
487 |
* Creates a <code>MultiPolygon</code> using the next token in the stream.
|
|
488 |
*
|
|
489 |
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
|
490 |
* format. The next tokens must form a <MultiPolygon Text>.
|
|
491 |
*@return a <code>MultiPolygon</code> specified by the next
|
|
492 |
* token in the stream, or if if the coordinates used to create the
|
|
493 |
* <code>Polygon</code> shells and holes do not form closed linestrings.
|
|
494 |
*@throws IOException if an I/O error occurs
|
|
495 |
*@throws ParseException if an unexpected token was encountered
|
|
496 |
* @throws IllegalAccessException
|
|
497 |
* @throws InstantiationException
|
|
498 |
*/
|
|
499 |
// TODO:
|
|
500 |
private Geometry readMultiPolygonText(StreamTokenizer tokenizer) throws IOException, ParseException, InstantiationException, IllegalAccessException {
|
|
501 |
String nextToken = getNextEmptyOrOpener(tokenizer);
|
|
502 |
if (nextToken.equals("EMPTY")) {
|
|
503 |
return null;
|
|
504 |
}
|
|
505 |
ArrayList polygons = new ArrayList();
|
|
506 |
Geometry polygon = readPolygonText(tokenizer);
|
|
507 |
/* polygons.add(polygon);
|
477 |
508 |
nextToken = getNextCloserOrComma(tokenizer);
|
478 |
509 |
while (nextToken.equals(",")) {
|
479 |
510 |
polygon = readPolygonText(tokenizer);
|
480 |
511 |
polygons.add(polygon);
|
481 |
512 |
nextToken = getNextCloserOrComma(tokenizer);
|
482 |
513 |
} */
|
483 |
|
// Polygon[] array = new Polygon[polygons.size()];
|
484 |
|
return polygon; //geometryFactory.createMultiPolygon((Polygon[]) polygons.toArray(array));
|
485 |
|
}
|
|
514 |
// Polygon[] array = new Polygon[polygons.size()];
|
|
515 |
return polygon; //geometryFactory.createMultiPolygon((Polygon[]) polygons.toArray(array));
|
|
516 |
}
|
486 |
517 |
|
487 |
|
/**
|
488 |
|
* Creates a <code>GeometryCollection</code> using the next token in the
|
489 |
|
* stream.
|
490 |
|
*
|
491 |
|
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
492 |
|
* format. The next tokens must form a <GeometryCollection Text>.
|
493 |
|
*@return a <code>GeometryCollection</code> specified by the
|
494 |
|
* next token in the stream
|
495 |
|
*@throws ParseException if the coordinates used to create a <code>Polygon</code>
|
496 |
|
* shell and holes do not form closed linestrings, or if an unexpected
|
497 |
|
* token was encountered
|
498 |
|
*@throws IOException if an I/O error occurs
|
499 |
|
*/
|
500 |
|
// TODO:
|
501 |
|
/* private GeometryCollection readGeometryCollectionText(StreamTokenizer tokenizer) throws IOException, ParseException {
|
|
518 |
/**
|
|
519 |
* Creates a <code>GeometryCollection</code> using the next token in the
|
|
520 |
* stream.
|
|
521 |
*
|
|
522 |
*@param tokenizer tokenizer over a stream of text in Well-known Text
|
|
523 |
* format. The next tokens must form a <GeometryCollection Text>.
|
|
524 |
*@return a <code>GeometryCollection</code> specified by the
|
|
525 |
* next token in the stream
|
|
526 |
*@throws ParseException if the coordinates used to create a <code>Polygon</code>
|
|
527 |
* shell and holes do not form closed linestrings, or if an unexpected
|
|
528 |
* token was encountered
|
|
529 |
*@throws IOException if an I/O error occurs
|
|
530 |
*/
|
|
531 |
// TODO:
|
|
532 |
/* private GeometryCollection readGeometryCollectionText(StreamTokenizer tokenizer) throws IOException, ParseException {
|
502 |
533 |
String nextToken = getNextEmptyOrOpener(tokenizer);
|
503 |
534 |
if (nextToken.equals("EMPTY")) {
|
504 |
535 |
return geometryFactory.createGeometryCollection(new Geometry[]{});
|