protected Polygon readCurvePolygon() throws IOException, ParseException { int numRings = dis.readInt(); LinearRing[] holes = null; if (numRings > 1) holes = new LinearRing[numRings - 1]; LinearRing shell = readRing(); for (int i = 0; i < numRings - 1; i++) { holes[i] = readRing(); } return factory.createPolygon(shell, holes); }
/** * Creates a <code>Polygon</code> using the next token in the stream. * * @return a <code>Polygon</code> specified by the next token in the stream * @throws ParseException if the coordinates used to create the <code>Polygon</code> shell and * holes do not form closed linestrings, or if an unexpected token was encountered. * @throws IOException if an I/O error occurs */ private Polygon readPolygonText() throws IOException, ParseException { String nextToken = getNextEmptyOrOpener(); if (nextToken.equals(EMPTY)) { return geometryFactory.createPolygon( geometryFactory.createLinearRing(new Coordinate[] {}), new LinearRing[] {}); } ArrayList holes = new ArrayList(); LinearRing shell = readLinearRingText(); nextToken = getNextCloserOrComma(); while (nextToken.equals(COMMA)) { LinearRing hole = readLinearRingText(); holes.add(hole); nextToken = getNextCloserOrComma(); } LinearRing[] array = new LinearRing[holes.size()]; return geometryFactory.createPolygon(shell, (LinearRing[]) holes.toArray(array)); }
protected Polygon readPolygon() throws IOException { int numRings = dis.readInt(); LinearRing[] holes = null; if (numRings > 1) holes = new LinearRing[numRings - 1]; LinearRing shell = readLinearRing(); for (int i = 0; i < numRings - 1; i++) { holes[i] = readLinearRing(); } return factory.createPolygon(shell, holes); }
public static Polygon polygon() { return gf.createPolygon(linearRing(), null); }
public static Polygon curvePolygon() { LineString curve1 = gf.createCurvedGeometry(2, 0, 0, 2, 0, 2, 1, 2, 3, 4, 3); LineString line1 = gf.createLineString(new LiteCoordinateSequence(4, 3, 4, 5, 1, 4, 0, 0)); LinearRing shell = (LinearRing) gf.createCurvedGeometry(Arrays.asList(curve1, line1)); LinearRing hole = (LinearRing) gf.createCurvedGeometry(2, 1.7, 1, 1.4, 0.4, 1.6, 0.4, 1.6, 0.5, 1.7, 1); return gf.createPolygon(shell, new LinearRing[] {hole}); }
Polygon poly = gf.createPolygon(exteriorRing, toInteriorRingArray(rings)); poly.setSRID(SRID);