/** * Expands the provided {@link Envelope} to encompass the {@code Node} this object points to. * * @param env the {@link Envelope} to expand */ @Override public void expand(Envelope env) { node.expand(env); }
/** * Expands the provided {@link Envelope} to encompass the {@code Node} this object points to. * * @param env the {@link Envelope} to expand */ @Override public void expand(Envelope env) { node.expand(env); }
/** * @param oldObject * @param newObject * @return the aggregated bounding box */ public static org.locationtech.jts.geom.Envelope aggregatedBounds(Node oldObject, Node newObject) { Envelope env = new Envelope(); if (oldObject != null) { oldObject.expand(env); } if (newObject != null) { newObject.expand(env); } return env; }
/** * @param oldObject * @param newObject * @return the aggregated bounding box */ public static com.vividsolutions.jts.geom.Envelope aggregatedBounds(Node oldObject, Node newObject) { Envelope env = new Envelope(); if (oldObject != null) { oldObject.expand(env); } if (newObject != null) { newObject.expand(env); } return env; }
protected void writeBBox(Writer w, Node node, Envelope envHelper) throws IOException { envHelper.setToNull(); node.expand(envHelper); writeEnvelope(w, envHelper); }
static BoundedSimpleFeature empty(SimpleFeatureType type, Node node, CoordinateReferenceSystem crs) { FeatureId fid = new FeatureIdImpl(node.getName()); ReferencedEnvelope env = new ReferencedEnvelope(crs); node.expand(env); return new BoundedSimpleFeature(Collections.emptyList(), type, fid, env); } }
protected void writeBBox(Writer w, Node node, Envelope envHelper) throws IOException { envHelper.setToNull(); node.expand(envHelper); writeEnvelope(w, envHelper); }
/** * @return a 3-elements boolean array where the first one indicates if at least one node has * bounds, the seconds if it has extradata map, and the third if it has a metadataId */ private boolean[] hasBoundsOrExtraData(List<Node> nodes, Envelope buff) { boolean hasBounds = false; boolean hasExtraData = false; boolean hasMetadataId = false; final int size = nodes.size(); for (int i = 0; i < size; i++) { buff.setToNull(); Node node = nodes.get(i); node.expand(buff); if (!buff.isNull()) { hasBounds = true; } Map<String, Object> extraData = node.getExtraData(); if (!extraData.isEmpty()) { hasExtraData = true; } if (node.getMetadataId().isPresent()) { hasMetadataId = true; } if (hasBounds && hasExtraData && hasMetadataId) { return new boolean[] { true, true, true }; } } return new boolean[] { hasBounds, hasExtraData, hasMetadataId }; }
public static void writeNode(Node node, DataOutput data, Envelope envBuff) { try { data.writeUTF(node.getName()); data.write(node.getObjectId().getRawValue()); data.write(node.getMetadataId().or(ObjectId.NULL).getRawValue()); int typeN = node.getType().value(); data.writeByte(typeN); envBuff.setToNull(); node.expand(envBuff); writeBoundingBox(envBuff, data); Map<String, Object> extraData = node.getExtraData(); DataStreamValueSerializerV1.INSTANCE.writeMap(extraData, data); } catch (IOException e) { throw Throwables.propagate(e); } }
public static MutableTree createFromPaths(final ObjectId rootId, final Map<String, NodeRef> entries) { List<NodeRef> refsByDepth = Lists.newArrayList(entries.values()); Collections.sort(refsByDepth, DEEPEST_LAST_COMPARATOR); Node rootNode = Node.create(ROOT, rootId, ObjectId.NULL, TYPE.TREE, null); MutableTree root = new MutableTree(rootNode); Envelope bounds = new Envelope(); for (NodeRef entry : refsByDepth) { Node node = entry.getNode(); node.expand(bounds); String parentPath = entry.getParentPath(); root.setChild(parentPath, node); } // recreate root node with the appropriate bounds rootNode = Node.create(ROOT, rootId, ObjectId.NULL, TYPE.TREE, bounds); root.setNode(rootNode); return root; }
public static void writeNode(Node node, DataOutput data, Envelope envBuff) { try { data.writeUTF(node.getName()); node.getObjectId().writeTo(data); node.getMetadataId().or(ObjectId.NULL).writeTo(data); int typeN = node.getType().value(); data.writeByte(typeN); envBuff.setToNull(); node.expand(envBuff); writeBoundingBox(envBuff, data); Map<String, Object> extraData = node.getExtraData(); DataStreamValueSerializerV1.INSTANCE.writeMap(extraData, data); } catch (IOException e) { throw new RuntimeException(e); } }
public static MutableTree createFromPaths(final ObjectId rootId, final Map<String, NodeRef> entries) { List<NodeRef> refsByDepth = Lists.newArrayList(entries.values()); Collections.sort(refsByDepth, DEEPEST_LAST_COMPARATOR); Node rootNode = RevObjectFactory.defaultInstance().createNode(ROOT, rootId, ObjectId.NULL, TYPE.TREE, null, null); MutableTree root = new MutableTree(rootNode); Envelope bounds = new Envelope(); for (NodeRef entry : refsByDepth) { Node node = entry.getNode(); node.expand(bounds); String parentPath = entry.getParentPath(); root.setChild(parentPath, node); } // recreate root node with the appropriate bounds rootNode = RevObjectFactory.defaultInstance().createNode(ROOT, rootId, ObjectId.NULL, TYPE.TREE, bounds, null); root.setNode(rootNode); return root; }
node.expand(env);
@Override protected ReferencedEnvelope getBoundsInternal(Query query) throws IOException { final Filter filter = (Filter) query.getFilter().accept(new SimplifyingFilterVisitor(), null); final CoordinateReferenceSystem crs = getSchema().getCoordinateReferenceSystem(); if (Filter.INCLUDE.equals(filter)) { NodeRef typeRef = getTypeRef(); ReferencedEnvelope bounds = new ReferencedEnvelope(crs); typeRef.getNode().expand(bounds); return bounds; } if (Filter.EXCLUDE.equals(filter)) { return ReferencedEnvelope.create(crs); } query = new Query(query); query.setPropertyNames(Query.NO_NAMES); ReferencedEnvelope bounds = new ReferencedEnvelope(crs); try (FeatureReader<SimpleFeatureType, SimpleFeature> features = getNativeReader(query, false)) { while (features.hasNext()) { bounds.expandToInclude((ReferencedEnvelope) features.next().getBounds()); } } return bounds; }
protected @Override ReferencedEnvelope getBoundsInternal(Query query) throws IOException { final Filter filter = (Filter) query.getFilter().accept(new SimplifyingFilterVisitor(), null); final CoordinateReferenceSystem crs = getSchema().getCoordinateReferenceSystem(); if (Filter.INCLUDE.equals(filter) && oldRoot == null && ChangeType.ADDED.equals(changeType())) { NodeRef typeRef = getTypeRef(); ReferencedEnvelope bounds = new ReferencedEnvelope(crs); typeRef.getNode().expand(bounds); return bounds; } if (Filter.EXCLUDE.equals(filter)) { return ReferencedEnvelope.create(crs); } query = new Query(query); query.setPropertyNames(Query.NO_NAMES); ReferencedEnvelope bounds = new ReferencedEnvelope(crs); try (FeatureReader<SimpleFeatureType, SimpleFeature> features = getNativeReader(query, false)) { while (features.hasNext()) { bounds.expandToInclude((ReferencedEnvelope) features.next().getBounds()); } } return bounds; }
private void checkTreeBounds(int size) { RevTreeBuilder b = createBuiler(); List<Node> nodes = createNodes(size); Envelope expectedBounds = new Envelope(); for (Node n : nodes) { b.put(n); n.expand(expectedBounds); } expectedBounds = Node.makePrecise(expectedBounds); RevTree tree = b.build(); assertEquals(size, tree.size()); Envelope bounds = SpatialOps.boundsOf(tree); bounds = Node.makePrecise(bounds); assertEquals(expectedBounds, bounds); }
private void checkTreeBounds(int size) { RevTreeBuilder b = createBuiler(); List<Node> nodes = createNodes(size); Envelope expectedBounds = new Envelope(); for (Node n : nodes) { b.put(n); n.expand(expectedBounds); } expectedBounds = RevObjects.makePrecise(expectedBounds); RevTree tree = b.build(); assertEquals(size, tree.size()); Envelope bounds = SpatialOps.boundsOf(tree); bounds = RevObjects.makePrecise(bounds); assertEquals(expectedBounds, bounds); }