public static LineString createLine ( Geometry pointA , Geometry ... optionalPoints ) throws SQLException { if ( pointA == null || optionalPoints . length > 0 && optionalPoints [ 0 ] == null ) { return null ; } if ( pointA . getNumGeometries ( ) == 1 && ! atLeastTwoPoints ( optionalPoints , countPoints ( pointA ) ) ) { throw new SQLException ( "At least two points are required to make a line." ) ; } List < Coordinate > coordinateList = new LinkedList < Coordinate > ( ) ; addCoordinatesToList ( pointA , coordinateList ) ; for ( Geometry optionalPoint : optionalPoints ) { addCoordinatesToList ( optionalPoint , coordinateList ) ; } return ( ( Geometry ) pointA ) . getFactory ( ) . createLineString ( coordinateList . toArray ( new Coordinate [ optionalPoints . length ] ) ) ; }
Constructs a LINESTRING from the given POINTs or MULTIPOINTs