Search in sources :

Example 36 with Coordinate

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

the class GeometryWrapperTest method testGetGeometryDatatypeURI.

/**
 * Test of getGeometryDatatypeURI method, of class GeometryWrapper.
 */
@Test
public void testGetGeometryDatatypeURI() {
    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);
    String expResult = WKTDatatype.URI;
    String result = instance.getGeometryDatatypeURI();
    assertEquals(expResult, result);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) Coordinate(org.locationtech.jts.geom.Coordinate) Test(org.junit.Test)

Example 37 with Coordinate

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

the class GeometryWrapperTest method testDistanceSameSRSDifferentUnit.

/**
 * Test of distanceEuclidean same SRS_URI method, of class GeometryWrapper.
 *
 * @throws java.lang.Exception
 */
@Test
public void testDistanceSameSRSDifferentUnit() throws Exception {
    // LatLon - 51.31, -2.21
    Geometry targetGeo = GEOMETRY_FACTORY.createPoint(new Coordinate(385458, 156785));
    String targetSRSURI = SRS_URI.OSGB36_CRS;
    GeometryWrapper targetGeometry = new GeometryWrapper(targetGeo, targetSRSURI, WKTDatatype.URI, DimensionInfo.XY_POINT);
    // LatLon: 51.31, -0.74
    Geometry instanceGeo = GEOMETRY_FACTORY.createPoint(new Coordinate(487920, 157518));
    String instanceSRSURI = SRS_URI.OSGB36_CRS;
    GeometryWrapper instance = new GeometryWrapper(instanceGeo, instanceSRSURI, WKTDatatype.URI, DimensionInfo.XY_POINT);
    // SRS is in metres.
    String distanceUnitsURL = Unit_URI.RADIAN_URL;
    // Degree: 1.47
    double expResult = 0.025656;
    double result = instance.distanceEuclidean(targetGeometry, distanceUnitsURL);
    assertEquals(expResult, result, 0.001);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) Coordinate(org.locationtech.jts.geom.Coordinate) Test(org.junit.Test)

Example 38 with Coordinate

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

the class GeometryWrapperTest method testGetSrsURI.

/**
 * Test of getSrsURI method, of class GeometryWrapper.
 */
@Test
public void testGetSrsURI() {
    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);
    String expResult = SRS_URI.WGS84_CRS;
    String result = instance.getSrsURI();
    assertEquals(expResult, result);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) Coordinate(org.locationtech.jts.geom.Coordinate) Test(org.junit.Test)

Example 39 with Coordinate

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

the class GeometryWrapperTest method testGetSRID.

/**
 * Test of getSRID method, of class GeometryWrapper.
 */
@Test
public void testGetSRID() {
    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);
    String expResult = SRS_URI.WGS84_CRS;
    String result = instance.getSRID();
    assertEquals(expResult, result);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) Coordinate(org.locationtech.jts.geom.Coordinate) Test(org.junit.Test)

Example 40 with Coordinate

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

the class GeometryWrapperTest method testDistanceSameSRSSameUnit.

/**
 * Test of distanceEuclidean same SRS_URI method, of class GeometryWrapper.
 *
 * @throws java.lang.Exception
 */
@Test
public void testDistanceSameSRSSameUnit() throws Exception {
    Geometry targetGeo = GEOMETRY_FACTORY.createPoint(new Coordinate(2.0, 1.0));
    String targetSRSURI = SRS_URI.OSGB36_CRS;
    GeometryWrapper targetGeometry = new GeometryWrapper(targetGeo, targetSRSURI, WKTDatatype.URI, DimensionInfo.XY_POINT);
    Geometry instanceGeo = GEOMETRY_FACTORY.createPoint(new Coordinate(12.0, 1.0));
    String instanceSRSURI = SRS_URI.OSGB36_CRS;
    GeometryWrapper instance = new GeometryWrapper(instanceGeo, instanceSRSURI, WKTDatatype.URI, DimensionInfo.XY_POINT);
    // SRS is in metres.
    String distanceUnitsURL = Unit_URI.METRE_URL;
    double expResult = 10.0;
    double result = instance.distanceEuclidean(targetGeometry, distanceUnitsURL);
    assertEquals(expResult, result, 0.0);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) Coordinate(org.locationtech.jts.geom.Coordinate) 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