use of com.revolsys.record.io.format.json.JsonParser in project com.revolsys.open by revolsys.
the class GeoJsonGeometryReader method readMultiPolygon.
private Geometry readMultiPolygon(final boolean cogo) {
final List<Polygon> polygons = new ArrayList<>();
List<List<LineString>> polygonRings = null;
GeometryFactory factory = this.geometryFactory;
do {
final JsonParser parser = this.in;
final String fieldName = parser.skipToNextAttribute();
if (GeoJson.COORDINATES.equals(fieldName)) {
polygonRings = readCoordinatesListListList(cogo);
} else if (GeoJson.CRS.equals(fieldName)) {
factory = readCoordinateSystem();
}
} while (this.in.getEvent() != EventType.endObject && this.in.getEvent() != EventType.endDocument);
int axisCount = 2;
if (polygonRings != null) {
for (final List<LineString> rings : polygonRings) {
for (final LineString points : rings) {
axisCount = Math.max(axisCount, points.getAxisCount());
}
factory = factory.convertAxisCount(axisCount);
final Polygon polygon = factory.polygon(rings);
polygons.add(polygon);
}
}
return factory.polygonal(polygons);
}
use of com.revolsys.record.io.format.json.JsonParser in project com.revolsys.open by revolsys.
the class GeoJsonGeometryReader method readMultiPoint.
private Geometry readMultiPoint() {
List<LineString> pointsList = null;
GeometryFactory factory = this.geometryFactory;
do {
final JsonParser parser = this.in;
final String fieldName = parser.skipToNextAttribute();
if (GeoJson.COORDINATES.equals(fieldName)) {
pointsList = readPointCoordinatesListList();
} else if (GeoJson.CRS.equals(fieldName)) {
factory = readCoordinateSystem();
}
} while (this.in.getEvent() != EventType.endObject && this.in.getEvent() != EventType.endDocument);
int axisCount = 2;
for (final LineString points : pointsList) {
axisCount = Math.max(axisCount, points.getAxisCount());
}
factory = factory.convertAxisCount(axisCount);
return factory.punctual(pointsList);
}
use of com.revolsys.record.io.format.json.JsonParser in project com.revolsys.open by revolsys.
the class GeoJsonGeometryReader method readMultiLineString.
private Geometry readMultiLineString(final boolean cogo) {
List<LineString> lineStrings = null;
GeometryFactory factory = this.geometryFactory;
do {
final JsonParser parser = this.in;
final String fieldName = parser.skipToNextAttribute();
if (GeoJson.COORDINATES.equals(fieldName)) {
lineStrings = readCoordinatesListList(cogo, false);
} else if (GeoJson.CRS.equals(fieldName)) {
factory = readCoordinateSystem();
}
} while (this.in.getEvent() != EventType.endObject && this.in.getEvent() != EventType.endDocument);
int axisCount = 2;
for (final LineString points : lineStrings) {
axisCount = Math.max(axisCount, points.getAxisCount());
}
factory = factory.convertAxisCount(axisCount);
return factory.lineal(lineStrings);
}
use of com.revolsys.record.io.format.json.JsonParser in project com.revolsys.open by revolsys.
the class GeoJsonGeometryReader method readGeometryCollection.
private Geometry readGeometryCollection() {
List<Geometry> geometries = new ArrayList<>();
GeometryFactory factory = this.geometryFactory;
do {
final JsonParser parser = this.in;
final String fieldName = parser.skipToNextAttribute();
if (GeoJson.GEOMETRIES.equals(fieldName)) {
geometries = readGeometryList();
} else if (GeoJson.CRS.equals(fieldName)) {
factory = readCoordinateSystem();
}
} while (this.in.getEvent() != EventType.endObject && this.in.getEvent() != EventType.endDocument);
return factory.geometry(geometries);
}
use of com.revolsys.record.io.format.json.JsonParser in project com.revolsys.open by revolsys.
the class GeoJsonGeometryReader method readPoint.
private Point readPoint() {
LineString coordinates = null;
GeometryFactory factory = this.geometryFactory;
do {
final JsonParser parser = this.in;
final String fieldName = parser.skipToNextAttribute();
if (GeoJson.COORDINATES.equals(fieldName)) {
coordinates = readPointCoordinatesList();
} else if (GeoJson.CRS.equals(fieldName)) {
factory = readCoordinateSystem();
}
} while (this.in.getEvent() != EventType.endObject && this.in.getEvent() != EventType.endDocument);
if (coordinates == null) {
return factory.point();
} else {
final int axisCount = coordinates.getAxisCount();
final GeometryFactory geometryFactory = factory.convertAxisCount(axisCount);
return geometryFactory.point(coordinates);
}
}
Aggregations