Search in sources :

Example 1 with CoordinateXY

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

the class DimensionInfoTest method testFind_Coordinate_Geometry.

/**
 * Test of find method, of class DimensionInfo.
 */
@Test
public void testFind_Coordinate_Geometry() {
    Coordinate coordinate = new CoordinateXY(1.0, 2.0);
    GeometryFactory factory = new GeometryFactory();
    Geometry geometry = factory.createPoint(coordinate);
    DimensionInfo expResult = DimensionInfo.XY_POINT;
    DimensionInfo result = DimensionInfo.find(coordinate, geometry);
    assertEquals(expResult, result);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Coordinate(org.locationtech.jts.geom.Coordinate) CoordinateXY(org.locationtech.jts.geom.CoordinateXY) Test(org.junit.Test)

Example 2 with CoordinateXY

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

the class DimensionInfoTest method testFind_List_Geometry.

/**
 * Test of find method, of class DimensionInfo.
 */
@Test
public void testFind_List_Geometry() {
    List<Coordinate> coordinates = Arrays.asList(new CoordinateXY(1.0, 2.0), new CoordinateXY(10.0, 20.0));
    GeometryFactory factory = new GeometryFactory();
    Geometry geometry = factory.createLineString(coordinates.toArray(new Coordinate[coordinates.size()]));
    DimensionInfo expResult = DimensionInfo.XY_LINESTRING;
    DimensionInfo result = DimensionInfo.find(coordinates, geometry);
    assertEquals(expResult, result);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Coordinate(org.locationtech.jts.geom.Coordinate) CoordinateXY(org.locationtech.jts.geom.CoordinateXY) Test(org.junit.Test)

Example 3 with CoordinateXY

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

the class GMLReaderTest method testExtractArc.

/**
 * Test of extract method, of class GMLReader.
 *
 * @throws org.jdom2.JDOMException
 * @throws java.io.IOException
 */
@Test
public void testExtractArc() throws JDOMException, IOException {
    GeometricShapeFactory shapeFactory = new GeometricShapeFactory(GEOMETRY_FACTORY);
    shapeFactory.setCentre(new CoordinateXY(0, 0));
    shapeFactory.setWidth(10);
    // Semi-cicle centred around 0,0 and radius 5.
    Geometry arc = shapeFactory.createArc(0, Math.PI);
    GMLReader expResult = new GMLReader(arc, 2, SRS_URI.OSGB36_CRS);
    String gmlText = "<gml:Curve xmlns:gml=\"http://www.opengis.net/ont/gml\" srsName=\"http://www.opengis.net/def/crs/EPSG/0/27700\"><gml:segments><gml:Arc><gml:posList>5 0 0 5 -5 0</gml:posList></gml:Arc></gml:segments></gml:Curve>";
    GMLReader result = GMLReader.extract(gmlText);
    // 
    // 
    assertEquals(expResult, result);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) GeometricShapeFactory(org.locationtech.jts.util.GeometricShapeFactory) CoordinateXY(org.locationtech.jts.geom.CoordinateXY) LineString(org.locationtech.jts.geom.LineString) Test(org.junit.Test)

Example 4 with CoordinateXY

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

the class GMLReaderTest method testGetGeometryPoint.

/**
 * Test of getGeometry method, of class GMLReader.
 */
@Test
public void testGetGeometryPoint() {
    GMLReader instance = new GMLReader(GEOMETRY_FACTORY.createPoint(new CoordinateXY(11.0, 12.0)), 2);
    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) CoordinateXY(org.locationtech.jts.geom.CoordinateXY) CustomCoordinateSequence(org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence) Test(org.junit.Test)

Example 5 with CoordinateXY

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

the class GMLReaderTest method testExtractCircle.

/**
 * Test of extract method, of class GMLReader.
 *
 * @throws org.jdom2.JDOMException
 * @throws java.io.IOException
 */
@Test
public void testExtractCircle() throws JDOMException, IOException {
    GeometricShapeFactory shapeFactory = new GeometricShapeFactory(GEOMETRY_FACTORY);
    shapeFactory.setCentre(new CoordinateXY(0, 0));
    shapeFactory.setWidth(10);
    Geometry circle = shapeFactory.createCircle().getExteriorRing();
    GMLReader expResult = new GMLReader(circle, 2, SRS_URI.OSGB36_CRS);
    String gmlText = "<gml:Curve xmlns:gml=\"http://www.opengis.net/ont/gml\" srsName=\"http://www.opengis.net/def/crs/EPSG/0/27700\"><gml:segments><gml:Circle><gml:posList>5 0 0 5 -5 0</gml:posList></gml:Circle></gml:segments></gml:Curve>";
    GMLReader result = GMLReader.extract(gmlText);
    // 
    // 
    assertEquals(expResult, result);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) GeometricShapeFactory(org.locationtech.jts.util.GeometricShapeFactory) CoordinateXY(org.locationtech.jts.geom.CoordinateXY) LineString(org.locationtech.jts.geom.LineString) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 CoordinateXY (org.locationtech.jts.geom.CoordinateXY)8 Geometry (org.locationtech.jts.geom.Geometry)5 Coordinate (org.locationtech.jts.geom.Coordinate)3 LineString (org.locationtech.jts.geom.LineString)3 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)2 GeometricShapeFactory (org.locationtech.jts.util.GeometricShapeFactory)2 DimensionInfo (org.apache.jena.geosparql.implementation.DimensionInfo)1 CustomCoordinateSequence (org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence)1