use of org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence in project jena by apache.
the class GMLWriter method buildLineString.
private static Element buildLineString(final CoordinateSequence coordSeq, final String srsName) {
CustomCoordinateSequence coordSequence = (CustomCoordinateSequence) coordSeq;
Element gmlRoot = new Element("LineString", GML_NAMESPACE);
gmlRoot.setAttribute("srsName", srsName);
if (coordSequence.size() > 0) {
Element posList = new Element("posList", GML_NAMESPACE);
posList.addContent(convertToGMLText(coordSequence));
gmlRoot.addContent(posList);
}
return gmlRoot;
}
use of org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence in project jena by apache.
the class WKTReader method buildGeometry.
private Geometry buildGeometry(String geometryType, String coordinates) throws DatatypeFormatException {
Geometry geo;
try {
switch(geometryType) {
case "point":
CustomCoordinateSequence pointSequence = new CustomCoordinateSequence(dims, clean(coordinates));
geo = GEOMETRY_FACTORY.createPoint(pointSequence);
break;
case "linestring":
CustomCoordinateSequence lineSequence = new CustomCoordinateSequence(dims, clean(coordinates));
geo = GEOMETRY_FACTORY.createLineString(lineSequence);
break;
case "linearring":
CustomCoordinateSequence linearSequence = new CustomCoordinateSequence(dims, clean(coordinates));
geo = GEOMETRY_FACTORY.createLinearRing(linearSequence);
break;
case "polygon":
geo = buildPolygon(coordinates);
break;
case "multipoint":
CustomCoordinateSequence multiPointSequence = new CustomCoordinateSequence(dims, clean(coordinates));
geo = GEOMETRY_FACTORY.createMultiPoint(multiPointSequence);
break;
case "multilinestring":
geo = buildMultiLineString(coordinates);
break;
case "multipolygon":
geo = buildMultiPolygon(coordinates);
break;
case "geometrycollection":
geo = buildGeometryCollection(coordinates);
break;
default:
throw new DatatypeFormatException("Geometry type not supported: " + geometryType);
}
} catch (ArrayIndexOutOfBoundsException ex) {
throw new DatatypeFormatException("Build WKT Geometry Exception - Type: " + geometryType + ", Coordinates: " + coordinates + ". " + ex.getMessage());
}
return geo;
}
use of org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence in project jena by apache.
the class WKTWriter method buildMultiPoint.
private static String buildMultiPoint(final MultiPoint multiPoint, final String dimensionString) {
StringBuilder sb = new StringBuilder("MULTIPOINT");
if (!multiPoint.isEmpty()) {
sb.append(dimensionString);
sb.append("(");
// Find first point
Point point = (Point) multiPoint.getGeometryN(0);
CustomCoordinateSequence coordSequence = (CustomCoordinateSequence) point.getCoordinateSequence();
sb.append(buildWKT("", coordSequence));
// Encode remaining points
int geomCount = multiPoint.getNumGeometries();
for (int i = 1; i < geomCount; i++) {
sb.append(", ");
point = (Point) multiPoint.getGeometryN(i);
coordSequence = (CustomCoordinateSequence) point.getCoordinateSequence();
sb.append(buildWKT("", coordSequence));
}
sb.append(")");
} else {
sb.append(" EMPTY");
}
return sb.toString();
}
use of org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence in project jena by apache.
the class WKTWriter method buildPolygon.
private static String buildPolygon(final Polygon polygon, final boolean isIncludeGeometryType, final String dimensionString) {
StringBuilder sb = new StringBuilder();
if (isIncludeGeometryType) {
sb.append("POLYGON");
}
if (!polygon.isEmpty()) {
if (isIncludeGeometryType) {
sb.append(dimensionString);
}
sb.append("(");
// Find exterior shell
LineString lineString = polygon.getExteriorRing();
CustomCoordinateSequence coordSequence = (CustomCoordinateSequence) lineString.getCoordinateSequence();
sb.append(convertToWKTText(coordSequence));
// Find inner holes
int interiorRings = polygon.getNumInteriorRing();
for (int i = 0; i < interiorRings; i++) {
sb.append(", ");
LineString innerLineString = polygon.getInteriorRingN(i);
CustomCoordinateSequence innerCoordSequence = (CustomCoordinateSequence) innerLineString.getCoordinateSequence();
sb.append(convertToWKTText(innerCoordSequence));
}
sb.append(")");
} else {
sb.append(" EMPTY");
}
return sb.toString();
}
use of org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence in project jena by apache.
the class WKTWriter method buildMultiLineString.
private static String buildMultiLineString(final MultiLineString multiLineString, final String dimensionString) {
StringBuilder sb = new StringBuilder("MULTILINESTRING");
if (!multiLineString.isEmpty()) {
sb.append(dimensionString);
sb.append("(");
// Find first linestring
LineString lineString = (LineString) multiLineString.getGeometryN(0);
CustomCoordinateSequence coordSequence = (CustomCoordinateSequence) lineString.getCoordinateSequence();
sb.append(buildWKT("", coordSequence));
// Encode remaining points
int geomCount = multiLineString.getNumGeometries();
for (int i = 1; i < geomCount; i++) {
sb.append(", ");
lineString = (LineString) multiLineString.getGeometryN(i);
coordSequence = (CustomCoordinateSequence) lineString.getCoordinateSequence();
sb.append(buildWKT("", coordSequence));
}
sb.append(")");
} else {
sb.append(" EMPTY");
}
return sb.toString();
}
Aggregations