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;
}
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);
}
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);
}
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);
}
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());
}
Aggregations