use of org.locationtech.jts.geom.LineString in project jena by apache.
the class GeometryTransformation method transformMultiLineString.
private static MultiLineString transformMultiLineString(Geometry sourceGeometry, MathTransform transform) throws TransformException {
GeometryFactory geometryFactory = sourceGeometry.getFactory();
MultiLineString multiLineString = (MultiLineString) sourceGeometry;
int geometryNumber = multiLineString.getNumGeometries();
ArrayList<LineString> lineStrings = new ArrayList<>();
for (int i = 0; i < geometryNumber; i++) {
LineString lineString = transformLineString(multiLineString.getGeometryN(i), transform);
lineStrings.add(lineString);
}
return geometryFactory.createMultiLineString(lineStrings.toArray(new LineString[lineStrings.size()]));
}
use of org.locationtech.jts.geom.LineString in project jena by apache.
the class GeometryTransformation method transformLineString.
private static LineString transformLineString(Geometry sourceGeometry, MathTransform transform) throws TransformException {
GeometryFactory geometryFactory = sourceGeometry.getFactory();
LineString lineString = (LineString) sourceGeometry;
CoordinateSequence coordSeq = lineString.getCoordinateSequence();
CoordinateSequence transformCoordSeq = transformCoordSeq(coordSeq, transform);
return geometryFactory.createLineString(transformCoordSeq);
}
use of org.locationtech.jts.geom.LineString 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.locationtech.jts.geom.LineString in project jena by apache.
the class WKTWriterTest method testWriteGeometryCollection.
/**
* Test of write method, of class WKTWriter.
*/
@Test
public void testWriteGeometryCollection() {
Geometry[] geometries = new Geometry[2];
geometries[0] = GEOMETRY_FACTORY.createPoint(new CustomCoordinateSequence(CoordinateSequenceDimensions.XYZM, "4 6 0 1"));
geometries[1] = GEOMETRY_FACTORY.createLineString(new CustomCoordinateSequence(CoordinateSequenceDimensions.XYZM, "4 6 0 1,7 10 0 1"));
Geometry geometry = GEOMETRY_FACTORY.createGeometryCollection(geometries);
GeometryWrapper geometryWrapper = new GeometryWrapper(geometry, SRS_URI.WGS84_CRS, WKTDatatype.URI, new DimensionInfo(4, 3, 1));
String expResult = "<" + SRS_URI.WGS84_CRS + "> GEOMETRYCOLLECTION ZM(POINT ZM(4 6 0 1), LINESTRING ZM(4 6 0 1, 7 10 0 1))";
String result = WKTWriter.write(geometryWrapper);
//
//
assertEquals(expResult, result);
}
use of org.locationtech.jts.geom.LineString in project jena by apache.
the class WKTWriterTest method testWriteLineStringEmpty.
/**
* Test of writeLineStringEmpty method, of class WKTWriter.
*/
@Test
public void testWriteLineStringEmpty() {
Geometry geometry = GEOMETRY_FACTORY.createLineString();
GeometryWrapper geometryWrapper = new GeometryWrapper(geometry, SRS_URI.DEFAULT_WKT_CRS84, WKTDatatype.URI, new DimensionInfo(2, 2, 1));
String result = WKTWriter.write(geometryWrapper);
String expResult = "LINESTRING EMPTY";
//
//
assertEquals(expResult, result);
}
Aggregations