Search in sources :

Example 36 with NotImplementedException

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());
        }
    }
}
Also used : ResultSet(com.googlecode.cqengine.resultset.ResultSet) Set(java.util.Set) HashSet(java.util.HashSet) Query(com.googlecode.cqengine.query.Query) GeometryObject(org.bimserver.geometry.accellerator.GeometryObject) NotImplementedException(org.apache.commons.lang.NotImplementedException) Node(org.bimserver.geometry.accellerator.Node) Traverser(org.bimserver.geometry.accellerator.Traverser) HashSet(java.util.HashSet)

Aggregations

NotImplementedException (org.apache.commons.lang.NotImplementedException)36 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Path (org.apache.hadoop.fs.Path)4 ASTNode (com.intellij.lang.ASTNode)3 IElementType (com.intellij.psi.tree.IElementType)3 File (java.io.File)3 Collection (java.util.Collection)3 LinkedList (java.util.LinkedList)3 List (java.util.List)3 Entry (java.util.Map.Entry)3 NotNull (org.jetbrains.annotations.NotNull)3 LeafPsiElement (com.intellij.psi.impl.source.tree.LeafPsiElement)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Set (java.util.Set)2 TableName (org.apache.hadoop.hbase.TableName)2 DMLProgram (org.apache.sysml.parser.DMLProgram)2 XSDConstrainingFacet (org.eclipse.xsd.XSDConstrainingFacet)2