use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.
the class CLI method actionInsertTuple.
/**
* Insert a new tuple
* @param line
*/
protected void actionInsertTuple(final CommandLine line) {
final List<String> requiredArgs = Arrays.asList(CLIParameter.TABLE, CLIParameter.KEY, CLIParameter.BOUNDING_BOX, CLIParameter.VALUE);
checkRequiredArgs(requiredArgs);
final String table = line.getOptionValue(CLIParameter.TABLE);
final String key = line.getOptionValue(CLIParameter.KEY);
final String value = line.getOptionValue(CLIParameter.VALUE);
final BoundingBox boundingBox = getBoundingBoxFromArgs(line);
final Tuple tuple = new Tuple(key, boundingBox, value.getBytes());
System.out.println("Insert new tuple into table: " + table);
try {
final EmptyResultFuture future = bboxDbConnection.insertTuple(table, tuple);
pendingFutures.put(future);
pendingFutures.waitForCompletion();
} catch (BBoxDBException e) {
System.err.println("Got an error during insert: " + e);
System.exit(-1);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return;
}
}
use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.
the class CLI method buildQueryFuture.
/**
* Build the query future
* @param line
* @return
* @throws BBoxDBException
*/
protected TupleListFuture buildQueryFuture(final CommandLine line) throws BBoxDBException {
final String table = line.getOptionValue(CLIParameter.TABLE);
if (line.hasOption(CLIParameter.KEY)) {
System.out.println("Executing key query..");
final String key = line.getOptionValue(CLIParameter.KEY);
return bboxDbConnection.queryKey(table, key);
} else if (line.hasOption(CLIParameter.BOUNDING_BOX) && line.hasOption(CLIParameter.TIMESTAMP)) {
System.out.println("Executing bounding box and time query...");
final BoundingBox boundingBox = getBoundingBoxFromArgs(line);
final long timestamp = getTimestampFromArgs();
return bboxDbConnection.queryBoundingBoxAndTime(table, boundingBox, timestamp);
} else if (line.hasOption(CLIParameter.BOUNDING_BOX)) {
System.out.println("Executing bounding box query...");
final BoundingBox boundingBox = getBoundingBoxFromArgs(line);
return bboxDbConnection.queryBoundingBox(table, boundingBox);
} else if (line.hasOption(CLIParameter.TIMESTAMP)) {
System.out.println("Executing time query...");
final long timestamp = getTimestampFromArgs();
return bboxDbConnection.queryVersionTime(table, timestamp);
} else {
System.err.println("Unable to execute query with the specified parameter");
printHelpAndExit();
// Unreachable code
return null;
}
}
use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.
the class TestTupleHelper method testCreateWithDifferentSizes.
/**
* Test the creation with different sizes
*/
@Test(expected = IllegalArgumentException.class)
public void testCreateWithDifferentSizes() {
final Tuple tuple1 = new Tuple("abc", new BoundingBox(1d, 2d), "".getBytes());
final Tuple tuple2 = new Tuple("def", new BoundingBox(1d, 2d), "".getBytes());
new JoinedTuple(Arrays.asList(tuple1, tuple2), Arrays.asList("abc"));
}
use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.
the class TestTupleHelper method testConvertMultiTuple.
/**
* Test the convert method of multiple tuples
*/
@Test(expected = IllegalArgumentException.class)
public void testConvertMultiTuple() {
final Tuple tuple1 = new Tuple("abc", new BoundingBox(1d, 2d), "".getBytes());
final Tuple tuple2 = new Tuple("def", new BoundingBox(1d, 2d), "".getBytes());
final JoinedTuple joinedTuple1 = new JoinedTuple(Arrays.asList(tuple1, tuple2), Arrays.asList("abc", "def"));
joinedTuple1.convertToSingleTupleIfPossible();
}
use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.
the class RTreeTestHelper method getEntryList.
/**
* Generate a list of tuples
* @return
*/
public static List<SpatialIndexEntry> getEntryList() {
final List<SpatialIndexEntry> entryList = new ArrayList<SpatialIndexEntry>();
entryList.add(new SpatialIndexEntry(new BoundingBox(0d, 1d, 0d, 1d), 1));
entryList.add(new SpatialIndexEntry(new BoundingBox(1d, 2d, 1d, 3d), 2));
entryList.add(new SpatialIndexEntry(new BoundingBox(2d, 3d, 0d, 1d), 3));
entryList.add(new SpatialIndexEntry(new BoundingBox(3d, 4d, 3d, 7d), 4));
entryList.add(new SpatialIndexEntry(new BoundingBox(1.2d, 2.2d, 0d, 1d), 5));
entryList.add(new SpatialIndexEntry(new BoundingBox(4.6d, 5.6d, 0d, 1d), 6));
entryList.add(new SpatialIndexEntry(new BoundingBox(5.2d, 6.2d, 4d, 5d), 7));
entryList.add(new SpatialIndexEntry(new BoundingBox(5.1d, 6.1d, 0d, 1d), 8));
entryList.add(new SpatialIndexEntry(new BoundingBox(6.1d, 7.1d, 0d, 1d), 9));
entryList.add(new SpatialIndexEntry(new BoundingBox(8.1d, 9.1d, 2d, 5d), 10));
return entryList;
}
Aggregations