Fetch multiple features by type and ID
client.Elements.Batch(ctx, body) (*FeatureCollection, error)
POST/api/v1/features/batch
Fetch multiple features by type and ID
package main
import (
"context"
"fmt"
"github.com/plazafyi/plaza-go"
"github.com/plazafyi/plaza-go/option"
)
func main() {
client := githubcomplazafyiplazago.NewClient(
option.WithAPIKey("My API Key"),
)
featureCollection, err := client.Elements.Batch(context.TODO(), githubcomplazafyiplazago.ElementBatchParams{
BatchRequest: githubcomplazafyiplazago.BatchRequestParam{
Elements: githubcomplazafyiplazago.F([]githubcomplazafyiplazago.BatchRequestElementParam{githubcomplazafyiplazago.BatchRequestElementParam{
ID: githubcomplazafyiplazago.F(int64(21154906)),
Type: githubcomplazafyiplazago.F(githubcomplazafyiplazago.BatchRequestElementsTypeNode),
}, githubcomplazafyiplazago.BatchRequestElementParam{
ID: githubcomplazafyiplazago.F(int64(4589123)),
Type: githubcomplazafyiplazago.F(githubcomplazafyiplazago.BatchRequestElementsTypeWay),
}}),
},
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", featureCollection.Features)
}
{
"features": [
{
"geometry": {
"coordinates": [
2.3522,
48.8566
],
"type": "Point"
},
"properties": {
"@id": "bar",
"@type": "bar",
"amenity": "bar",
"cuisine": "bar",
"name": "bar"
},
"type": "Feature",
"id": "node/21154906"
}
],
"type": "FeatureCollection"
}Returns Examples
{
"features": [
{
"geometry": {
"coordinates": [
2.3522,
48.8566
],
"type": "Point"
},
"properties": {
"@id": "bar",
"@type": "bar",
"amenity": "bar",
"cuisine": "bar",
"name": "bar"
},
"type": "Feature",
"id": "node/21154906"
}
],
"type": "FeatureCollection"
}