private Polygon asPolygon ( List < List < List > > coords , CrsId crsId ) throws IOException { if ( coords == null || coords . isEmpty ( ) ) { throw new IOException ( "A polygon requires the specification of its outer ring" ) ; } List < LinearRing > rings = new ArrayList < LinearRing > ( ) ; try { for ( List < List > ring : coords ) { PointSequence ringCoords = getPointSequence ( ring , crsId ) ; rings . add ( new LinearRing ( ringCoords ) ) ; } return new Polygon ( rings . toArray ( new LinearRing [ ] { } ) ) ; } catch ( IllegalArgumentException e ) { throw new IOException ( "Invalid Polygon: " + e . getMessage ( ) , e ) ; } }
Parses the JSON as a polygon geometry