Compartilhar via


Scenes.SearchFeaturesAsync Método

Definição

Pesquise recursos stac por id de coleção, bbox, geometria de interseção, datetime de início e término.

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)

Parâmetros

collectionId
String

ID da coleção a ser pesquisada. Valores permitidos: "Sentinel_2_L2A" | "Sentinel_2_L1C".

content
RequestContent

O conteúdo a ser enviado como o corpo da solicitação. Os detalhes do esquema do corpo da solicitação estão na seção Comentários abaixo.

maxpagesize
Nullable<Int32>

Número máximo de recursos necessários (inclusivo). Mínimo = 1, Máximo = 100, Valor padrão = 10.

skip
Nullable<Int32>

Ignore o token para obter o próximo conjunto de resultados.

context
RequestContext

O contexto de solicitação, que pode substituir os comportamentos padrão do pipeline do cliente por chamada.

Retornos

A resposta retornada do serviço. Os detalhes do esquema do corpo da resposta estão na seção Comentários abaixo.

Exceções

collectionId ou content é nulo.

collectionId é uma cadeia de caracteres vazia e esperava-se que não estivesse vazia.

O serviço retornou um código de status sem êxito.

Exemplos

Este exemplo mostra como chamar SearchFeaturesAsync com os parâmetros necessários e o conteúdo da solicitação e como analisar o resultado.

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());

Este exemplo mostra como chamar SearchFeaturesAsync com todos os parâmetros e conteúdo da solicitação e como analisar o resultado.

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());

Comentários

Abaixo está o esquema JSON para as cargas de solicitação e resposta.

Corpo da solicitação:

Esquema para 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.
}

Corpo da resposta:

Esquema para 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.
}

Aplica-se a