*/
private Object[] parseLine(String line) {
List<String> entries = tokenize(line);
Iterator<String> iter = entries.iterator();
LabelList labels = new LabelList();
List<Polygon> polys = new java.util.Vector<Polygon>(1);
List<Vector> coords = new ArrayList<Vector>();
while(iter.hasNext()) {
String cur = iter.next();
Matcher m = COORD.matcher(cur);
if(m.find()) {
try {
double c1 = Double.valueOf(m.group(1));
double c2 = Double.valueOf(m.group(2));
if(m.group(3) != null) {
double c3 = Double.valueOf(m.group(3));
coords.add(new Vector(new double[] { c1, c2, c3 }));
}
else {
coords.add(new Vector(new double[] { c1, c2 }));
}
continue;
}
catch(NumberFormatException e) {
logger.warning("Looked like a coordinate pair but didn't parse: " + cur);
}
}
// Polygon separator.
if(cur.equals(POLYGON_SEPARATOR)) {
if(coords.size() > 0) {
polys.add(new Polygon(coords));
coords = new ArrayList<Vector>();
}
continue;
}
// Label
labels.add(cur);
}
// Complete polygon
if(coords.size() > 0) {
polys.add(new Polygon(coords));
}
// Use first label as eternal ID
ExternalID eid = labels.size() > 0 ? new ExternalID(labels.remove(0)) : null;
return new Object[] { new PolygonsObject(polys), labels, eid };
}