private void write(Coordinate[] coords,Writer writer,int level) throws IOException {
  startLine(level,writer);
  startGeomTag(GMLConstants.GML_COORDINATES,null,writer);
  int dim=2;
  if (coords.length > 0) {
    if (!(Double.isNaN(coords[0].z)))     dim=3;
  }
  boolean isNewLine=true;
  for (int i=0; i < coords.length; i++) {
    if (isNewLine) {
      startLine(level + 1,writer);
      isNewLine=false;
    }
    if (dim == 2) {
      writer.write("" + coords[i].x);
      writer.write(coordinateSeparator);
      writer.write("" + coords[i].y);
    }
 else     if (dim == 3) {
      writer.write("" + coords[i].x);
      writer.write(coordinateSeparator);
      writer.write("" + coords[i].y);
      writer.write(coordinateSeparator);
      writer.write("" + coords[i].z);
    }
    writer.write(tupleSeparator);
    if ((i + 1) % maxCoordinatesPerLine == 0 && i < coords.length - 1) {
      writer.write("\n");
      isNewLine=true;
    }
  }
  if (!isNewLine)   writer.write("\n");
  startLine(level,writer);
  endGeomTag(GMLConstants.GML_COORDINATES,writer);
}

private void write ( Coordinate [ ] coords , Writer writer , int level ) throws IOException { startLine ( level , writer ) ; startGeomTag ( GMLConstants . GML_COORDINATES , null , writer ) ; int dim = 2 ; if ( coords . length > 0 ) { if ( ! ( Double . isNaN ( coords [ 0 ] . z ) ) ) dim = 3 ; } boolean isNewLine = true ; for ( int i = 0 ; i < coords . length ; i ++ ) { if ( isNewLine ) { startLine ( level + 1 , writer ) ; isNewLine = false ; } if ( dim == 2 ) { writer . write ( "" + coords [ i ] . x ) ; writer . write ( coordinateSeparator ) ; writer . write ( "" + coords [ i ] . y ) ; } else if ( dim == 3 ) { writer . write ( "" + coords [ i ] . x ) ; writer . write ( coordinateSeparator ) ; writer . write ( "" + coords [ i ] . y ) ; writer . write ( coordinateSeparator ) ; writer . write ( "" + coords [ i ] . z ) ; } writer . write ( tupleSeparator ) ; if ( ( i + 1 ) % maxCoordinatesPerLine == 0 && i < coords . length - 1 ) { writer . write ( "\n" ) ; isNewLine = true ; } } if ( ! isNewLine ) writer . write ( "\n" ) ; startLine ( level , writer ) ; endGeomTag ( GMLConstants . GML_COORDINATES , writer ) ; }
takes a list of coordinates and converts it to gml . < br > 2d and 3d aware .
