use of org.locationtech.geowave.service.grpc.protobuf.VectorStoreParametersProtos in project geowave by locationtech.
the class GeoWaveGrpcTestClient method spatialQuery.
public ArrayList<FeatureProtos> spatialQuery() throws UnsupportedEncodingException {
LOGGER.info("Performing Spatial Query...");
final VectorStoreParametersProtos baseParams = VectorStoreParametersProtos.newBuilder().setStoreName(GeoWaveGrpcTestUtils.storeName).setTypeName(GeoWaveGrpcTestUtils.typeName).setIndexName(GeoWaveGrpcTestUtils.indexName).build();
final SpatialQueryParametersProtos request = SpatialQueryParametersProtos.newBuilder().setBaseParams(baseParams).setGeometry(copyFrom(GeoWaveGrpcTestUtils.wkbSpatialQuery)).build();
Iterator<FeatureProtos> features;
final ArrayList<FeatureProtos> feature_list = new ArrayList<>();
features = vectorBlockingStub.spatialQuery(request);
// iterate over features
for (int i = 1; features.hasNext(); i++) {
final FeatureProtos feature = features.next();
feature_list.add(feature);
}
return feature_list;
}
use of org.locationtech.geowave.service.grpc.protobuf.VectorStoreParametersProtos in project geowave by locationtech.
the class GeoWaveGrpcTestClient method cqlQuery.
public ArrayList<FeatureProtos> cqlQuery() throws UnsupportedEncodingException {
LOGGER.info("Performing CQL Query...");
final VectorStoreParametersProtos baseParams = VectorStoreParametersProtos.newBuilder().setStoreName(GeoWaveGrpcTestUtils.storeName).setTypeName(GeoWaveGrpcTestUtils.typeName).setIndexName(GeoWaveGrpcTestUtils.indexName).build();
final CQLQueryParametersProtos request = CQLQueryParametersProtos.newBuilder().setBaseParams(baseParams).setCql(GeoWaveGrpcTestUtils.cqlSpatialQuery).build();
Iterator<FeatureProtos> features;
final ArrayList<FeatureProtos> feature_list = new ArrayList<>();
features = vectorBlockingStub.cqlQuery(request);
// iterate over features
for (int i = 1; features.hasNext(); i++) {
final FeatureProtos feature = features.next();
feature_list.add(feature);
}
return feature_list;
}
use of org.locationtech.geowave.service.grpc.protobuf.VectorStoreParametersProtos in project geowave by locationtech.
the class GeoWaveGrpcTestClient method vectorIngest.
// Vector Service Methods
public void vectorIngest(final int minLat, final int maxLat, final int minLon, final int maxLon, final int latStepDegs, final int lonStepDegs) throws InterruptedException, UnsupportedEncodingException, ParseException {
LOGGER.info("Performing Vector Ingest...");
final VectorStoreParametersProtos baseParams = VectorStoreParametersProtos.newBuilder().setStoreName(GeoWaveGrpcTestUtils.storeName).setTypeName(GeoWaveGrpcTestUtils.typeName).setIndexName(GeoWaveGrpcTestUtils.indexName).build();
final CountDownLatch finishLatch = new CountDownLatch(1);
final StreamObserver<StringResponseProtos> responseObserver = new StreamObserver<StringResponseProtos>() {
@Override
public void onNext(final StringResponseProtos value) {
try {
numFeaturesProcessed = Integer.parseInt(value.getResponseValue());
} catch (final NumberFormatException e) {
}
LOGGER.info(value.getResponseValue());
}
@Override
public void onError(final Throwable t) {
LOGGER.error("Error: Vector Ingest failed.", t);
finishLatch.countDown();
}
@Override
public void onCompleted() {
LOGGER.info("Finished Vector Ingest...");
finishLatch.countDown();
}
};
final StreamObserver<VectorIngestParametersProtos> requestObserver = vectorAsyncStub.vectorIngest(responseObserver);
// Build up and add features to the request here...
final VectorIngestParametersProtos.Builder requestBuilder = VectorIngestParametersProtos.newBuilder();
final FeatureAttributeProtos.Builder attBuilder = FeatureAttributeProtos.newBuilder();
for (int longitude = minLon; longitude <= maxLon; longitude += lonStepDegs) {
for (int latitude = minLat; latitude <= maxLat; latitude += latStepDegs) {
attBuilder.setValGeometry(copyFrom(new WKBWriter().write(GeometryUtils.GEOMETRY_FACTORY.createPoint(new Coordinate(longitude, latitude)))));
requestBuilder.putFeature("geometry", attBuilder.build());
final TimeZone tz = TimeZone.getTimeZone("UTC");
// Quoted "Z" to
final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
// indicate UTC,
// no timezone offset
df.setTimeZone(tz);
attBuilder.setValDate(Timestamps.fromMillis((df.parse(GeoWaveGrpcTestUtils.temporalQueryStartTime).getTime() + df.parse(GeoWaveGrpcTestUtils.temporalQueryEndTime).getTime()) / 2));
requestBuilder.putFeature("TimeStamp", attBuilder.build());
attBuilder.setValDouble(latitude);
requestBuilder.putFeature("Latitude", attBuilder.build());
attBuilder.setValDouble(longitude);
requestBuilder.putFeature("Longitude", attBuilder.build());
final VectorIngestParametersProtos params = requestBuilder.setBaseParams(baseParams).build();
requestObserver.onNext(params);
if (finishLatch.getCount() == 0) {
// be thrown away.
return;
}
}
}
// Mark the end of requests
requestObserver.onCompleted();
// Receiving happens asynchronously
if (!finishLatch.await(15, TimeUnit.MINUTES)) {
LOGGER.warn("Vector Ingest can not finish within 5 minutes");
}
}
use of org.locationtech.geowave.service.grpc.protobuf.VectorStoreParametersProtos in project geowave by locationtech.
the class GeoWaveGrpcTestClient method spatialTemporalQuery.
public ArrayList<FeatureProtos> spatialTemporalQuery() throws ParseException {
LOGGER.info("Performing Spatial Temporal Query...");
final VectorStoreParametersProtos baseParams = VectorStoreParametersProtos.newBuilder().setStoreName(GeoWaveGrpcTestUtils.storeName).build();
final TimeZone tz = TimeZone.getTimeZone("UTC");
// Quoted "Z" to indicate
final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
// UTC,
// no timezone offset
df.setTimeZone(tz);
final SpatialQueryParametersProtos spatialQuery = SpatialQueryParametersProtos.newBuilder().setBaseParams(baseParams).setGeometry(copyFrom(GeoWaveGrpcTestUtils.wkbSpatialQuery)).build();
final TemporalConstraintsProtos t = TemporalConstraintsProtos.newBuilder().setStartTime(Timestamps.fromMillis(df.parse(GeoWaveGrpcTestUtils.temporalQueryStartTime).getTime())).setEndTime(Timestamps.fromMillis(df.parse(GeoWaveGrpcTestUtils.temporalQueryEndTime).getTime())).build();
final SpatialTemporalQueryParametersProtos request = SpatialTemporalQueryParametersProtos.newBuilder().setSpatialParams(spatialQuery).addTemporalConstraints(0, t).setCompareOperation("CONTAINS").build();
Iterator<FeatureProtos> features;
final ArrayList<FeatureProtos> feature_list = new ArrayList<>();
features = vectorBlockingStub.spatialTemporalQuery(request);
// iterate over features
while (features.hasNext()) {
final FeatureProtos feature = features.next();
feature_list.add(feature);
}
return feature_list;
}
Aggregations