/** * @return and {@link Optional} containing the bounds of the {@code Node} this object points to, * or {@link Optional#absent()} if the {@code Node} has no bounds */ @Override public Optional<Envelope> bounds() { return node.bounds(); }
/** * @return and {@link Optional} containing the bounds of the {@code Node} this object points to, * or {@link Optional#absent()} if the {@code Node} has no bounds */ @Override public Optional<Envelope> bounds() { return node.bounds(); }
public Node update(final ObjectId newId) { return update(newId, bounds().orNull()); }
public Node update(final ObjectId newId) { return update(newId, bounds().orNull()); }
/** * @return a {@link NodeId} whose {@link NodeId#value() value} is the node's * {@link Node#bounds() bounds} {@link Envelope} or {@code null} */ @Override public NodeId computeId(final Node node) { @Nullable Envelope bounds = node.bounds().orNull(); return new NodeId(node.getName(), bounds); }
/** * @return a {@link NodeId} whose {@link NodeId#value() value} is the node's * {@link Node#bounds() bounds} {@link Envelope} or {@code null} */ @Override public NodeId computeId(final Node node) { @Nullable Envelope bounds = node.bounds().orNull(); return new NodeId(node.getName(), bounds); }
public static String toString(@NonNull Node node) { Envelope env = node.bounds().orNull(); String bounds = env == null ? null : env.toString(); return String.format("%s[%s -> %s, type: %s, md id: %s, bounds: %s]", // node.getClass().getSimpleName(), // node.getName(), // toShortString(node.getObjectId()), // node.getType(), // (node.getMetadataId().isPresent() ? toShortString(node.getMetadataId().get()) : "NULL"), // bounds); }
private Node createNode(int intId, final @Nullable Envelope bounds) { String nodeName = String.valueOf(intId); String sid = Strings.padStart(nodeName, 40, '0'); ObjectId oid = RevObjectTestSupport.hashString(sid); checkState(bounds == null || (!bounds.isNull() && maxBounds.contains(bounds))); Node node = Node.create(nodeName, oid, ObjectId.NULL, TYPE.FEATURE, bounds, null); Envelope nodeBounds = node.bounds().orNull(); if (bounds != null) { checkState(nodeBounds.contains(bounds)); checkState(maxBounds.contains(nodeBounds)); } return node; }
private void assertNodesEqual(List<Node> l1, List<Node> l2) { assertEquals(l1, l2); for (int i = 0; i < l1.size(); i++) { Node n1 = l1.get(i); Node n2 = l2.get(i); assertEquals(n1.getExtraData(), n2.getExtraData()); assertEquals(n1.getMetadataId(), n2.getMetadataId()); assertEquals(n1.bounds(), n2.bounds()); } }
private void assertNodesEqual(List<Node> l1, List<Node> l2) { assertEquals(l1, l2); for (int i = 0; i < l1.size(); i++) { Node n1 = l1.get(i); Node n2 = l2.get(i); assertEquals(n1.getExtraData(), n2.getExtraData()); assertEquals(n1.getMetadataId(), n2.getMetadataId()); assertEquals(n1.bounds(), n2.bounds()); } }
public Node createNode(String name, @Nullable Envelope bounds) { ObjectId id = RevObjectTestSupport.hashString(name); Node n = Node.create(name, id, ObjectId.NULL, RevObject.TYPE.FEATURE, bounds); if (bounds != null && !bounds.isNull()) { Envelope float32Bounds = n.bounds().get(); Assert.assertTrue(float32Bounds.contains(bounds)); } return n; }
/** * given a list of quandrants, create a node with a bounding box that JUST fits inside */ public Node createNode(String name, Quadrant... quadrants) { Envelope nodeBounds = createBounds(quadrants); Node node = createNode(name, nodeBounds); if (!nodeBounds.contains(node.bounds().get())) { node = createPointNode(name, quadrants); } return node; }
/** * given a list of quandrants, create a node with a bounding box that JUST fits inside */ public Node createNode(String name, Quadrant... quadrants) { Envelope nodeBounds = createBounds(quadrants); Node node = createNode(name, nodeBounds); if (!nodeBounds.contains(node.bounds().get())) { node = createPointNode(name, quadrants); } return node; }
private Node createNode(int intId, final @Nullable Envelope bounds) { String nodeName = String.valueOf(intId); String sid = Strings.padStart(nodeName, 40, '0'); ObjectId oid = RevObjectTestSupport.hashString(sid); checkState(bounds == null || (!bounds.isNull() && maxBounds.contains(bounds))); Node node = RevObjectFactory.defaultInstance().createNode(nodeName, oid, ObjectId.NULL, TYPE.FEATURE, bounds, null); Envelope nodeBounds = node.bounds().orNull(); if (bounds != null) { checkState(nodeBounds.contains(bounds)); checkState(maxBounds.contains(nodeBounds)); } return node; }
public Node createNode(String name, @Nullable Envelope bounds) { ObjectId id = RevObjectTestSupport.hashString(name); Node n = RevObjectFactory.defaultInstance().createNode(name, id, ObjectId.NULL, RevObject.TYPE.FEATURE, bounds, null); if (bounds != null && !bounds.isNull()) { Envelope float32Bounds = n.bounds().get(); Assert.assertTrue(float32Bounds.contains(bounds)); } return n; }
@Test public void withinFilter() throws Exception { Envelope bounds = testNode.bounds().get(); bounds.expandBy(1); Polygon container = JTS.toGeometry(bounds); Within filter; Filter pre; Filter post; filter = (Within) toFilter(String.format("Within(the_geom, %s)", container)); pre = ff.within(ff.property("@bounds"), ff.literal(container)); post = filter; assertFilter(filter, pre, post); }
@Test public void withinFilter() throws Exception { Envelope bounds = testNode.bounds().get(); bounds.expandBy(1); Polygon container = JTS.toGeometry(bounds); Within filter; Filter pre; Filter post; filter = (Within) toFilter(String.format("Within(the_geom, %s)", container)); pre = ff.within(ff.property("@bounds"), ff.literal(container)); post = filter; assertFilter(filter, pre, post); }
@Test public void disjointFilter() throws Exception { Envelope bounds = testNode.bounds().get(); bounds.expandBy(1); Polygon container = JTS.toGeometry(bounds); Geometry containerBounds = JTS.toGeometry(container.getEnvelopeInternal()); Disjoint filter; filter = (Disjoint) toFilter(String.format("Disjoint(the_geom, %s)", container)); Filter pre = ff.intersects(ff.property("@bounds"), ff.literal(containerBounds)); Filter post = filter; assertFilter(filter, pre, post); }
@Test public void disjointFilter() throws Exception { Envelope bounds = testNode.bounds().get(); bounds.expandBy(1); Polygon container = JTS.toGeometry(bounds); Geometry containerBounds = JTS.toGeometry(container.getEnvelopeInternal()); Disjoint filter; filter = (Disjoint) toFilter(String.format("Disjoint(the_geom, %s)", container)); Filter pre = ff.intersects(ff.property("@bounds"), ff.literal(containerBounds)); Filter post = filter; assertFilter(filter, pre, post); }
@Test public void touchesFilter() throws Exception { Envelope bounds = testNode.bounds().get(); bounds.translate(-1 * bounds.getWidth(), 0); Polygon touching = JTS.toGeometry(bounds); // just a preflight test assertTrue(JTS.toGeometry(bounds).intersects(touching)); Touches filter; Filter pre; Filter post; filter = (Touches) toFilter(String.format("Touches(the_geom, %s)", touching)); pre = ff.intersects(ff.property("@bounds"), ff.literal(touching)); post = filter; assertFilter(filter, pre, post); }