Search in sources :

Example 41 with Coordinate

use of org.locationtech.jts.geom.Coordinate in project jena by apache.

the class GeometryWrapperTest method testGetCRS.

/**
 * Test of getCRS method, of class GeometryWrapper.
 *
 * @throws org.opengis.util.FactoryException
 */
@Test
public void testGetCRS() throws FactoryException {
    Geometry geometry = GEOMETRY_FACTORY.createPoint(new Coordinate(1.0, 2.0));
    String sourceSRSURI = SRS_URI.WGS84_CRS;
    GeometryWrapper instance = new GeometryWrapper(geometry, sourceSRSURI, WKTDatatype.URI, DimensionInfo.XY_POINT);
    CoordinateReferenceSystem expResult = CRS.forCode(sourceSRSURI);
    CoordinateReferenceSystem result = instance.getCRS();
    assertEquals(expResult, result);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) Coordinate(org.locationtech.jts.geom.Coordinate) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) Test(org.junit.Test)

Example 42 with Coordinate

use of org.locationtech.jts.geom.Coordinate in project jena by apache.

the class GeometryWrapperTest method testGetXYGeometry.

/**
 * Test of getXYGeometry method, of class GeometryWrapper.
 */
@Test
public void testGetXYGeometry() {
    Geometry geometry = GEOMETRY_FACTORY.createPoint(new Coordinate(1.0, 2.0));
    String sourceSRSURI = SRS_URI.WGS84_CRS;
    GeometryWrapper instance = new GeometryWrapper(geometry, sourceSRSURI, WKTDatatype.URI, DimensionInfo.XY_POINT);
    // Expect the coordinates to be reversed as JTS is x,y and WGS84 is y,x
    Geometry expResult = GEOMETRY_FACTORY.createPoint(new Coordinate(2.0, 1.0));
    Geometry result = instance.getXYGeometry();
    assertEquals(expResult, result);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) Coordinate(org.locationtech.jts.geom.Coordinate) Test(org.junit.Test)

Example 43 with Coordinate

use of org.locationtech.jts.geom.Coordinate in project jena by apache.

the class GeometryWrapperTest method testGetParsingGeometry.

/**
 * Test of getParsingGeometry method, of class GeometryWrapper.
 */
@Test
public void testGetParsingGeometry() {
    Geometry geometry = GEOMETRY_FACTORY.createPoint(new Coordinate(1.0, 2.0));
    String sourceSRSURI = SRS_URI.WGS84_CRS;
    GeometryWrapper instance = new GeometryWrapper(geometry, sourceSRSURI, WKTDatatype.URI, DimensionInfo.XY_POINT);
    // Expect coordinates to be same as supplied.
    Geometry expResult = GEOMETRY_FACTORY.createPoint(new Coordinate(1.0, 2.0));
    Geometry result = instance.getParsingGeometry();
    assertEquals(expResult, result);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) Coordinate(org.locationtech.jts.geom.Coordinate) Test(org.junit.Test)

Example 44 with Coordinate

use of org.locationtech.jts.geom.Coordinate in project jena by apache.

the class WKTDatatypeTest method testParseNoSRSNotEqual.

/**
 * Test of parse method, of class WKTDatatype.
 */
@Test
public void testParseNoSRSNotEqual() {
    String lexicalForm = "POINT(-83.38 33.95)";
    GeometryWrapper result = WKT_DATATYPE.parse(lexicalForm);
    Coordinate coord = new Coordinate(-88.38, 33.95);
    Point expGeometry = GEOMETRY_FACTORY.createPoint(coord);
    String expSRSURI = SRS_URI.DEFAULT_WKT_CRS84;
    DimensionInfo dimensionInfo = new DimensionInfo(2, 2, 0);
    GeometryWrapper expResult = new GeometryWrapper(expGeometry, expSRSURI, WKTDatatype.URI, dimensionInfo);
    // 
    // 
    assertThat(expResult, not(result));
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) GeometryWrapper(org.apache.jena.geosparql.implementation.GeometryWrapper) DimensionInfo(org.apache.jena.geosparql.implementation.DimensionInfo) LineString(org.locationtech.jts.geom.LineString) Point(org.locationtech.jts.geom.Point) Test(org.junit.Test)

Example 45 with Coordinate

use of org.locationtech.jts.geom.Coordinate in project jena by apache.

the class WKTDatatypeTest method testParseSRS.

/**
 * Test of parse method, of class WKTDatatype.
 */
@Test
public void testParseSRS() {
    String lexicalForm = "<http://www.opengis.net/def/crs/EPSG/0/4326> POINT(33.95 -88.38)";
    GeometryWrapper result = WKT_DATATYPE.parse(lexicalForm);
    Coordinate coord = new Coordinate(33.95, -88.38);
    Point expGeometry = GEOMETRY_FACTORY.createPoint(coord);
    String expSRSURI = "http://www.opengis.net/def/crs/EPSG/0/4326";
    DimensionInfo dimensionInfo = new DimensionInfo(2, 2, 0);
    GeometryWrapper expResult = new GeometryWrapper(expGeometry, expSRSURI, WKTDatatype.URI, dimensionInfo);
    // 
    // 
    assertEquals(expResult, result);
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) GeometryWrapper(org.apache.jena.geosparql.implementation.GeometryWrapper) DimensionInfo(org.apache.jena.geosparql.implementation.DimensionInfo) LineString(org.locationtech.jts.geom.LineString) Point(org.locationtech.jts.geom.Point) Test(org.junit.Test)

Aggregations

Coordinate (org.locationtech.jts.geom.Coordinate)330 Test (org.junit.Test)135 Geometry (org.locationtech.jts.geom.Geometry)64 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)62 LineString (org.locationtech.jts.geom.LineString)54 Point (org.locationtech.jts.geom.Point)51 Polygon (org.locationtech.jts.geom.Polygon)44 LinearRing (org.locationtech.jts.geom.LinearRing)42 AbstractArcTest (eu.esdihumboldt.util.geometry.interpolation.AbstractArcTest)37 ArcByCenterPoint (eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint)32 ArrayList (java.util.ArrayList)31 Test (org.junit.jupiter.api.Test)26 MultiPolygon (org.locationtech.jts.geom.MultiPolygon)25 Arc (eu.esdihumboldt.util.geometry.interpolation.model.Arc)20 ArcByPointsImpl (eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByPointsImpl)17 ArcByCenterPointImpl (eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByCenterPointImpl)16 GeometryWrapper (org.apache.jena.geosparql.implementation.GeometryWrapper)15 MultiPoint (org.locationtech.jts.geom.MultiPoint)15 ArcByPoints (eu.esdihumboldt.util.geometry.interpolation.model.ArcByPoints)14 HashMap (java.util.HashMap)13