} else { throw new ParseException("Unexpected String Value for key: " + key, (int) parser.getPosition()); (int) parser.getPosition()); (int) parser.getPosition()); (int) parser.getPosition());
protected void readCoordListXYZ(JSONParser parser, ShapeFactory.PointsBuilder pointsBuilder) throws IOException, ParseException { assert (parser.lastEvent() == JSONParser.ARRAY_START); int evt = parser.nextEvent(); while (evt != JSONParser.EOF) { switch (evt) { case JSONParser.ARRAY_START: readCoordXYZ(parser, pointsBuilder); // reads until ARRAY_END break; case JSONParser.ARRAY_END: return; default: throw new ParseException("Unexpected " + JSONParser.getEventString(evt), (int) parser.getPosition()); } evt = parser.nextEvent(); } }
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(); } }
protected Shape readShapeFromCoordinates(String type, JSONParser parser) throws IOException, ParseException { switch(type) { case "Point": return readPoint(parser); case "LineString": return readLineString(parser); case "Circle": return readCircle(parser); case "Polygon": return readPolygon(parser, shapeFactory.polygon()).buildOrRect(); case "MultiPoint": return readMultiPoint(parser); case "MultiLineString": return readMultiLineString(parser); case "MultiPolygon": return readMultiPolygon(parser); default: throw new ParseException("Unable to make shape type: " + type, (int) parser.getPosition()); } }
protected Shape readMultiLineString(JSONParser parser) throws IOException, ParseException { assert (parser.lastEvent() == JSONParser.ARRAY_START); // TODO need Spatial4j LineString interface ShapeFactory.MultiLineStringBuilder builder = shapeFactory.multiLineString(); int evt = parser.nextEvent(); while (true) { switch (evt) { case JSONParser.ARRAY_START: ShapeFactory.LineStringBuilder lineStringBuilder = builder.lineString(); readCoordListXYZ(parser, lineStringBuilder); builder.add(lineStringBuilder); break; case JSONParser.ARRAY_END: return builder.build(); default: throw new ParseException("Unexpected " + JSONParser.getEventString(evt), (int) parser.getPosition()); } evt = parser.nextEvent(); } }
protected Shape readMultiPolygon(JSONParser parser) throws IOException, ParseException { assert (parser.lastEvent() == JSONParser.ARRAY_START); // TODO need Spatial4j Polygon interface ShapeFactory.MultiPolygonBuilder builder = shapeFactory.multiPolygon(); int evt = parser.nextEvent(); while (true) { switch (evt) { case JSONParser.ARRAY_START: ShapeFactory.PolygonBuilder polygonBuilder = readPolygon(parser, builder.polygon()); builder.add(polygonBuilder); break; case JSONParser.ARRAY_END: return builder.build(); default: throw new ParseException("Unexpected " + JSONParser.getEventString(evt), (int) parser.getPosition()); } evt = parser.nextEvent(); } } }
default: throw new ParseException("Unexpected " + JSONParser.getEventString(evt), (int) parser.getPosition());
(int) parser.getPosition());
(int) parser.getPosition());
public List<Coordinate> readCoordList(JSONParser parser) throws IOException, ParseException { assert (parser.lastEvent() == JSONParser.ARRAY_START); List<Coordinate> coords = new ArrayList<Coordinate>(); int evt = parser.nextEvent(); while (evt != JSONParser.EOF) { switch (evt) { case JSONParser.ARRAY_START: coords.add(readCoord(parser)); break; case JSONParser.ARRAY_END: return coords; default: throw new ParseException("Unexpected " + JSONParser.getEventString(evt), (int) parser.getPosition()); } evt = parser.nextEvent(); } return coords; }
public List<double[]> readCoordListXY(JSONParser parser) throws IOException, ParseException { assert (parser.lastEvent() == JSONParser.ARRAY_START); List<double[]> coords = new ArrayList<double[]>(); int evt = parser.nextEvent(); while (evt != JSONParser.EOF) { switch (evt) { case JSONParser.ARRAY_START: coords.add(readCoordXY(parser)); break; case JSONParser.ARRAY_END: return coords; default: throw new ParseException("Unexpected " + JSONParser.getEventString(evt), (int) parser.getPosition()); } evt = parser.nextEvent(); } return coords; }
public List<double[]> readCoordListXY(JSONParser parser) throws IOException, ParseException { assert (parser.lastEvent() == JSONParser.ARRAY_START); List<double[]> coords = new ArrayList<double[]>(); int evt = parser.nextEvent(); while (evt != JSONParser.EOF) { switch (evt) { case JSONParser.ARRAY_START: coords.add(readCoordXY(parser)); break; case JSONParser.ARRAY_END: return coords; default: throw new ParseException("Unexpected " + JSONParser.getEventString(evt), (int) parser.getPosition()); } evt = parser.nextEvent(); } return coords; }
public List<Coordinate> readCoordList(JSONParser parser) throws IOException, ParseException { assert (parser.lastEvent() == JSONParser.ARRAY_START); List<Coordinate> coords = new ArrayList<Coordinate>(); int evt = parser.nextEvent(); while (evt != JSONParser.EOF) { switch (evt) { case JSONParser.ARRAY_START: coords.add(readCoord(parser)); break; case JSONParser.ARRAY_END: return coords; default: throw new ParseException("Unexpected " + JSONParser.getEventString(evt), (int) parser.getPosition()); } evt = parser.nextEvent(); } return coords; }
} else { throw new ParseException("Unexpected String Value for key: " + key, (int) parser.getPosition()); (int) parser.getPosition()); } else if ("geometries".equals(key)) { List<Shape> shapes = new ArrayList<Shape>(); (int) parser.getPosition()); (int) parser.getPosition()); (int) parser.getPosition());
} else { throw new ParseException("Unexpected String Value for key: " + key, (int) parser.getPosition()); (int) parser.getPosition()); } else if ("geometries".equals(key)) { List<Shape> shapes = new ArrayList<Shape>(); (int) parser.getPosition()); (int) parser.getPosition()); (int) parser.getPosition());
public Coordinate readCoord(JSONParser parser) throws IOException, ParseException { assert (parser.lastEvent() == JSONParser.ARRAY_START); Coordinate coord = new Coordinate(); int idx = 0; int evt = parser.nextEvent(); while (evt != JSONParser.EOF) { switch (evt) { case JSONParser.LONG: case JSONParser.NUMBER: case JSONParser.BIGNUMBER: coord.setOrdinate(idx++, parser.getDouble()); break; case JSONParser.ARRAY_END: return coord; case JSONParser.STRING: case JSONParser.BOOLEAN: case JSONParser.NULL: case JSONParser.OBJECT_START: case JSONParser.OBJECT_END: case JSONParser.ARRAY_START: default: throw new ParseException("Unexpected " + JSONParser.getEventString(evt), (int) parser.getPosition()); } evt = parser.nextEvent(); } return coord; }
public Coordinate readCoord(JSONParser parser) throws IOException, ParseException { assert (parser.lastEvent() == JSONParser.ARRAY_START); Coordinate coord = new Coordinate(); int idx = 0; int evt = parser.nextEvent(); while (evt != JSONParser.EOF) { switch (evt) { case JSONParser.LONG: case JSONParser.NUMBER: case JSONParser.BIGNUMBER: coord.setOrdinate(idx++, parser.getDouble()); break; case JSONParser.ARRAY_END: return coord; case JSONParser.STRING: case JSONParser.BOOLEAN: case JSONParser.NULL: case JSONParser.OBJECT_START: case JSONParser.OBJECT_END: case JSONParser.ARRAY_START: default: throw new ParseException("Unexpected " + JSONParser.getEventString(evt), (int) parser.getPosition()); } evt = parser.nextEvent(); } return coord; }
public double[] readCoordXY(JSONParser parser) throws IOException, ParseException { assert (parser.lastEvent() == JSONParser.ARRAY_START); double[] coord = new double[3]; int idx = 0; int evt = parser.nextEvent(); while (evt != JSONParser.EOF) { switch (evt) { case JSONParser.LONG: case JSONParser.NUMBER: case JSONParser.BIGNUMBER: coord[idx++] = parser.getDouble(); break; case JSONParser.ARRAY_END: return coord; case JSONParser.STRING: case JSONParser.BOOLEAN: case JSONParser.NULL: case JSONParser.OBJECT_START: case JSONParser.OBJECT_END: case JSONParser.ARRAY_START: default: throw new ParseException("Unexpected " + JSONParser.getEventString(evt), (int) parser.getPosition()); } evt = parser.nextEvent(); } return coord; }
public double[] readCoordXY(JSONParser parser) throws IOException, ParseException { assert (parser.lastEvent() == JSONParser.ARRAY_START); double[] coord = new double[3]; int idx = 0; int evt = parser.nextEvent(); while (evt != JSONParser.EOF) { switch (evt) { case JSONParser.LONG: case JSONParser.NUMBER: case JSONParser.BIGNUMBER: coord[idx++] = parser.getDouble(); break; case JSONParser.ARRAY_END: return coord; case JSONParser.STRING: case JSONParser.BOOLEAN: case JSONParser.NULL: case JSONParser.OBJECT_START: case JSONParser.OBJECT_END: case JSONParser.ARRAY_START: default: throw new ParseException("Unexpected " + JSONParser.getEventString(evt), (int) parser.getPosition()); } evt = parser.nextEvent(); } return coord; }