use of org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence in project jena by apache.
the class GMLWriter method buildPoint.
private static Element buildPoint(final CoordinateSequence coordSeq, final String srsName) {
CustomCoordinateSequence coordSequence = (CustomCoordinateSequence) coordSeq;
Element gmlRoot = new Element("Point", GML_NAMESPACE);
gmlRoot.setAttribute("srsName", srsName);
if (coordSequence.size() > 0) {
Element pos = new Element("pos", GML_NAMESPACE);
pos.addContent(convertToGMLText(coordSequence));
gmlRoot.addContent(pos);
}
return gmlRoot;
}
use of org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence in project jena by apache.
the class GMLReader method buildLineStringSegments.
private static LineString buildLineStringSegments(List<Element> segments, CoordinateSequenceDimensions dims) {
int srsDimension = CoordinateSequenceDimensions.convertToInt(dims);
List<Coordinate> lineStringCoords = new ArrayList<>();
for (Element segment : segments) {
List<Coordinate> segmentCoords = buildCoordinateList(segment, srsDimension);
if (lineStringCoords.isEmpty()) {
lineStringCoords = segmentCoords;
} else {
if (!segmentCoords.isEmpty()) {
Coordinate lastCoord = lineStringCoords.get(lineStringCoords.size() - 1);
Coordinate firstCoord = segmentCoords.get(0);
if (!firstCoord.equals2D(lastCoord)) {
throw new DatatypeFormatException("GML LineString segments do not have matching last and first coordinates: " + lineStringCoords + " - " + segmentCoords);
}
segmentCoords.remove(0);
lineStringCoords.addAll(segmentCoords);
}
}
}
CustomCoordinateSequence coordinateSequence = new CustomCoordinateSequence(dims, lineStringCoords);
return GEOMETRY_FACTORY.createLineString(coordinateSequence);
}
use of org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence in project jena by apache.
the class WKTWriter method buildWKT.
private static String buildWKT(final String geometryType, final CoordinateSequence coordSeq, final String dimensionString) {
CustomCoordinateSequence coordSequence = (CustomCoordinateSequence) coordSeq;
String wktText = convertToWKTText(coordSequence);
StringBuilder sb = new StringBuilder(geometryType);
if (!wktText.equals(" EMPTY")) {
sb.append(dimensionString);
}
sb.append(wktText);
return sb.toString();
}
use of org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence in project jena by apache.
the class GMLReaderTest method testExtractMutliCurve.
/**
* Test of extract method, of class GMLReader.
*
* @throws org.jdom2.JDOMException
* @throws java.io.IOException
*/
@Test
public void testExtractMutliCurve() throws JDOMException, IOException {
LineString[] lineStrings = new LineString[2];
lineStrings[0] = GEOMETRY_FACTORY.createLineString(new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "10 10, 20 20, 10 40"));
lineStrings[1] = GEOMETRY_FACTORY.createLineString(new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "40 40, 30 30, 40 20, 30 10"));
Geometry geometry = GEOMETRY_FACTORY.createMultiLineString(lineStrings);
GMLReader expResult = new GMLReader(geometry, 2, SRS_URI.OSGB36_CRS);
String gmlText = "<gml:MultiCurve xmlns:gml=\"http://www.opengis.net/ont/gml\" srsName=\"http://www.opengis.net/def/crs/EPSG/0/27700\"><gml:curveMember><gml:LineString srsName=\"http://www.opengis.net/def/crs/EPSG/0/27700\"><gml:posList>10 10 20 20 10 40</gml:posList></gml:LineString></gml:curveMember><gml:curveMember><gml:LineString srsName=\"http://www.opengis.net/def/crs/EPSG/0/27700\"><gml:posList>40 40 30 30 40 20 30 10</gml:posList></gml:LineString></gml:curveMember></gml:MultiCurve>";
GMLReader result = GMLReader.extract(gmlText);
//
//
assertEquals(expResult, result);
}
use of org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence in project jena by apache.
the class GMLReaderTest method testGetGeometryPoint.
/**
* Test of getGeometry method, of class GMLReader.
*/
@Test
public void testGetGeometryPoint() {
GMLReader instance = new GMLReader(GEOMETRY_FACTORY.createPoint(new CoordinateXY(11.0, 12.0)), 2);
Geometry expResult = GEOMETRY_FACTORY.createPoint(new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "11.0 12.0"));
Geometry result = instance.getGeometry();
//
//
assertEquals(expResult, result);
}
Aggregations