return readGeometryTaggedText(tokenizer, type, ordinateFlags);
/** * Reads a Well-Known Text representation of a {@link Geometry} * from a {@link Reader}. * *@param reader a Reader which will return a <Geometry Tagged Text> * string (see the OpenGIS Simple Features Specification) *@return a <code>Geometry</code> read from <code>reader</code> *@throws ParseException if a parsing problem occurs */ public Geometry read(Reader reader) throws ParseException { StreamTokenizer tokenizer = createTokenizer(reader); try { return readGeometryTaggedText(tokenizer); } catch (IOException e) { throw new ParseException(e.toString()); } }
/** * Creates a <code>GeometryCollection</code> using the next token in the * stream. * *@param tokenizer tokenizer over a stream of text in Well-known Text * format. The next tokens must form a <GeometryCollection Text>. *@return a <code>GeometryCollection</code> specified by the * next token in the stream *@throws ParseException if the coordinates used to create a <code>Polygon</code> * shell and holes do not form closed linestrings, or if an unexpected * token was encountered *@throws IOException if an I/O error occurs */ private GeometryCollection readGeometryCollectionText(StreamTokenizer tokenizer, EnumSet<Ordinate> ordinateFlags) throws IOException, ParseException { String nextToken = getNextEmptyOrOpener(tokenizer); if (nextToken.equals(EMPTY)) { return geometryFactory.createGeometryCollection(); } ArrayList geometries = new ArrayList(); do { Geometry geometry = readGeometryTaggedText(tokenizer); geometries.add(geometry); nextToken = getNextCloserOrComma(tokenizer); } while (nextToken.equals(COMMA)); Geometry[] array = new Geometry[geometries.size()]; return geometryFactory.createGeometryCollection((Geometry[]) geometries.toArray(array)); }