use of com.revolsys.geometry.model.impl.BoundingBoxDoubleXY 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.BoundingBoxDoubleXY in project com.revolsys.open by revolsys.
the class KdTreeTest method testSinglePoint.
public void testSinglePoint() {
final KdTree index = new KdTree(GeometryFactory.fixed2d(0, 1000, 1000));
final KdNode node1 = index.insertPoint(new PointDouble(1, 1));
final KdNode node2 = index.insertPoint(new PointDouble(1, 1));
assertTrue("Inserting 2 identical points should create one node", node1 == node2);
final BoundingBox queryEnv = new BoundingBoxDoubleXY(0, 0, 10, 10);
final List result = index.getItems(queryEnv);
assertTrue(result.size() == 1);
final KdNode node = (KdNode) result.get(0);
assertTrue(node.getCount() == 2);
assertTrue(node.isRepeated());
}
use of com.revolsys.geometry.model.impl.BoundingBoxDoubleXY in project com.revolsys.open by revolsys.
the class EpsgCoordinateSystems method loadArea.
private static void loadArea() {
try (ChannelReader reader = newChannelReader("area")) {
while (true) {
final int code = reader.getInt();
final String name = reader.getStringUtf8ByteCount();
final double minX = reader.getDouble();
final double minY = reader.getDouble();
final double maxX = reader.getDouble();
final double maxY = reader.getDouble();
final boolean deprecated = readBoolean(reader);
final Authority authority = new EpsgAuthority(code);
BoundingBox boundingBox;
if (Double.isFinite(minX) || Double.isFinite(minX) || Double.isFinite(minX) || Double.isFinite(minX)) {
boundingBox = new BoundingBoxDoubleXY(minX, minY, maxX, maxY);
} else {
boundingBox = BoundingBox.empty();
}
final Area area = new Area(name, boundingBox, authority, deprecated);
AREA_BY_ID.put(code, area);
}
} catch (final NoSuchResourceException e) {
} catch (final WrappedException e) {
if (Exceptions.isException(e, EOFException.class)) {
} else {
throw e;
}
}
}
use of com.revolsys.geometry.model.impl.BoundingBoxDoubleXY in project com.revolsys.open by revolsys.
the class MCPointInRing method isInside.
@Override
public boolean isInside(final Point pt) {
this.crossings = 0;
// test all segments intersected by ray from pt in positive x direction
final double y = pt.getY();
final BoundingBox rayEnv = new BoundingBoxDoubleXY(-Double.MAX_VALUE, y, Double.MAX_VALUE, y);
this.interval.min = y;
this.interval.max = y;
final List segs = this.tree.query(this.interval);
// System.out.println("query size = " + segs.size());
final MCSelecter mcSelecter = new MCSelecter(pt);
for (final Iterator i = segs.iterator(); i.hasNext(); ) {
final MonotoneChain mc = (MonotoneChain) i.next();
testMonotoneChain(rayEnv, mcSelecter, mc);
}
/*
* p is inside if number of crossings is odd.
*/
if (this.crossings % 2 == 1) {
return true;
}
return false;
}
use of com.revolsys.geometry.model.impl.BoundingBoxDoubleXY in project com.revolsys.open by revolsys.
the class GeometricShapeBuilder method getSquareExtent.
public BoundingBox getSquareExtent() {
final double radius = getRadius();
final Point centre = getCentre();
return new BoundingBoxDoubleXY(centre.getX() - radius, centre.getY() - radius, centre.getX() + radius, centre.getY() + radius);
}
Aggregations