use of com.vividsolutions.jts.geom.Envelope in project GeoGig by boundlessgeo.
the class RevTreeBuilderTest method node.
/**
* @return a feature node named {@code i}, with
* {@code id = ObjectId.forString(String.valueOf(i))}, null metadata id, and
* {@code bounds = [i, i+1, i, i+1]}
*/
private static Node node(int i) {
String key = String.valueOf(i);
ObjectId oid = ObjectId.forString(key);
Envelope bounds = new Envelope(i, i + 1, i, i + 1);
Node node = Node.create(key, oid, ObjectId.NULL, TYPE.FEATURE, bounds);
return node;
}
use of com.vividsolutions.jts.geom.Envelope in project GeoGig by boundlessgeo.
the class RevTreeBuilderPerformanceTest method createNode.
private static Node createNode(int i) {
byte[] rawID = FAKE_ID.getRawValue();
String key = "Feature." + i;
ObjectId id = new ObjectId(rawID);
Envelope env = new Envelope(0, 0, i, i);
Node ref = Node.create(key, id, FAKE_ID, TYPE.FEATURE, env);
return ref;
}
use of com.vividsolutions.jts.geom.Envelope in project GeoGig by boundlessgeo.
the class ResponseWriter method writeTree.
public void writeTree(RevTree tree, String tag) throws XMLStreamException {
out.writeStartElement(tag);
writeElement("id", tree.getId().toString());
writeElement("size", Long.toString(tree.size()));
writeElement("numtrees", Integer.toString(tree.numTrees()));
if (tree.trees().isPresent()) {
ImmutableList<Node> trees = tree.trees().get();
for (Node ref : trees) {
writeNode(ref, "tree");
}
}
if (tree.features().isPresent()) {
ImmutableList<Node> features = tree.features().get();
for (Node ref : features) {
writeNode(ref, "feature");
}
} else if (tree.buckets().isPresent()) {
Map<Integer, Bucket> buckets = tree.buckets().get();
for (Entry<Integer, Bucket> entry : buckets.entrySet()) {
Integer bucketIndex = entry.getKey();
Bucket bucket = entry.getValue();
out.writeStartElement("bucket");
writeElement("bucketindex", bucketIndex.toString());
writeElement("bucketid", bucket.id().toString());
Envelope env = new Envelope();
env.setToNull();
bucket.expand(env);
out.writeStartElement("bbox");
writeElement("minx", Double.toString(env.getMinX()));
writeElement("maxx", Double.toString(env.getMaxX()));
writeElement("miny", Double.toString(env.getMinY()));
writeElement("maxy", Double.toString(env.getMaxY()));
out.writeEndElement();
out.writeEndElement();
}
}
out.writeEndElement();
}
use of com.vividsolutions.jts.geom.Envelope in project GeoGig by boundlessgeo.
the class WorkingTreeInsertHelper method findOrCreateTree.
private NodeRef findOrCreateTree(final String treePath, final FeatureType type) {
RevTree tree = context.command(FindOrCreateSubtree.class).setChildPath(treePath).setIndex(true).setParent(workHead).setParentPath(NodeRef.ROOT).call();
ObjectId metadataId = ObjectId.NULL;
if (type != null) {
RevFeatureType revFeatureType = RevFeatureTypeImpl.build(type);
if (tree.isEmpty()) {
indexDatabase.put(revFeatureType);
}
metadataId = revFeatureType.getId();
}
Envelope bounds = SpatialOps.boundsOf(tree);
Node node = Node.create(NodeRef.nodeFromPath(treePath), tree.getId(), metadataId, TYPE.TREE, bounds);
String parentPath = NodeRef.parentPath(treePath);
return new NodeRef(node, parentPath, ObjectId.NULL);
}
use of com.vividsolutions.jts.geom.Envelope in project GeoGig by boundlessgeo.
the class FormatCommonV2 method readNode.
public static Node readNode(DataInput in) throws IOException {
final int typeAndMasks = in.readByte() & 0xFF;
final int nodeType = typeAndMasks & TYPE_READ_MASK;
final int boundsMask = typeAndMasks & BOUNDS_READ_MASK;
final int metadataMask = typeAndMasks & METADATA_READ_MASK;
final RevObject.TYPE contentType = RevObject.TYPE.valueOf(nodeType);
final String name = in.readUTF();
final ObjectId objectId = readObjectId(in);
ObjectId metadataId = ObjectId.NULL;
if (metadataMask == METADATA_PRESENT_MASK) {
metadataId = readObjectId(in);
}
@Nullable final Envelope bbox;
if (boundsMask == BOUNDS_NULL_MASK) {
bbox = null;
} else if (boundsMask == BOUNDS_POINT_MASK) {
bbox = readPointBoundingBox(in);
} else if (boundsMask == BOUNDS_BOX2D_MASK) {
bbox = readBoundingBox(in);
} else {
throw new IllegalStateException(String.format("Illegal bounds mask: %s, expected one of %s, %s, %s", toBinaryString(boundsMask), toBinaryString(BOUNDS_NULL_MASK), toBinaryString(BOUNDS_POINT_MASK), toBinaryString(BOUNDS_BOX2D_MASK)));
}
final Node node;
node = Node.create(name, objectId, metadataId, contentType, bbox);
return node;
}
Aggregations