use of org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence in project jena by apache.
the class GMLReader method buildLinearRing.
private static LinearRing buildLinearRing(Element gmlElement, CoordinateSequenceDimensions dims) {
int srsDimension = CoordinateSequenceDimensions.convertToInt(dims);
String posList = extractPosList(gmlElement, srsDimension);
CustomCoordinateSequence sequence = new CustomCoordinateSequence(dims, posList);
LinearRing linearRing = GEOMETRY_FACTORY.createLinearRing(sequence);
return linearRing;
}
use of org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence in project jena by apache.
the class WKTReader method buildPolygon.
private Polygon buildPolygon(String coordinates) {
Polygon polygon;
String[] splitCoordinates = splitCoordinates(coordinates);
if (splitCoordinates.length == 1) {
// Polygon without holes.
CustomCoordinateSequence shellSequence = new CustomCoordinateSequence(dims, clean(coordinates));
polygon = GEOMETRY_FACTORY.createPolygon(shellSequence);
} else {
// Polygon with holes
String shellCoordinates = splitCoordinates[0];
CustomCoordinateSequence shellSequence = new CustomCoordinateSequence(dims, clean(shellCoordinates));
LinearRing shellLinearRing = GEOMETRY_FACTORY.createLinearRing(shellSequence);
String[] splitHoleCoordinates = Arrays.copyOfRange(splitCoordinates, 1, splitCoordinates.length);
LinearRing[] holesLinearRing = splitLinearRings(dims, splitHoleCoordinates);
polygon = GEOMETRY_FACTORY.createPolygon(shellLinearRing, holesLinearRing);
}
return polygon;
}
use of org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence in project jena by apache.
the class WKTReader method splitLineStrings.
private LineString[] splitLineStrings(String[] splitCoordinates) {
LineString[] lineStrings = new LineString[splitCoordinates.length];
for (int i = 0; i < splitCoordinates.length; i++) {
CustomCoordinateSequence sequence = new CustomCoordinateSequence(dims, clean(splitCoordinates[i]));
LineString lineString = GEOMETRY_FACTORY.createLineString(sequence);
lineStrings[i] = lineString;
}
return lineStrings;
}
use of org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence in project jena by apache.
the class WKTReader method splitLinearRings.
private LinearRing[] splitLinearRings(CoordinateSequenceDimensions dims, String[] splitCoordinates) {
LinearRing[] linearRings = new LinearRing[splitCoordinates.length];
for (int i = 0; i < splitCoordinates.length; i++) {
CustomCoordinateSequence sequence = new CustomCoordinateSequence(dims, clean(splitCoordinates[i]));
LinearRing linearRing = GEOMETRY_FACTORY.createLinearRing(sequence);
linearRings[i] = linearRing;
}
return linearRings;
}
use of org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence in project jena by apache.
the class GMLWriter method buildPolygon.
private static Element buildPolygon(final Polygon polygon, final String srsName) {
Element gmlRoot = new Element(polygon.getGeometryType(), GML_NAMESPACE);
gmlRoot.setAttribute("srsName", srsName);
if (!polygon.isEmpty()) {
LineString lineString = polygon.getExteriorRing();
CustomCoordinateSequence coordSequence = (CustomCoordinateSequence) lineString.getCoordinateSequence();
// Find exterior shell
Element exterior = new Element("exterior", GML_NAMESPACE);
Element exteriorLinearRing = new Element("LinearRing", GML_NAMESPACE);
Element exteriorPosList = new Element("posList", GML_NAMESPACE);
exteriorPosList.addContent(convertToGMLText(coordSequence));
exteriorLinearRing.addContent(exteriorPosList);
exterior.addContent(exteriorLinearRing);
gmlRoot.addContent(exterior);
// Find inner holes
int interiorRings = polygon.getNumInteriorRing();
for (int i = 0; i < interiorRings; i++) {
// flush all content
Element interior = new Element("interior", GML_NAMESPACE);
Element interiorLinearRing = new Element("LinearRing", GML_NAMESPACE);
Element innerPosList = new Element("posList", GML_NAMESPACE);
LineString innerLineString = polygon.getInteriorRingN(i);
CustomCoordinateSequence innerCoordSequence = (CustomCoordinateSequence) innerLineString.getCoordinateSequence();
innerPosList.addContent(convertToGMLText(innerCoordSequence));
interiorLinearRing.addContent(innerPosList);
interior.addContent(interiorLinearRing);
gmlRoot.addContent(interior);
}
} else {
// Do nothing to the GML
}
return gmlRoot;
}
Aggregations