Search in sources :

Example 26 with CustomCoordinateSequence

use of org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence 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);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) GeometryWrapper(org.apache.jena.geosparql.implementation.GeometryWrapper) DimensionInfo(org.apache.jena.geosparql.implementation.DimensionInfo) LineString(org.locationtech.jts.geom.LineString) CustomCoordinateSequence(org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence) Test(org.junit.Test)

Example 27 with CustomCoordinateSequence

use of org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence in project jena by apache.

the class WKTWriterTest method testWriteMultiPolygon2.

/**
 * Test of write method, of class WKTWriter.
 */
@Test
public void testWriteMultiPolygon2() {
    Polygon[] polygons = new Polygon[2];
    polygons[0] = GEOMETRY_FACTORY.createPolygon(new CustomCoordinateSequence(CoordinateSequenceDimensions.XYZM, "40 40 0 1, 20 45 0 1, 45 30 0 1, 40 40 0 1"));
    LinearRing shell = GEOMETRY_FACTORY.createLinearRing(new CustomCoordinateSequence(CoordinateSequenceDimensions.XYZM, "20 35 0 1, 10 30 0 1, 10 10 0 1, 30 5 0 1, 45 20 0 1, 20 35 0 1"));
    LinearRing[] holes = new LinearRing[] { GEOMETRY_FACTORY.createLinearRing(new CustomCoordinateSequence(CoordinateSequenceDimensions.XYZM, "30 20 0 1, 20 15 0 1, 20 25 0 1, 30 20 0 1")) };
    polygons[1] = GEOMETRY_FACTORY.createPolygon(shell, holes);
    Geometry geometry = GEOMETRY_FACTORY.createMultiPolygon(polygons);
    GeometryWrapper geometryWrapper = new GeometryWrapper(geometry, SRS_URI.WGS84_CRS, WKTDatatype.URI, new DimensionInfo(4, 3, 2));
    String expResult = "<" + SRS_URI.WGS84_CRS + "> MULTIPOLYGON ZM(((40 40 0 1, 20 45 0 1, 45 30 0 1, 40 40 0 1)), ((20 35 0 1, 10 30 0 1, 10 10 0 1, 30 5 0 1, 45 20 0 1, 20 35 0 1), (30 20 0 1, 20 15 0 1, 20 25 0 1, 30 20 0 1)))";
    String result = WKTWriter.write(geometryWrapper);
    // 
    // 
    assertEquals(expResult, result);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) GeometryWrapper(org.apache.jena.geosparql.implementation.GeometryWrapper) DimensionInfo(org.apache.jena.geosparql.implementation.DimensionInfo) LineString(org.locationtech.jts.geom.LineString) Polygon(org.locationtech.jts.geom.Polygon) CustomCoordinateSequence(org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence) LinearRing(org.locationtech.jts.geom.LinearRing) Test(org.junit.Test)

Example 28 with CustomCoordinateSequence

use of org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence in project jena by apache.

the class WKTWriterTest method testWritePolygon.

/**
 * Test of write method, of class WKTWriter.
 */
@Test
public void testWritePolygon() {
    Geometry geometry = GEOMETRY_FACTORY.createPolygon(new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "30 10, 40 40, 20 40, 10 20, 30 10"));
    GeometryWrapper geometryWrapper = new GeometryWrapper(geometry, SRS_URI.WGS84_CRS, WKTDatatype.URI, new DimensionInfo(2, 2, 2));
    String expResult = "<" + SRS_URI.WGS84_CRS + "> POLYGON((30 10, 40 40, 20 40, 10 20, 30 10))";
    String result = WKTWriter.write(geometryWrapper);
    // 
    // 
    assertEquals(expResult, result);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) GeometryWrapper(org.apache.jena.geosparql.implementation.GeometryWrapper) DimensionInfo(org.apache.jena.geosparql.implementation.DimensionInfo) LineString(org.locationtech.jts.geom.LineString) CustomCoordinateSequence(org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence) Test(org.junit.Test)

Example 29 with CustomCoordinateSequence

