protected static ArrayList<GeoPoint> parseKmlCoordinates(String input){
  LinkedList<GeoPoint> tmpCoords=new LinkedList<GeoPoint>();
  int i=0;
  int tupleStart=0;
  int length=input.length();
  boolean startReadingTuple=false;
  while (i < length) {
    char c=input.charAt(i);
    if (c == ' ' || c == '\n' || c == '\t') {
      if (startReadingTuple) {
        String tuple=input.substring(tupleStart,i);
        GeoPoint p=parseKmlCoord(tuple);
        if (p != null)         tmpCoords.add(p);
        startReadingTuple=false;
      }
    }
 else {
      if (!startReadingTuple) {
        startReadingTuple=true;
        tupleStart=i;
      }
      if (i == length - 1) {
        String tuple=input.substring(tupleStart,i + 1);
        GeoPoint p=parseKmlCoord(tuple);
        if (p != null)         tmpCoords.add(p);
      }
    }
    i++;
  }
  ArrayList<GeoPoint> coordinates=new ArrayList<GeoPoint>(tmpCoords.size());
  coordinates.addAll(tmpCoords);
  return coordinates;
}

protected static ArrayList < GeoPoint > parseKmlCoordinates ( String input ) { LinkedList < GeoPoint > tmpCoords = new LinkedList < GeoPoint > ( ) ; int i = 0 ; int tupleStart = 0 ; int length = input . length ( ) ; boolean startReadingTuple = false ; while ( i < length ) { char c = input . charAt ( i ) ; if ( c == ' ' || c == '\n' || c == '\t' ) { if ( startReadingTuple ) { String tuple = input . substring ( tupleStart , i ) ; GeoPoint p = parseKmlCoord ( tuple ) ; if ( p != null ) tmpCoords . add ( p ) ; startReadingTuple = false ; } } else { if ( ! startReadingTuple ) { startReadingTuple = true ; tupleStart = i ; } if ( i == length - 1 ) { String tuple = input . substring ( tupleStart , i + 1 ) ; GeoPoint p = parseKmlCoord ( tuple ) ; if ( p != null ) tmpCoords . add ( p ) ; } } i ++ ; } ArrayList < GeoPoint > coordinates = new ArrayList < GeoPoint > ( tmpCoords . size ( ) ) ; coordinates . addAll ( tmpCoords ) ; return coordinates ; }
kml coordinates are : lon , lat { , alt } tuples separated by separators ( space , tab , cr ) .
