Skip to content
GuidesPlaygroundDashboard

Execute a SPARQL query

client.Query.Sparql(ctx, body) (*SparqlResult, error)
POST/api/v1/sparql

Execute a SPARQL query

ParametersExpand Collapse
body QuerySparqlParams
SparqlQuery param.Field[SparqlQuery]
ReturnsExpand Collapse
type SparqlResult struct{…}

GeoJSON FeatureCollection of SPARQL query results

Features []GeoJsonFeature

GeoJSON features from SPARQL query

Coordinates GeoJsonGeometryCoordinatesUnion

GeoJSON coordinates array (nesting depth varies by geometry type)

One of the following:
type GeoJsonGeometryCoordinatesArray []float64
type GeoJsonGeometryCoordinatesArray [][]float64
type GeoJsonGeometryCoordinatesArray [][][]float64
type GeoJsonGeometryCoordinatesArray [][][][]float64
Type GeoJsonGeometryType
One of the following:
const GeoJsonGeometryTypePoint GeoJsonGeometryType = "Point"
const GeoJsonGeometryTypeLineString GeoJsonGeometryType = "LineString"
const GeoJsonGeometryTypePolygon GeoJsonGeometryType = "Polygon"
const GeoJsonGeometryTypeMultiPoint GeoJsonGeometryType = "MultiPoint"
const GeoJsonGeometryTypeMultiLineString GeoJsonGeometryType = "MultiLineString"
const GeoJsonGeometryTypeMultiPolygon GeoJsonGeometryType = "MultiPolygon"
Properties map[string, unknown]
Type GeoJsonFeatureType
ID stringoptional

Feature identifier (type/osm_id)

OsmID int64optional

OpenStreetMap ID

Type SparqlResultType

Execute a SPARQL query

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"),
  )
  sparqlResult, err := client.Query.Sparql(context.TODO(), githubcomplazafyiplazago.QuerySparqlParams{
    SparqlQuery: githubcomplazafyiplazago.SparqlQueryParam{
      Query: githubcomplazafyiplazago.F("query"),
    },
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", sparqlResult.Features)
}
Returns Examples