public String toWKT ( ) { StringBuffer sb = new StringBuffer ( ) ; sb . append ( "POLYGON (" ) ; boolean isFirstLoop = true ; for ( List < XYZPoint > loop : m_loops ) { if ( ! isFirstLoop ) { sb . append ( ", " ) ; } sb . append ( "(" ) ; int startIdx = ( isFirstLoop ? 1 : loop . size ( ) - 1 ) ; int endIdx = ( isFirstLoop ? loop . size ( ) : 0 ) ; int increment = ( isFirstLoop ? 1 : - 1 ) ; sb . append ( loop . get ( 0 ) . toGeographyPointValue ( ) . formatLngLat ( ) ) . append ( ", " ) ; for ( int idx = startIdx ; idx != endIdx ; idx += increment ) { XYZPoint xyz = loop . get ( idx ) ; sb . append ( xyz . toGeographyPointValue ( ) . formatLngLat ( ) ) ; sb . append ( ", " ) ; } // Repeat the start vertex to close the loop as WKT requires. sb . append ( loop . get ( 0 ) . toGeographyPointValue ( ) . formatLngLat ( ) ) ; sb . append ( ")" ) ; isFirstLoop = false ; } sb . append ( ")" ) ; return sb . toString ( ) ; }
Return a representation of this object as well - known text .