use of org.bboxdb.network.server.ContinuousBoundingBoxClientQuery in project bboxdb by jnidzwetzki.
the class HandleContinuousBoundingBoxQuery method handleQuery.
@Override
public /**
* Handle a bounding box query
*/
void handleQuery(final ByteBuffer encodedPackage, final short packageSequence, final ClientConnectionHandler clientConnectionHandler) throws IOException, PackageEncodeException {
try {
if (clientConnectionHandler.getActiveQueries().containsKey(packageSequence)) {
logger.error("Query sequence {} is already known, please close old query first", packageSequence);
return;
}
final QueryBoundingBoxContinuousRequest queryRequest = QueryBoundingBoxContinuousRequest.decodeTuple(encodedPackage);
final TupleStoreName requestTable = queryRequest.getTable();
if (!QueryHelper.handleNonExstingTable(requestTable, packageSequence, clientConnectionHandler)) {
return;
}
final BoundingBox boundingBox = queryRequest.getBoundingBox();
final ClientQuery clientQuery = new ContinuousBoundingBoxClientQuery(boundingBox, clientConnectionHandler, packageSequence, requestTable);
clientConnectionHandler.getActiveQueries().put(packageSequence, clientQuery);
clientConnectionHandler.sendNextResultsForQuery(packageSequence, packageSequence);
} catch (PackageEncodeException e) {
logger.warn("Got exception while decoding package", e);
clientConnectionHandler.writeResultPackage(new ErrorResponse(packageSequence, ErrorMessages.ERROR_EXCEPTION));
}
}
Aggregations