use of org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence in project jena by apache.

the class WKTWriterTest method testWriteMultiLineString.

/**
 * Test of write method, of class WKTWriter.
 */
@Test
public void testWriteMultiLineString() {
    LineString[] lineStrings = new LineString[2];
    lineStrings[0] = GEOMETRY_FACTORY.createLineString(new CustomCoordinateSequence(CoordinateSequenceDimensions.XYZM, "10 10 0 1, 20 20 0 1, 10 40 0 1"));
    lineStrings[1] = GEOMETRY_FACTORY.createLineString(new CustomCoordinateSequence(CoordinateSequenceDimensions.XYZM, "40 40 0 1, 30 30 0 1, 40 20 0 1, 30 10 0 1"));
    Geometry geometry = GEOMETRY_FACTORY.createMultiLineString(lineStrings);
    GeometryWrapper geometryWrapper = new GeometryWrapper(geometry, SRS_URI.WGS84_CRS, WKTDatatype.URI, new DimensionInfo(4, 3, 1));
    String expResult = "<" + SRS_URI.WGS84_CRS + "> MULTILINESTRING ZM((10 10 0 1, 20 20 0 1, 10 40 0 1), (40 40 0 1, 30 30 0 1, 40 20 0 1, 30 10 0 1))";
    String result = WKTWriter.write(geometryWrapper);
    // 
    // 
    assertEquals(expResult, result);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) LineString(org.locationtech.jts.geom.LineString) GeometryWrapper(org.apache.jena.geosparql.implementation.GeometryWrapper) DimensionInfo(org.apache.jena.geosparql.implementation.DimensionInfo) LineString(org.locationtech.jts.geom.LineString) CustomCoordinateSequence(org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence) Test(org.junit.Test)

Example 30 with CustomCoordinateSequence

use of org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence in project jena by apache.

the class WKTWriterTest method testWriteLineString2.

/**
 * Test of write method, of class WKTWriter.
 */
@Test
public void testWriteLineString2() {
    Geometry geometry = GEOMETRY_FACTORY.createLineString(new CustomCoordinateSequence(CoordinateSequenceDimensions.XYZM, "11.0 12.1 8.0 5.0, 3 4 6 2"));
    GeometryWrapper geometryWrapper = new GeometryWrapper(geometry, SRS_URI.WGS84_CRS, WKTDatatype.URI, new DimensionInfo(4, 3, 1));
    String expResult = "<" + SRS_URI.WGS84_CRS + "> LINESTRING ZM(11 12.1 8 5, 3 4 6 2)";
    String result = WKTWriter.write(geometryWrapper);
    // 
    // 
    assertEquals(expResult, result);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) GeometryWrapper(org.apache.jena.geosparql.implementation.GeometryWrapper) DimensionInfo(org.apache.jena.geosparql.implementation.DimensionInfo) LineString(org.locationtech.jts.geom.LineString) CustomCoordinateSequence(org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence) Test(org.junit.Test)

Aggregations

CustomCoordinateSequence (org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence)72 Geometry (org.locationtech.jts.geom.Geometry)49 Test (org.junit.Test)48 LineString (org.locationtech.jts.geom.LineString)44 DimensionInfo (org.apache.jena.geosparql.implementation.DimensionInfo)39 GeometryWrapper (org.apache.jena.geosparql.implementation.GeometryWrapper)39 LinearRing (org.locationtech.jts.geom.LinearRing)10 Polygon (org.locationtech.jts.geom.Polygon)8 Element (org.jdom2.Element)4 MultiLineString (org.locationtech.jts.geom.MultiLineString)3 MultiPoint (org.locationtech.jts.geom.MultiPoint)3 Point (org.locationtech.jts.geom.Point)3 DatatypeFormatException (org.apache.jena.datatypes.DatatypeFormatException)2 ArrayList (java.util.ArrayList)1 Coordinate (org.locationtech.jts.geom.Coordinate)1 CoordinateXY (org.locationtech.jts.geom.CoordinateXY)1