Search in sources :

Example 46 with Coordinate

use of org.locationtech.jts.geom.Coordinate in project hale by halestudio.

the class AbstractArcTest method createArcShape.

/**
 * Create an Arc AWT shape from a given arc.
 *
 * @param arc the arc
 * @param paintSettings the paint settings for coordinate conversion
 * @return the arc shape
 */
protected Arc2D createArcShape(Arc arc, PaintSettings paintSettings) {
    ArcByCenterPoint a = arc.toArcByCenterPoint();
    // FIXME probably not the right position
    Coordinate center = paintSettings.convertPoint(a.getCenterPoint());
    double radius = a.getRadius() * paintSettings.getScaleFactor();
    double startAngle = a.getStartAngle().getDegrees();
    double angleExtent = a.getAngleBetween().getDegrees();
    Arc2D.Double arcShape = new Arc2D.Double();
    arcShape.setArcByCenter(center.x, center.y, radius, startAngle, angleExtent, Arc2D.OPEN);
    return arcShape;
}
Also used : ArcByCenterPoint(eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint) Coordinate(org.locationtech.jts.geom.Coordinate) Arc2D(java.awt.geom.Arc2D)

Example 47 with Coordinate

use of org.locationtech.jts.geom.Coordinate in project hale by halestudio.

the class GridUtilTest method testQ1.

@Test
public void testQ1() {
    Coordinate coord = new Coordinate(0.1, 0.1);
    Coordinate moved = testMoveToGrid(coord, 0.1);
    assertTrue(moved.x > 0.1);
    assertTrue(moved.x < 0.2);
    assertTrue(moved.y > 0.1);
    assertTrue(moved.y < 0.2);
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) Test(org.junit.Test)

Example 48 with Coordinate

use of org.locationtech.jts.geom.Coordinate in project hale by halestudio.

the class GridUtilTest method testQ3.

@Test
public void testQ3() {
    Coordinate coord = new Coordinate(-0.1, -0.1);
    Coordinate moved = testMoveToGrid(coord, 0.1);
    assertTrue(moved.x < -0.1);
    assertTrue(moved.x > -0.2);
    assertTrue(moved.y < -0.1);
    assertTrue(moved.y > -0.2);
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) Test(org.junit.Test)

Example 49 with Coordinate

use of org.locationtech.jts.geom.Coordinate in project hale by halestudio.

the class GridUtilTest method testOrigin.

@Test
public void testOrigin() {
    Coordinate coord = new Coordinate(0, 0);
    Coordinate moved = testMoveToGrid(coord, 0.1);
    // point should be the same
    assertEqualsCoord(coord, moved);
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) Test(org.junit.Test)

Example 50 with Coordinate

use of org.locationtech.jts.geom.Coordinate in project hale by halestudio.

the class ArcByPointsImplTest method testNotOrigin.

@Test
public void testNotOrigin() throws IOException {
    ArcByPoints arc = new ArcByPointsImpl(new Coordinate(-2, 1), new Coordinate(-1, 2), new Coordinate(0, 1));
    drawArcWithMarkers(arc);
    assertFalse(arc.isCircle());
    assertFalse(InterpolationUtil.isStraightLine(arc));
    ArcByCenterPoint converted = arc.toArcByCenterPoint();
    assertEqualsCoord(new Coordinate(-1, 1), converted.getCenterPoint());
    assertEquals(1.0, converted.getRadius(), 1e-10);
    assertEquals(Angle.fromDegrees(180), converted.getStartAngle());
    assertEquals(Angle.fromDegrees(0), converted.getEndAngle());
    assertEquals(Angle.fromDegrees(-180), converted.getAngleBetween());
    assertTrue(converted.isClockwise());
}
Also used : ArcByPoints(eu.esdihumboldt.util.geometry.interpolation.model.ArcByPoints) ArcByCenterPoint(eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint) Coordinate(org.locationtech.jts.geom.Coordinate) AbstractArcTest(eu.esdihumboldt.util.geometry.interpolation.AbstractArcTest) Test(org.junit.Test)

Aggregations

Coordinate (org.locationtech.jts.geom.Coordinate)348 Test (org.junit.Test)145 Geometry (org.locationtech.jts.geom.Geometry)69 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)65 LineString (org.locationtech.jts.geom.LineString)57 Point (org.locationtech.jts.geom.Point)57 Polygon (org.locationtech.jts.geom.Polygon)47 LinearRing (org.locationtech.jts.geom.LinearRing)45 AbstractArcTest (eu.esdihumboldt.util.geometry.interpolation.AbstractArcTest)37 ArcByCenterPoint (eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint)32 ArrayList (java.util.ArrayList)32 MultiPolygon (org.locationtech.jts.geom.MultiPolygon)27 Test (org.junit.jupiter.api.Test)26 Arc (eu.esdihumboldt.util.geometry.interpolation.model.Arc)20 MultiPoint (org.locationtech.jts.geom.MultiPoint)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 ArcByPoints (eu.esdihumboldt.util.geometry.interpolation.model.ArcByPoints)14 HashMap (java.util.HashMap)13