use of org.apache.commons.lang.NotImplementedException in project BIMserver by opensourceBIM.
the class TilingImplementation method queryOids.
@Override
public void queryOids(List<Long> oids, List<Long> oidsFiltered, long croid, EClass eClass, Tiles tiles) {
if (tiles.getTileIds().size() > 1) {
throw new NotImplementedException("Only one tile id supported in this method");
}
Set<Query<GeometryObject>> queries = new HashSet<>();
queries.add(QueryFactory.equal(CROID, croid));
if (eClass != null) {
queries.add(QueryFactory.equal(ECLASS, eClass));
}
if (tiles.getTileIds().contains(0) && tiles.getMaxDepth() == 0) {
// When we are querying TILE_ID = 0 in a context where the maxdepth = 0, we need to get all levels, basically we can omit the TILE_ID
} else {
// For every tile we load that has a level < maxdepth -> Just load the tile
// For every tile we load that has a level > maxdepth, log a message, makes no sense
// For every tile we load that has a level == maxdepth, we need to make sure to also load all tiles of lower levels (level > q < actual max depth of octree)
// TODO this code for now assumes one single tileId
Integer tileId = tiles.getTileIds().iterator().next();
int level = Octree.getLevelOfId(tileId);
if (level < tiles.getMaxDepth()) {
queries.add(QueryFactory.equal(TILE_ID, tileId));
} else if (level > tiles.getMaxDepth()) {
LOGGER.info("Not cool");
} else {
// TODO it must be possible to make this faster...
Node node = octree.getById(tileId);
Set<Integer> in = new HashSet<>();
node.traverseBreathFirst(new Traverser() {
@Override
public void traverse(Node t) {
in.add(t.getId());
}
});
queries.add(QueryFactory.in(TILE_ID, in));
}
}
if (tiles.getMaximumThreshold() != -1 && tiles.getMinimumThreshold() != -1) {
queries.add(QueryFactory.between(DENSITY, tiles.getMinimumThreshold(), false, tiles.getMaximumThreshold(), true));
} else {
if (tiles.getMaximumThreshold() != -1) {
queries.add(QueryFactory.lessThanOrEqualTo(DENSITY, tiles.getMaximumThreshold()));
}
if (tiles.getMinimumThreshold() != -1) {
queries.add(QueryFactory.greaterThan(DENSITY, tiles.getMinimumThreshold()));
}
}
Query<GeometryObject> query = null;
if (queries.size() == 1) {
query = queries.iterator().next();
} else {
query = new And<>(queries);
}
ResultSet<GeometryObject> retrieve = objects.retrieve(query, QueryFactory.queryOptions(QueryFactory.orderBy(QueryFactory.descending(ORDER)), QueryFactory.applyThresholds(QueryFactory.threshold(EngineThresholds.INDEX_ORDERING_SELECTIVITY, 1.0))));
for (GeometryObject geometryObject : retrieve) {
if (tiles.getMinimumReuseThreshold() != -1 && tiles.getMinimumReuseThreshold() <= geometryObject.getSaveableTriangles()) {
// We still have to send this object, we just need to somehow make sure the associated GeometryData is not sent
oidsFiltered.add(geometryObject.getOid());
} else {
oids.add(geometryObject.getOid());
}
}
}
Aggregations