Skip to content
GuidesBlogPlaygroundDashboard

Get async optimization result

client.Optimize.Get(ctx, jobID) (*OptimizeJobStatus, error)
GET/api/v1/optimize/{job_id}

Get async optimization result

ParametersExpand Collapse
jobID string
ReturnsExpand Collapse
type OptimizeJobStatus struct{…}

Status of an async optimization job. When completed, the result field contains the full OptimizeCompletedResult. When processing, the job is still running — poll again. Failed jobs return a standard Error response (HTTP 422), not this schema.

Status OptimizeJobStatusStatus

Current job state

One of the following:
const OptimizeJobStatusStatusCompleted OptimizeJobStatusStatus = "completed"
const OptimizeJobStatusStatusProcessing OptimizeJobStatusStatus = "processing"

Completed optimization result as a GeoJSON FeatureCollection. Each Feature is a waypoint in optimized visit order. Top-level fields provide summary statistics.

Features []OptimizeCompletedResultFeature

Waypoints in optimized visit order

GeoJSON Geometry object per RFC 7946. Coordinates use [longitude, latitude] order. 3D coordinates [lng, lat, elevation] are used for elevation endpoints.

Coordinates GeoJsonGeometryCoordinatesUnion

Coordinates array. Nesting depth varies by geometry type: Point = [lng, lat], LineString = [[lng, lat], ...], Polygon = [[[lng, lat], ...], ...], etc.

One of the following:
type GeoJsonGeometryCoordinatesPoint []float64

[longitude, latitude] or [longitude, latitude, elevation]

type GeoJsonGeometryCoordinatesLineStringOrMultiPoint [][]float64

Array of [lng, lat] positions

type GeoJsonGeometryCoordinatesPolygonOrMultiLineString [][][]float64

Array of linear rings / line strings

type GeoJsonGeometryCoordinatesMultiPolygon [][][][]float64

Array of polygons

Type GeoJsonGeometryType

Geometry type

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 OptimizeCompletedResultFeaturesProperties
CostS float64

Travel time in seconds from the previous waypoint to this one (0 for the first waypoint)

CumulativeCostS float64

Cumulative travel time in seconds from the start to this waypoint

WaypointIndex int64

Position of this waypoint in the optimized visit order (0-based)

Type OptimizeCompletedResultFeaturesType
Optimization string

Optimization method used (e.g. nearest_neighbor, 2opt)

Roundtrip bool

Whether the route returns to the starting waypoint

TotalCostS float64

Total travel time for the optimized route in seconds

Type OptimizeCompletedResultType

Get async optimization result

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"),
  )
  optimizeJobStatus, err := client.Optimize.Get(context.TODO(), "job_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", optimizeJobStatus.Status)
}
{
  "status": "completed",
  "result": {
    "features": [
      {
        "geometry": {
          "coordinates": [
            2.3522,
            48.8566
          ],
          "type": "Point"
        },
        "properties": {
          "cost_s": 0,
          "cumulative_cost_s": 0,
          "waypoint_index": 0
        },
        "type": "Feature"
      }
    ],
    "optimization": "optimization",
    "roundtrip": true,
    "total_cost_s": 0,
    "type": "FeatureCollection"
  }
}
Returns Examples
{
  "status": "completed",
  "result": {
    "features": [
      {
        "geometry": {
          "coordinates": [
            2.3522,
            48.8566
          ],
          "type": "Point"
        },
        "properties": {
          "cost_s": 0,
          "cumulative_cost_s": 0,
          "waypoint_index": 0
        },
        "type": "Feature"
      }
    ],
    "optimization": "optimization",
    "roundtrip": true,
    "total_cost_s": 0,
    "type": "FeatureCollection"
  }
}