use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class RectanglePredicateSyntheticTest method newAngle.
public Geometry newAngle(final Point base, final double size, final int quadrant) {
final int[][] factor = { { 1, 0 }, { 0, 1 }, { -1, 0 }, { 0, -1 } };
final int xFac = factor[quadrant][0];
final int yFac = factor[quadrant][1];
final Point p0 = new PointDoubleXY(base.getX() + xFac * size, base.getY() + yFac * size);
final Point p2 = new PointDoubleXY(base.getX() + yFac * size, base.getY() + -xFac * size);
return this.fact.lineString(new Point[] { p0, base, p2 });
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class RectanglePredicateSyntheticTest method newTestGeometries.
public List<Geometry> newTestGeometries(final BoundingBox env, final double inc, final double size) {
final List<Geometry> testGeoms = new ArrayList<>();
for (double y = env.getMinY(); y <= env.getMaxY(); y += inc) {
for (double x = env.getMinX(); x <= env.getMaxX(); x += inc) {
final Point base = new PointDoubleXY(x, y);
testGeoms.add(newAngle(base, size, 0));
testGeoms.add(newAngle(base, size, 1));
testGeoms.add(newAngle(base, size, 2));
testGeoms.add(newAngle(base, size, 3));
}
}
return testGeoms;
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class STRtreeTest method testQuery.
public void testQuery() throws Throwable {
final ArrayList geometries = new ArrayList();
geometries.add(this.factory.lineString(new Point[] { new PointDoubleXY(0, 0), new PointDoubleXY(10, 10) }));
geometries.add(this.factory.lineString(new Point[] { new PointDoubleXY(20, 20), new PointDoubleXY(30, 30) }));
geometries.add(this.factory.lineString(new Point[] { new PointDoubleXY(20, 20), new PointDoubleXY(30, 30) }));
final STRtreeDemo.TestTree t = new STRtreeDemo.TestTree(4);
for (final Iterator i = geometries.iterator(); i.hasNext(); ) {
final Geometry g = (Geometry) i.next();
t.insertItem(g.getBoundingBox(), new Object());
}
t.build();
try {
assertEquals(1, t.getItems(new BoundingBoxDoubleXY(5, 5, 6, 6)).size());
assertEquals(0, t.getItems(new BoundingBoxDoubleXY(20, 0, 30, 10)).size());
assertEquals(2, t.getItems(new BoundingBoxDoubleXY(25, 25, 26, 26)).size());
assertEquals(3, t.getItems(new BoundingBoxDoubleXY(0, 0, 100, 100)).size());
} catch (final Throwable x) {
STRtreeDemo.printSourceData(geometries, System.out);
STRtreeDemo.printLevels(t, System.out);
throw x;
}
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class SegmentPointComparatorFullTest method computePoint.
private Point computePoint(final LineSegment seg, final double dist) {
final double dx = seg.getP1().getX() - seg.getP0().getX();
final double dy = seg.getP1().getY() - seg.getP0().getY();
final double len = seg.getLength();
final Point pt = new PointDoubleXY(Doubles.makePrecise(1.0, dist * dx / len), Doubles.makePrecise(1.0, dist * dy / len));
return pt;
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class IsValidTest method testNaNCoordinate.
public void testNaNCoordinate() throws Exception {
final Point badCoord = new PointDoubleXY(1.0, Double.NaN);
final Point[] pts = { new PointDoubleXY(0.0, 0.0), badCoord };
final Geometry line = this.geometryFactory.lineString(pts);
final IsValidOp isValidOp = new IsValidOp(line);
final boolean valid = isValidOp.isValid();
final GeometryValidationError err = isValidOp.getValidationError();
final Point errCoord = err.getErrorPoint();
assertTrue(err instanceof CoordinateNaNError);
assertTrue(Double.isNaN(errCoord.getY()));
assertEquals(false, valid);
}
Aggregations