次の方法で共有


Scenes.SearchFeaturesAsync メソッド

定義

コレクション ID、bbox、交差するジオメトリ、開始日時と終了日時で STAC フィーチャを検索します。

public virtual System.Threading.Tasks.Task<Azure.Response> SearchFeaturesAsync (string collectionId, Azure.Core.RequestContent content, int? maxpagesize = default, int? skip = default, Azure.RequestContext context = default);
abstract member SearchFeaturesAsync : string * Azure.Core.RequestContent * Nullable<int> * Nullable<int> * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.SearchFeaturesAsync : string * Azure.Core.RequestContent * Nullable<int> * Nullable<int> * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function SearchFeaturesAsync (collectionId As String, content As RequestContent, Optional maxpagesize As Nullable(Of Integer) = Nothing, Optional skip As Nullable(Of Integer) = Nothing, Optional context As RequestContext = Nothing) As Task(Of Response)

パラメーター

collectionId
String

検索するコレクション ID。 使用できる値: "Sentinel_2_L2A" |"Sentinel_2_L1C"

content
RequestContent

要求の本文として送信するコンテンツ。 要求本文スキーマの詳細については、以下の「解説」セクションを参照してください。

maxpagesize
Nullable<Int32>

必要な機能の最大数 (含む)。 Minimum = 1、Maximum = 100、既定値 = 10。

skip
Nullable<Int32>

次の結果セットを取得するためのトークンをスキップします。

context
RequestContext

要求コンテキスト。これは、クライアント パイプラインの既定の動作を呼び出しごとにオーバーライドできます。

戻り値

サービスから返された応答。 応答本文スキーマの詳細については、以下の「解説」セクションを参照してください。

例外

collectionId または content が null です。

collectionId は空の文字列であり、空でないと予想されていました。

サービスから成功以外の状態コードが返されました。

このサンプルでは、必要なパラメーターと要求コンテンツを使用して SearchFeaturesAsync を呼び出す方法と、結果を解析する方法を示します。

var credential = new DefaultAzureCredential();
var client = new FarmBeatsClient(credential).GetScenesClient(<2022-11-01-preview>);

var data = new {
    startDateTime = "2022-05-10T18:57:31.2311892Z",
    endDateTime = "2022-05-10T18:57:31.2311892Z",
};

Response response = await client.SearchFeaturesAsync("<collectionId>", RequestContent.Create(data));

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("features")[0].GetProperty("stacVersion").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("id").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("type").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("properties").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("links")[0].GetProperty("href").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("links")[0].GetProperty("rel").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("assets").GetProperty("<test>").GetProperty("href").ToString());

このサンプルでは、すべてのパラメーターと要求コンテンツを使用して SearchFeaturesAsync を呼び出す方法と、結果を解析する方法を示します。

var credential = new DefaultAzureCredential();
var client = new FarmBeatsClient(credential).GetScenesClient(<2022-11-01-preview>);

var data = new {
    startDateTime = "2022-05-10T18:57:31.2311892Z",
    endDateTime = "2022-05-10T18:57:31.2311892Z",
    intersects = new {
        coordinates = new[] {
            new[] {
                new[] {
                    new[] {
                        123.45d
                    }
                }
            }
        },
        type = "MultiPolygon",
    },
    bbox = new[] {
        123.45d
    },
    featureIds = new[] {
        "<String>"
    },
};

Response response = await client.SearchFeaturesAsync("<collectionId>", RequestContent.Create(data), 1234, 1234);

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("features")[0].GetProperty("stacVersion").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("stacExtensions")[0].ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("id").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("type").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("geometry").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("bbox")[0].ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("properties").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("links")[0].GetProperty("href").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("links")[0].GetProperty("rel").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("links")[0].GetProperty("type").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("links")[0].GetProperty("title").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("assets").GetProperty("<test>").GetProperty("href").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("assets").GetProperty("<test>").GetProperty("title").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("assets").GetProperty("<test>").GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("assets").GetProperty("<test>").GetProperty("type").ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("assets").GetProperty("<test>").GetProperty("roles")[0].ToString());
Console.WriteLine(result.GetProperty("features")[0].GetProperty("collection").ToString());
Console.WriteLine(result.GetProperty("nextLink").ToString());

注釈

要求と応答のペイロードの JSON スキーマを次に示します。

要求本文:

SearchFeaturesQueryスキーマ:

{
  startDateTime: string (ISO 8601 Format), # Required. Start datetime of the time interval in which to search for Features.
  endDateTime: string (ISO 8601 Format), # Required. End datetime of the time interval in which to search for Features.
  intersects: {
    type: "Point" | "Polygon" | "MultiPolygon", # Required. GeoJSON object type.
  }, # Optional. GeoJSON (For more details: https://geojson.org/). Note: Coordinates are expected in [Longitude, Latitude] format.
  bbox: [number], # Optional. Only features that have a geometry that intersects the bounding box are selected.
The bounding box is provided as four numbers. The coordinate reference system of the values is WGS84 longitude/latitude.
  featureIds: [string], # Optional. Array of feature ids to return.
}

応答本文:

SearchFeaturesResponseスキーマ:

{
  features: [
    {
      stacVersion: string, # Required. The STAC version the Feature implements.
      stacExtensions: [string], # Optional. A list of extensions the Feature implements.
      id: string, # Required. Provider identifier. Globally unique ID by Data provider.
      type: string, # Required. Type of the GeoJSON Object. It's value is always Feature.
      geometry: AnyObject, # Optional. Defines the full footprint of the asset represented by this item.
Its a GeoJSON geometry.
      bbox: [number], # Optional. Bounding box of the feature.
      properties: AnyObject, # Required. A dictionary of additional metadata for the item.
      links: [
        {
          href: string, # Required. The actual link in the format of an URL.
          rel: string, # Required. Relationship between the current document and the linked document.
          type: string, # Optional. Media type of the referenced entity.
          title: string, # Optional. A human readable title to be used in rendered displays of the link.
        }
      ], # Required. List of link objects to resources and related URLs.
      assets: Dictionary<string, StacFeatureAsset>, # Required. Dictionary of asset objects, each with a unique key.
      collection: string, # Optional. The id of the STAC Collection this Feature references.
    }
  ], # Required. List of features.
  nextLink: string, # Optional. URL to do the POST request with same filters,
to get next set of features.
}

適用対象