public List < List < GeographyPointValue > > getRings ( ) { /* * Gets the loops that make up the polygon, with the outer loop first. * Note that we need to convert from XYZPoint to GeographyPointValue. * * Include the loop back to the first vertex. Also, since WKT wants * holes oriented Clockwise and S2 wants everything oriented CounterClockWise, * reverse the order of holes. We take care to leave the first vertex * the same. */ List < List < GeographyPointValue >> llLoops = new ArrayList <> ( ) ; boolean isShell = true ; for ( List < XYZPoint > xyzLoop : m_loops ) { List < GeographyPointValue > llLoop = new ArrayList <> ( ) ; // Add the first of xyzLoop first. llLoop . add ( xyzLoop . get ( 0 ) . toGeographyPointValue ( ) ) ; // Add shells left to right, and holes right to left. Make sure // not to add the first element we just added. int startIdx = ( isShell ? 1 : xyzLoop . size ( ) - 1 ) ; int endIdx = ( isShell ? xyzLoop . size ( ) : 0 ) ; int delta = ( isShell ? 1 : - 1 ) ; for ( int idx = startIdx ; idx != endIdx ; idx += delta ) { XYZPoint xyz = xyzLoop . get ( idx ) ; llLoop . add ( xyz . toGeographyPointValue ( ) ) ; } // Close the loop. llLoop . add ( xyzLoop . get ( 0 ) . toGeographyPointValue ( ) ) ; llLoops . add ( llLoop ) ; isShell = false ; } return llLoops ; }
Return the list of rings of a polygon . The list has the same values as the list of rings used to construct the polygon or the sequence of WKT rings used to construct the polygon .