ShapeFactory.PolygonBuilder.HoleBuilder hole = b.hole(); coords = (ArrayNode)arr.get(h); for(int i=0; i<coords.size(); i++) {
protected Shape readPolygon(XReader reader) throws IOException { ShapeFactory.PolygonBuilder polyBuilder = shpFactory.polygon(); reader.readPoints(polyBuilder); if(!reader.isDone() && reader.peek()==PolyshapeWriter.KEY_ARG_START) { List<LinearRing> list = new ArrayList<LinearRing>(); while(reader.isEvent() && reader.peek()==PolyshapeWriter.KEY_ARG_START) { reader.readKey(); // eat the event; reader.readPoints(polyBuilder.hole()).endHole(); } } return polyBuilder.build(); }
protected ShapeFactory.PolygonBuilder readPolygon(JSONParser parser, ShapeFactory.PolygonBuilder polygonBuilder) throws IOException, ParseException { assert (parser.lastEvent() == JSONParser.ARRAY_START); boolean firstRing = true; int evt = parser.nextEvent(); while (true) { switch (evt) { case JSONParser.ARRAY_START: if (firstRing) { readCoordListXYZ(parser, polygonBuilder); firstRing = false; } else { ShapeFactory.PolygonBuilder.HoleBuilder holeBuilder = polygonBuilder.hole(); readCoordListXYZ(parser, holeBuilder); holeBuilder.endHole(); } break; case JSONParser.ARRAY_END: return polygonBuilder; default: throw new ParseException("Unexpected " + JSONParser.getEventString(evt), (int) parser.getPosition()); } evt = parser.nextEvent(); } }
/** * Reads a polygon */ protected ShapeFactory.PolygonBuilder polygon(WKTReader.State state, ShapeFactory.PolygonBuilder polygonBuilder) throws ParseException { state.nextExpect('('); pointList(state, polygonBuilder); // outer ring while (state.nextIf(',')) { ShapeFactory.PolygonBuilder.HoleBuilder holeBuilder = polygonBuilder.hole(); pointList(state, holeBuilder); holeBuilder.endHole(); } state.nextExpect(')'); return polygonBuilder; }