Search in sources :

Example 36 with CustomCoordinateSequence

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

the class WKTDatatypeTest method testReadGeometryCollection.

/**
 * Test of read method, of class WKTReader.
 */
@Test
public void testReadGeometryCollection() {
    String wktLiteral = "GEOMETRYCOLLECTION ZM(POINT ZM (4 6 0 1), LINESTRING ZM (4 6 0 1, 7 10 0 1))";
    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 expResult = new GeometryWrapper(geometry, SRS_URI.DEFAULT_WKT_CRS84, WKTDatatype.URI, new DimensionInfo(4, 3, 1));
    GeometryWrapper result = WKT_DATATYPE.read(wktLiteral);
    // 
    // 
    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 37 with CustomCoordinateSequence

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

the class WKTDatatypeTest method testReadPoint2.

/**
 * Test of read method, of class WKTReader.
 */
@Test
public void testReadPoint2() {
    String wktLiteral = "<http://www.opengis.net/def/crs/OGC/1.3/CRS84> POINT ZM(11.0 12.0 8.0 5.0)";
    Geometry geometry = GEOMETRY_FACTORY.createPoint(new CustomCoordinateSequence(CoordinateSequenceDimensions.XYZM, "11.0 12.0 8.0 5.0"));
    GeometryWrapper expResult = new GeometryWrapper(geometry, SRS_URI.DEFAULT_WKT_CRS84, WKTDatatype.URI, new DimensionInfo(4, 3, 0), wktLiteral);
    GeometryWrapper result = WKT_DATATYPE.read(wktLiteral);
    // 
    // 
    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 38 with CustomCoordinateSequence

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

the class WKTReaderTest method testBuildPointEmpty.

/**
 * Test of buildPointEmpty method, of class WKTReader.
 */
@Test
public void testBuildPointEmpty() {
    WKTReader instance = WKTReader.extract("POINT EMPTY");
    Geometry result = instance.getGeometry();
    CustomCoordinateSequence pointSequence = new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "");
    Geometry expResult = GEOMETRY_FACTORY.createPoint(pointSequence);
    // 
    // 
    assertEquals(expResult, result);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) CustomCoordinateSequence(org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence) Test(org.junit.Test)

Example 39 with CustomCoordinateSequence

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

the class WKTReaderTest method testBuildLineStringEmpty.

/**
 * Test of buildLineStringEmpty method, of class WKTReader.
 */
@Test
public void testBuildLineStringEmpty() {
    WKTReader instance = WKTReader.extract("LINESTRING EMPTY");
    Geometry result = instance.getGeometry();
    CustomCoordinateSequence pointSequence = new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "");
    Geometry expResult = GEOMETRY_FACTORY.createLineString(pointSequence);
    // 
    // 
    assertEquals(expResult, result);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) CustomCoordinateSequence(org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence) Test(org.junit.Test)

Example 40 with CustomCoordinateSequence

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

the class WKTReaderTest method testGetGeometryPoint.

/**
 * Test of getGeometry method, of class WKTReader.
 */
@Test
public void testGetGeometryPoint() {
    WKTReader instance = new WKTReader("point", "", "(11.0 12.0)");
    Geometry expResult = GEOMETRY_FACTORY.createPoint(new CustomCoordinateSequence(CoordinateSequenceDimensions.XY, "11.0 12.0"));
    Geometry result = instance.getGeometry();
    // 
    // 
    assertEquals(expResult, result);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) 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