The following .proto file is required for accessing the beta features of BigGeo.

//    Copyright 2024 BigGeo Inc.
//
//    Permission is hereby granted, free of charge, to any person obtaining a copy of
//    this software and associated documentation files (the “Software”), to deal in
//    the Software without restriction, including without limitation the rights to
//    use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
//    of the Software, and to permit persons to whom the Software is furnished to do
//    so, subject to the following conditions:
//
//    The above copyright notice and this permission notice shall be included in all
//    copies or substantial portions of the Software.
//
//    THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
//    INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
//    PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
//    HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
//    OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
//    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

syntax = "proto3";

package biggeo.protobuf;

import "bgsearch_types.proto";

service BGSearchBeta {
  rpc BetaSearchIntersects (BetaSearchIntersectsArgs) returns (stream BetaSearchResult){}
  rpc BetaSearchDistWithin (BetaSearchDistWithinArgs) returns (stream BetaSearchResult){}

  rpc PointToDGGSIndex (LatLng) returns (DGGSIndex) {}

  rpc Rasterize     (RasterizeArgs)     returns (RasterizeResult) {}
  rpc RasterizeBulk (RasterizeBulkArgs) returns (RasterizeBulkResult) {}
}

// **************
// Argument Types
// **************

message AggregationArgs {
  uint64 max_geoms_per_cell = 1;
  uint64 resolution_offset = 2;
  uint64 max_additional_refines = 3;
  double count_refine_factor = 4;
}

message BetaSearchControls {
  bool return_geometries = 1;
  bool return_payloads = 2;
  uint64 geometries_chunk_size = 3;
  uint64 aggregates_chunk_size = 4;
  optional AggregationArgs aggregationArgs = 5;
};

message BetaSearchIntersectsArgs {
  string collection = 1;
  oneof search_geometry {
    // LatLng point = 2;
    // LineStrip line_strip = 3;
    Polygon polygon = 4;
    LatLngBBox lat_Lng_bbox = 5;
  };
  reserved 2, 3;
  reserved "point", "line_strip";
  reserved 6 to 14;
  BetaSearchControls controls = 15;
}

message BetaSearchDistWithinArgs {
  string collection = 1;
  double distance_m = 2;
  oneof search_geometry {
    LatLng point = 3;
    // LineStrip line_strip = 4;
    // Polygon polygon = 5;
  };
  reserved 4, 5;
  reserved "line_strip", "polygon";
  uint64 max_geoms_per_cell = 6;
  uint64 resolution_offset = 7;
  uint64 max_additional_refines = 8;
  double count_refine_factor = 9;
  reserved 10 to 14;
  BetaSearchControls controls = 15;
}

message RasterizeArgs {
  oneof geometry {
    LatLng point = 1;
    LineStrip line_strip = 2;
    Polygon polygon = 3;
    MultiPolygon multi_polygon = 4;
  }
}

message RasterizeBulkArgs {
  repeated RasterizeArgs geometries = 1;
}

// ************
// Result Types
// ************

message BetaSearchResult {
  message Geometry {
    GeometryID id = 1;
    optional IndexableGeometry geometry = 2;
    optional Payload payload = 3;
  }
  // Subject to change
  message Aggregate {
    DGGSIndex cell_index = 1;
    Ring cell_vertices = 2;
    uint64 point_count = 3;
    uint64 non_point_count = 4;
    LatLng mean_point = 5;
  }

  repeated Geometry geometries = 1;
  repeated Aggregate aggregates = 2;
}

message RasterizeResult {
  repeated DGGSIndex indices = 1;
}

message RasterizeBulkResult {
  repeated RasterizeResult results = 1;
}