Search in sources :

Example 1 with VectorStoreParametersProtos

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;
}
Also used : SpatialQueryParametersProtos(org.locationtech.geowave.service.grpc.protobuf.SpatialQueryParametersProtos) FeatureProtos(org.locationtech.geowave.service.grpc.protobuf.FeatureProtos) ArrayList(java.util.ArrayList) VectorStoreParametersProtos(org.locationtech.geowave.service.grpc.protobuf.VectorStoreParametersProtos)

Example 2 with VectorStoreParametersProtos

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;
}
Also used : CQLQueryParametersProtos(org.locationtech.geowave.service.grpc.protobuf.CQLQueryParametersProtos) FeatureProtos(org.locationtech.geowave.service.grpc.protobuf.FeatureProtos) ArrayList(java.util.ArrayList) VectorStoreParametersProtos(org.locationtech.geowave.service.grpc.protobuf.VectorStoreParametersProtos)

Example 3 with VectorStoreParametersProtos

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");
    }
}
Also used : StreamObserver(io.grpc.stub.StreamObserver) WKBWriter(org.locationtech.jts.io.WKBWriter) MapStringStringResponseProtos(org.locationtech.geowave.service.grpc.protobuf.GeoWaveReturnTypesProtos.MapStringStringResponseProtos) StringResponseProtos(org.locationtech.geowave.service.grpc.protobuf.GeoWaveReturnTypesProtos.StringResponseProtos) CountDownLatch(java.util.concurrent.CountDownLatch) TimeZone(java.util.TimeZone) VectorIngestParametersProtos(org.locationtech.geowave.service.grpc.protobuf.VectorIngestParametersProtos) Coordinate(org.locationtech.jts.geom.Coordinate) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) VectorStoreParametersProtos(org.locationtech.geowave.service.grpc.protobuf.VectorStoreParametersProtos) FeatureAttributeProtos(org.locationtech.geowave.service.grpc.protobuf.FeatureAttributeProtos) SimpleDateFormat(java.text.SimpleDateFormat)

Example 4 with VectorStoreParametersProtos

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;
}
Also used : TemporalConstraintsProtos(org.locationtech.geowave.service.grpc.protobuf.TemporalConstraintsProtos) TimeZone(java.util.TimeZone) SpatialQueryParametersProtos(org.locationtech.geowave.service.grpc.protobuf.SpatialQueryParametersProtos) SpatialTemporalQueryParametersProtos(org.locationtech.geowave.service.grpc.protobuf.SpatialTemporalQueryParametersProtos) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) FeatureProtos(org.locationtech.geowave.service.grpc.protobuf.FeatureProtos) ArrayList(java.util.ArrayList) VectorStoreParametersProtos(org.locationtech.geowave.service.grpc.protobuf.VectorStoreParametersProtos) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

VectorStoreParametersProtos (org.locationtech.geowave.service.grpc.protobuf.VectorStoreParametersProtos)4 ArrayList (java.util.ArrayList)3 FeatureProtos (org.locationtech.geowave.service.grpc.protobuf.FeatureProtos)3 DateFormat (java.text.DateFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 TimeZone (java.util.TimeZone)2 SpatialQueryParametersProtos (org.locationtech.geowave.service.grpc.protobuf.SpatialQueryParametersProtos)2 StreamObserver (io.grpc.stub.StreamObserver)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 CQLQueryParametersProtos (org.locationtech.geowave.service.grpc.protobuf.CQLQueryParametersProtos)1 FeatureAttributeProtos (org.locationtech.geowave.service.grpc.protobuf.FeatureAttributeProtos)1 MapStringStringResponseProtos (org.locationtech.geowave.service.grpc.protobuf.GeoWaveReturnTypesProtos.MapStringStringResponseProtos)1 StringResponseProtos (org.locationtech.geowave.service.grpc.protobuf.GeoWaveReturnTypesProtos.StringResponseProtos)1 SpatialTemporalQueryParametersProtos (org.locationtech.geowave.service.grpc.protobuf.SpatialTemporalQueryParametersProtos)1 TemporalConstraintsProtos (org.locationtech.geowave.service.grpc.protobuf.TemporalConstraintsProtos)1 VectorIngestParametersProtos (org.locationtech.geowave.service.grpc.protobuf.VectorIngestParametersProtos)1 Coordinate (org.locationtech.jts.geom.Coordinate)1 WKBWriter (org.locationtech.jts.io.WKBWriter)1