use of org.opengis.geometry.complex.CompositeCurve in project geotoolkit by Geomatys.
the class GeometryUtils method getLineCharSequences.
/**
* Recursively populates the specified List with LineCharSequences corresponding
* to the primitive elements of the specified CompositeCurve.
* Returns null if any element of the CompositeCurve cannot be converted
* to a LineString.
* @param cc The CompositeCurve of interest
* @param lsList The ArrayList to be populated
* @return The populated List, or null if not valid
*/
private static ArrayList getLineCharSequences(final CompositeCurve cc, final ArrayList lsList) {
// Cast below can be removed when Types will be allowed to abandon Java 1.4 support.
List elements = (List) cc.getGenerators();
boolean valid = true;
if (!elements.isEmpty()) {
Iterator it = elements.iterator();
LineString ls = null;
while (it.hasNext() && valid) {
Object element = it.next();
if (element instanceof CompositeCurve) {
valid = getLineCharSequences((CompositeCurve) element, lsList) != null;
} else if (element instanceof Curve) {
// PENDING(NL): When we have arc geometries implemented,
// make provision to pass in real parameters for spacing and offset.
// What we have below essentially just returns start and end points
// if it's not a LineString
ls = ((Curve) element).asLineString(Double.MAX_VALUE, Double.MAX_VALUE);
if (ls != null) {
lsList.add(ls);
} else {
valid = false;
}
} else {
valid = false;
}
}
}
if (valid) {
return null;
}
return lsList;
}
Aggregations