Search in sources :

Example 1 with EventType

use of com.revolsys.record.io.format.json.JsonParser.EventType in project com.revolsys.open by revolsys.

the class JsonMapIterator method readNextRecord.

/**
 * Reads the next line from the buffer and converts to a string array.
 *
 * @return a string array with each comma-separated element as a separate
 *         entry.
 * @throws IOException if bad things happen during the read
 */
private MapEx readNextRecord() {
    if (this.hasNext && this.parser.hasNext()) {
        final EventType event = this.parser.next();
        if (event == EventType.endArray || event == EventType.endDocument) {
            this.hasNext = false;
            close();
            return null;
        } else {
            this.currentObject = this.parser.getMap();
            return this.currentObject;
        }
    } else {
        this.hasNext = false;
        close();
        return null;
    }
}
Also used : EventType(com.revolsys.record.io.format.json.JsonParser.EventType)

Example 2 with EventType

use of com.revolsys.record.io.format.json.JsonParser.EventType in project com.revolsys.open by revolsys.

the class GeoJsonGeometryReader method readPointCoordinatesListList.

private List<LineString> readPointCoordinatesListList() {
    if (this.in.getEvent() == EventType.startArray || this.in.hasNext() && this.in.next() == EventType.startArray) {
        EventType event = this.in.next();
        final List<LineString> coordinatesLists = new ArrayList<>();
        if (event != EventType.endArray) {
            do {
                coordinatesLists.add(readPointCoordinatesList());
                event = this.in.next();
            } while (event == EventType.comma);
        }
        if (event != EventType.endArray) {
            throw new IllegalStateException("Exepecting end array, not: " + event);
        }
        return coordinatesLists;
    } else {
        throw new IllegalStateException("Exepecting start array, not: " + this.in.getEvent());
    }
}
Also used : EventType(com.revolsys.record.io.format.json.JsonParser.EventType) LineString(com.revolsys.geometry.model.LineString) ArrayList(java.util.ArrayList)

Example 3 with EventType

use of com.revolsys.record.io.format.json.JsonParser.EventType in project com.revolsys.open by revolsys.

the class GeoJsonGeometryReader method readCoordinatesListList.

private List<LineString> readCoordinatesListList(final boolean cogo, final boolean ring) {
    if (this.in.getEvent() == EventType.startArray || this.in.hasNext() && this.in.next() == EventType.startArray) {
        EventType event = this.in.next();
        final List<LineString> coordinatesLists = new ArrayList<>();
        if (event != EventType.endArray) {
            do {
                coordinatesLists.add(readCoordinatesList(cogo, ring));
                event = this.in.next();
            } while (event == EventType.comma);
        }
        if (event != EventType.endArray) {
            throw new IllegalStateException("Exepecting end array, not: " + event);
        }
        return coordinatesLists;
    } else {
        throw new IllegalStateException("Exepecting start array, not: " + this.in.getEvent());
    }
}
Also used : EventType(com.revolsys.record.io.format.json.JsonParser.EventType) LineString(com.revolsys.geometry.model.LineString) ArrayList(java.util.ArrayList)

Example 4 with EventType

use of com.revolsys.record.io.format.json.JsonParser.EventType in project com.revolsys.open by revolsys.

the class GeoJsonGeometryReader method readCoordinatesList.

private int readCoordinatesList(final List<Double> coordinates) {
    int axisCount = 0;
    if (this.in.getEvent() == EventType.startArray || this.in.hasNext() && this.in.next() == EventType.startArray) {
        EventType event = this.in.next();
        if (event != EventType.endArray) {
            do {
                axisCount = Math.max(axisCount, readCoordinatesListCoordinates(coordinates));
                event = this.in.next();
            } while (event == EventType.comma);
        }
        if (event != EventType.endArray) {
            throw new IllegalStateException("Exepecting end array, not: " + event);
        }
    } else {
        throw new IllegalStateException("Exepecting start array, not: " + this.in.getEvent());
    }
    return axisCount;
}
Also used : EventType(com.revolsys.record.io.format.json.JsonParser.EventType) Point(com.revolsys.geometry.model.Point)

Example 5 with EventType

use of com.revolsys.record.io.format.json.JsonParser.EventType in project com.revolsys.open by revolsys.

the class GeoJsonGeometryReader method readCoordinatesListListList.

private List<List<LineString>> readCoordinatesListListList(final boolean cogo) {
    if (this.in.getEvent() == EventType.startArray || this.in.hasNext() && this.in.next() == EventType.startArray) {
        EventType event = this.in.next();
        final List<List<LineString>> coordinatesLists = new ArrayList<>();
        if (event != EventType.endArray) {
            do {
                coordinatesLists.add(readCoordinatesListList(cogo, true));
                event = this.in.next();
            } while (event == EventType.comma);
        }
        if (event != EventType.endArray) {
            throw new IllegalStateException("Exepecting end array, not: " + event);
        }
        return coordinatesLists;
    } else {
        throw new IllegalStateException("Exepecting start array, not: " + this.in.getEvent());
    }
}
Also used : EventType(com.revolsys.record.io.format.json.JsonParser.EventType) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

EventType (com.revolsys.record.io.format.json.JsonParser.EventType)9 Point (com.revolsys.geometry.model.Point)4 ArrayList (java.util.ArrayList)4 Geometry (com.revolsys.geometry.model.Geometry)3 JsonParser (com.revolsys.record.io.format.json.JsonParser)3 MapEx (com.revolsys.collection.map.MapEx)2 LineString (com.revolsys.geometry.model.LineString)2 Record (com.revolsys.record.Record)2 NoSuchElementException (java.util.NoSuchElementException)2 List (java.util.List)1