/** * Parses a sequence of coordinates array expressed as * * [ [100.0, 0.0], [101.0, 1.0] ] * * @param jp * @throws IOException * @throws SQLException * @return Coordinate[] */ private Coordinate[] parseCoordinates(JsonParser jp) throws IOException { jp.nextToken(); // START_ARRAY [ to parse the each positions ArrayList<Coordinate> coords = new ArrayList<Coordinate>(); while (jp.getCurrentToken() != JsonToken.END_ARRAY) { coords.add(parseCoordinate(jp)); } return coords.toArray(new Coordinate[coords.size()]); }
/** * Parses a sequence of coordinates array expressed as * * [ [100.0, 0.0], [101.0, 1.0] ] * * @param jp * @throws IOException * @throws SQLException * @return Coordinate[] */ private Coordinate[] parseCoordinates(JsonParser jp) throws IOException { jp.nextToken(); // START_ARRAY [ to parse the each positions ArrayList<Coordinate> coords = new ArrayList<Coordinate>(); while (jp.getCurrentToken() != JsonToken.END_ARRAY) { coords.add(parseCoordinate(jp)); } return coords.toArray(new Coordinate[coords.size()]); }
/** * Parses a sequence of coordinates array expressed as * * [ [100.0, 0.0], [101.0, 1.0] ] * * @param jp * @throws IOException * @throws SQLException * @return Coordinate[] */ private Coordinate[] parseCoordinates(JsonParser jp) throws IOException { jp.nextToken(); // START_ARRAY [ to parse the each positions ArrayList<Coordinate> coords = new ArrayList<Coordinate>(); while (jp.getCurrentToken() != JsonToken.END_ARRAY) { coords.add(parseCoordinate(jp)); } return coords.toArray(new Coordinate[0]); }
/** * Parses one position * * Syntax: * * { "type": "Point", "coordinates": [100.0, 0.0] } * * @param jp * @throws IOException * @return Point */ private Point parsePoint(JsonParser jp) throws IOException, SQLException { jp.nextToken(); // FIELD_NAME coordinates String coordinatesField = jp.getText(); if (coordinatesField.equalsIgnoreCase(GeoJsonField.COORDINATES)) { jp.nextToken(); // START_ARRAY [ to parse the coordinate Point point = GF.createPoint(parseCoordinate(jp)); return point; } else { throw new SQLException("Malformed GeoJSON file. Expected 'coordinates', found '" + coordinatesField + "'"); } }
/** * Parses one position * * Syntax: * * { "type": "Point", "coordinates": [100.0, 0.0] } * * @param jp * @throws IOException * @return Point */ private Point parsePoint(JsonParser jp) throws IOException, SQLException { jp.nextToken(); // FIELD_NAME coordinates String coordinatesField = jp.getText(); if (coordinatesField.equalsIgnoreCase(GeoJsonField.COORDINATES)) { jp.nextToken(); // START_ARRAY [ to parse the coordinate Point point = GF.createPoint(parseCoordinate(jp)); return point; } else { throw new SQLException("Malformed GeoJSON file. Expected 'coordinates', found '" + coordinatesField + "'"); } }
/** * Parses one position * * Syntax: * * { "type": "Point", "coordinates": [100.0, 0.0] } * * @param jp * @throws IOException * @return Point */ private Point parsePoint(JsonParser jp) throws IOException, SQLException { jp.nextToken(); // FIELD_NAME coordinates String coordinatesField = jp.getText(); if (coordinatesField.equalsIgnoreCase(GeoJsonField.COORDINATES)) { jp.nextToken(); // START_ARRAY [ to parse the coordinate return GF.createPoint(parseCoordinate(jp)); } else { throw new SQLException("Malformed GeoJSON file. Expected 'coordinates', found '" + coordinatesField + "'"); } }