Documentation
¶
Overview ¶
Package grid provides a client for using the GRiD API.
Portions of the grid package borrow heavily from https://github.com/google/go-github, a Go library for accessing the GitHub API, which is released under a BSD-style license (https://github.com/google/go-github/blob/master/LICENSE), with additional inspiration drawn from https://github.com/Medium/medium-sdk-go, a similar library for accessing the Medium API, and released under Apache v2.0.
Index ¶
- func CheckResponse(r *http.Response) error
- func CreateConfigFile() (*os.File, error)
- type AOI
- type AOIItem
- type AOIResponse
- type AddAOIResponse
- type Config
- type Error
- type ErrorResponse
- type Export
- type ExportDetail
- type ExportFile
- type GenerateExportObject
- type GeneratePointCloudExportOptions
- type Geoname
- type Grid
- func (g *Grid) AddAOI(name, geom string, subscribe bool) (*AddAOIResponse, *Response, error)
- func (g *Grid) Do(req *http.Request, v interface{}) (*Response, error)
- func (g *Grid) DownloadByPk(pk int) (*Response, error)
- func (g *Grid) GeneratePointCloudExport(pk int, collects []string, options *GeneratePointCloudExportOptions) (*GenerateExportObject, *Response, error)
- func (g *Grid) GetAOI(pk int) (*AOIItem, *Response, error)
- func (g *Grid) GetExport(pk int) (*ExportDetail, *Response, error)
- func (g *Grid) ListAOIs(geom string) (*AOIResponse, *Response, error)
- func (g *Grid) Lookup(geom string) (*Geoname, *Response, error)
- func (g *Grid) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)
- func (g *Grid) TaskDetails(pk string) (*TaskObject, *Response, error)
- type PointcloudCollect
- type RasterCollect
- type Response
- type TDASet
- type TaskObject
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.
func CreateConfigFile ¶ added in v0.2.1
CreateConfigFile creates the config file for writing, overwriting existing.
Types ¶
type AOI ¶
type AOI struct {
// Fields Fields `json:"fields,omitempty"`
Fields struct {
Name string `json:"name,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
IsActive bool `json:"is_active,omitempty"`
Source string `json:"source,omitempty"`
User int `json:"user,omitempty"`
ClipGeometry string `json:"clip_geometry,omitempty"`
Notes string `json:"notes,omitempty"`
} `json:"fields,omitempty"`
Model string `json:"model,omitempty"`
Pk int `json:"pk,omitempty"`
}
AOI represents the AOI object that is returned by the AOI detail endpoint.
GRiD API docs: https://github.com/CRREL/GRiD-API/blob/master/composed_api.rst#aoi-object2
type AOIItem ¶
type AOIItem struct {
ExportSet []Export `json:"export_set,omitempty"`
RasterCollects []RasterCollect `json:"raster_collects,omitempty"`
PointcloudCollects []PointcloudCollect `json:"pointcloud_collects,omitempty"`
AOIs []AOI `json:"aoi,omitempty"`
Success *bool `json:"success,omitempty"`
Error string `json:"error,omitempty"`
}
AOIItem represents the AOI object that is returned by the AOI list endpoint.
Note: If the query fails, we get a completely different JSON object, containing Success and Error fields. Although we never actually receive Success = true, we can test to see if the Success field exists, in which case it is false, and our query failed.
GRiD API docs: https://github.com/CRREL/GRiD-API/blob/master/composed_api.rst#aoi-detail-object
type AOIResponse ¶
AOIResponse represents the collection of AOIItems returned by the AOI list endpoint.
GRiD API docs: https://github.com/CRREL/GRiD-API/blob/master/composed_api.rst#aoi-object
type AddAOIResponse ¶
type AddAOIResponse map[string]interface{}
AddAOIResponse represents the response returned by the AOI add endpoint.
GRiD API docs: https://github.com/CRREL/GRiD-API/blob/master/composed_api.rst#aoi-detail-object
type Error ¶
type Error struct {
Resource string `json:"resource"` // resource on which the error occurred
Field string `json:"field"` // field on which the error occurred
Code string `json:"code"` // validation error code
}
An Error reports more details on an individual error in an ErrorResponse. These are the possible validation error codes:
missing:
resource does not exist
missing_field:
a required field on a resource has not been set
invalid:
the formatting of a field is invalid
already_exists:
another resource has the same valid as this field
GitHub API docs: http://developer.github.com/v3/#client-errors
type ErrorResponse ¶
type ErrorResponse struct {
Response *http.Response // HTTP response that caused this error
Message string `json:"message"` // error message
Errors []Error `json:"errors"` // more detail on individual errors
}
An ErrorResponse reports one or more errors caused by an API request. GitHub API docs: http://developer.github.com/v3/#client-errors
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type Export ¶
type Export struct {
Status string `json:"status,omitempty"`
Name string `json:"name,omitempty"`
Datatype string `json:"datatype,omitempty"`
HSRS string `json:"hsrs,omitempty"`
URL string `json:"url,omitempty"`
Pk int `json:"pk,omitempty"`
StartedAt string `json:"started_at,omitempty"`
}
Export represents the export object that is returned as part of an AOIItem.
GRiD API docs: https://github.com/CRREL/GRiD-API/blob/master/composed_api.rst#export-object
type ExportDetail ¶
type ExportDetail struct {
ExportFiles []ExportFile `json:"exportfiles,omitempty"`
TDASets []TDASet `json:"tda_set,omitempty"`
Success *bool `json:"success,omitempty"`
Error string `json:"error,omitempty"`
}
ExportDetail represents the export detail object that is returned by the export endpoint.
Note: If the query fails, we get a completely different JSON object, containing Success and Error fields. Although we never actually receive Success = true, we can test to see if the Success field exists, in which case it is false, and our query failed.
GRiD API docs: https://github.com/CRREL/GRiD-API/blob/master/composed_api.rst#export-detail-object
type ExportFile ¶
type ExportFile struct {
URL string `json:"url,omitempty"`
Pk int `json:"pk,omitempty"`
Name string `json:"name,omitempty"`
}
ExportFile represents the export file object that is returned by the export endpoint.
GRiD API docs: https://github.com/CRREL/GRiD-API/blob/master/composed_api.rst#exportfiles-object
type GenerateExportObject ¶ added in v0.2.1
type GenerateExportObject struct {
Started bool `json:"started,omitempty"`
TaskID string `json:"task_id,omitempty"`
ExportID int `json:"export_id,omitempty"`
}
GenerateExportObject represents the output from a Generate Export operation
GRiD API docs: https://github.com/CRREL/GRiD-API/blob/master/composed_api.rst#generate-export-object
type GeneratePointCloudExportOptions ¶ added in v0.2.1
type GeneratePointCloudExportOptions struct {
Intensity bool
DimClassification bool
Hsrs string //EPSG code
FileExportOptions string //individual or collect
Compressed bool
SendEmail bool
GenerateDem bool
CellSpacing float32
PclTerrain string // urban, mountainous, suburban, or foliated
SriHResolution float32 // Horizontal resolution
}
GeneratePointCloudExportOptions represents the options for a Generate Point Cloud Export Operation
GRiD API docs: https://github.com/CRREL/GRiD-API/blob/master/composed_api.rst#generate-point-cloud-export
func NewGeneratePointCloudExportOptions ¶ added in v0.2.1
func NewGeneratePointCloudExportOptions() *GeneratePointCloudExportOptions
NewGeneratePointCloudExportOptions is a factory method for a GeneratePointCloudExportOptions that provides all defaults
type Geoname ¶
type Geoname struct {
Name string `json:"name,omitempty"`
Geometry string `json:"provided_geometry,omitempty"`
}
Geoname represents the geoname object that is returned by the geoname endpoint.
GRiD API docs: https://github.com/CRREL/GRiD-API/blob/master/composed_api.rst#geoname-object
type Grid ¶ added in v0.2.1
type Grid struct {
Auth string
Key string
// Base URL for API requests. Defaults to GRiD TE, but can be
// set to a domain endpoint to use with other instances. BaseURL should
// always be specified with a trailing slash.
BaseURL *url.URL
Transport http.RoundTripper
}
Grid defines the GRiD client.
func (*Grid) AddAOI ¶ added in v0.2.1
AddAOI uploads the given geometry to create a new AOI.
GRiD API docs: https://github.com/CRREL/GRiD-API/blob/master/composed_api.rst#add-aoi
func (*Grid) Do ¶ added in v0.2.1
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.
func (*Grid) DownloadByPk ¶ added in v0.2.1
DownloadByPk downloads the file specified by the user-provided primary key.
func (*Grid) GeneratePointCloudExport ¶ added in v0.2.1
func (g *Grid) GeneratePointCloudExport(pk int, collects []string, options *GeneratePointCloudExportOptions) (*GenerateExportObject, *Response, error)
GeneratePointCloudExport does just that for the given PK and set of collects
GRiD API docs: https://github.com/CRREL/GRiD-API/blob/master/composed_api.rst#generate-point-cloud-export
func (*Grid) GetAOI ¶ added in v0.2.1
GetAOI returns AOI details for the AOI specified by the user-provided primary key.
GRiD API docs: https://github.com/CRREL/GRiD-API/blob/master/composed_api.rst#get-aoi-details
func (*Grid) GetExport ¶ added in v0.2.1
func (g *Grid) GetExport(pk int) (*ExportDetail, *Response, error)
GetExport returns export details for the export specified by the user-provided primary key.
GRiD API docs: https://github.com/CRREL/GRiD-API/blob/master/composed_api.rst#get-export-details
func (*Grid) ListAOIs ¶ added in v0.2.1
func (g *Grid) ListAOIs(geom string) (*AOIResponse, *Response, error)
ListAOIs retrieves all AOIs intersecting the optional geometry.
GRiD API docs: https://github.com/CRREL/GRiD-API/blob/master/composed_api.rst#get-a-users-aoi-list
func (*Grid) Lookup ¶ added in v0.2.1
Lookup the suggested name for the given geometry.
GRiD API docs: https://github.com/CRREL/GRiD-API/blob/master/composed_api.rst#lookup-geoname
func (*Grid) NewRequest ¶ added in v0.2.1
NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.
func (*Grid) TaskDetails ¶ added in v0.2.1
func (g *Grid) TaskDetails(pk string) (*TaskObject, *Response, error)
TaskDetails returns the details for a GRiD task
GRiD API docs: https://github.com/CRREL/GRiD-API/blob/master/composed_api.rst#generate-point-cloud-export
type PointcloudCollect ¶
type PointcloudCollect struct {
Datatype string `json:"datatype,omitempty"`
Pk int `json:"pk,omitempty"`
Name string `json:"name,omitempty"`
}
PointcloudCollect represents the pointcloud collect object that is returned as part of an AOIItem.
GRiD API docs: https://github.com/CRREL/GRiD-API/blob/master/composed_api.rst#collect-object
type RasterCollect ¶
type RasterCollect struct {
Datatype string `json:"datatype,omitempty"`
Pk int `json:"pk,omitempty"`
Name string `json:"name,omitempty"`
}
RasterCollect represents the raster collect object that is returned as part of an AOIItem.
GRiD API docs: https://github.com/CRREL/GRiD-API/blob/master/composed_api.rst#collect-object
type Response ¶
Response is a GitHub API response. This wraps the standard http.Response returned from GitHub and provides convenient access to things like pagination links.
type TDASet ¶
type TDASet struct {
Status string `json:"status,omitempty"`
TDAType string `json:"tda_type,omitempty"`
Name string `json:"name,omitempty"`
URL string `json:"url,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
Pk int `json:"pk,omitempty"`
Notes string `json:"notes,omitempty"`
}
TDASet represents the TDA set object that is returned by the export endpoint.
GRiD API docs: https://github.com/CRREL/GRiD-API/blob/master/composed_api.rst#tda-set-object
type TaskObject ¶ added in v0.2.1
type TaskObject struct {
Traceback string `json:"task_traceback,omitempty"`
State string `json:"task_state,omitempty"`
Timestamp string `json:"task_tstamp,omitempty"`
Name string `json:"task_name,omitempty"`
TaskID string `json:"task_id,omitempty"`
}
TaskObject represents the state of a GRiD task
GRiD API docs: https://github.com/CRREL/GRiD-API/blob/master/composed_api.rst#task-object