client

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2023 License: Apache-2.0 Imports: 21 Imported by: 3

Documentation

Index

Constants

View Source
const (
	Format_Raw   = Format(pb.FileFormat_Raw)
	Format_GTiff = Format(pb.FileFormat_GTiff)
)
View Source
const (
	// AuthorizationHeader is the header key to get the authorization token
	AuthorizationHeader = "authorization"
	// ESRIAuthorizationHeader is the header key to get the authorization token
	ESRIAuthorizationHeader = "X-Esri-Authorization"
)

Variables

View Source
var COGPattern = "R>Z=1:>T>B;R>Z=0>T>B"
View Source
var MUCOGPattern = "Z=0>T>R>B;R>Z=1:>T>B"

Functions

func Code

func Code(err error) codes.Code

Code is used to retrieves the status code of the error

func GeometryFromAOI

func GeometryFromAOI(aoi AOI) geojson.Geometry

GeometryFromAOI converts an AOI to a geometry

func GroupBy added in v1.0.0

func GroupBy(records []*Record, funcKey GroupByKeyFunc) [][]string

GroupBy groups the records of the list by the key provided by the func_key(Record) Returns a list of grouped records ID

func GroupByDayKey added in v1.0.0

func GroupByDayKey(record *Record) string

Types

type AOI

type AOI [][][][2]float64

func AOIFromFile

func AOIFromFile(path string) (AOI, error)

AOIFromFile extracts the geometry from the given file. For Geojson File : it merges all the polygons and multipolygons into one multipolygon If provided, the CRS is ignored

func AOIFromGeometry

func AOIFromGeometry(geometry geojson.Geometry) (AOI, error)

AOIFromGeometry converts a geometry to an AOI

func AOIFromMultiPolygonArray

func AOIFromMultiPolygonArray(mp [][][][2]float64) AOI

AOIFromMultiPolygonArray converts a multipolygon as an array to an AOI

type Client

type Client struct {
	// contains filtered or unexported fields
}

func (Client) AddRecordsTags

func (c Client) AddRecordsTags(ctx context.Context, ids []string, tags map[string]string) (int64, error)

AddRecordsTags add or update existing tag form list of records returns the number of updated records

func (Client) CancelJob

func (c Client) CancelJob(ctx context.Context, jobID string) error

CancelJob retries the job with the given ID

func (Client) CleanJobs

func (c Client) CleanJobs(ctx context.Context, nameLike, state string) (int32, error)

CleanJobs removes the terminated jobs nameLike, state : [optional] filter by name or state (DONE/FAILED)

func (Client) ConfigConsolidation

func (c Client) ConfigConsolidation(ctx context.Context, variableID string, dformat *DataFormat, exponent float64, compression int, resamplingAlg string, storageClass int) error

ConfigConsolidation configures the parameters associated to this variable

func (Client) ConsolidateDatasetsFromFilters

func (c Client) ConsolidateDatasetsFromFilters(ctx context.Context, name string, instanceID, layoutName string, tags map[string]string, fromTime, toTime time.Time) (string, error)

ConsolidateDatasetsFromFilters starts a consolidation job of the datasets defined by the given parameters

func (Client) ConsolidateDatasetsFromRecords

func (c Client) ConsolidateDatasetsFromRecords(ctx context.Context, name string, instanceID, layoutName string, recordsID []string) (string, error)

ConsolidateDatasetsFromRecords starts a consolidation job of the datasets defined by the given parameters

func (Client) CreateAOI

func (c Client) CreateAOI(ctx context.Context, g AOI) (string, error)

CreateAOI creates an aoi from a geometry If error EntityAlreadyExists, returns the id of the existing one and the error.

func (Client) CreateLayout

func (c Client) CreateLayout(ctx context.Context, name string, gridFlags []string, gridParameters map[string]string, blockXSize, blockYSize, maxRecords, overviewsMinSize int64, interlacingPattern string) error

func (Client) CreatePalette

func (c Client) CreatePalette(ctx context.Context, name string, colors []ColorPoint, replace bool) error

CreatePalette defines (or redefines) a palette as a ramp of colors

func (Client) CreateRecord added in v0.4.0

func (c Client) CreateRecord(ctx context.Context, name, aoiID string, date time.Time, tags map[string]string) ([]string, error)

CreateRecord creates a record with an aoi, a name and a date

func (Client) CreateRecords

func (c Client) CreateRecords(ctx context.Context, names, aoiIDs []string, dates []time.Time, tags []map[string]string) ([]string, error)

CreateRecords creates a batch of records with aois, names and dates

func (Client) CreateVariable

func (c Client) CreateVariable(ctx context.Context, name, unit, description string, dformat *DataFormat, bandsName []string, palette, resamplingAlg string) (string, error)

CreateVariable creates a variable

func (Client) DeleteInstance

func (c Client) DeleteInstance(ctx context.Context, instanceID string) error

DeleteInstance deletes the Instance if and only if it's a pending instance (with no datasets) DeleteInstance does not delete the Variable

func (Client) DeleteRecords

func (c Client) DeleteRecords(ctx context.Context, ids []string) (int64, error)

DeleteRecords deletes a batch of records iif no dataset has reference on Returns the number of deleted records

func (Client) DeleteVariable

func (c Client) DeleteVariable(ctx context.Context, variableID string) error

DeleteVariable deletes the Variable and all its instances if and only if all instances are pending

func (Client) GetAOI

func (c Client) GetAOI(ctx context.Context, aoiID string) (AOI, error)

GetAOI retrieves an AOI from a aoi_id

func (Client) GetConsolidationParams

func (c Client) GetConsolidationParams(ctx context.Context, variableID string) (*ConsolidationParams, error)

GetConsolidationParams read the consolidation parameters associated to this variable

func (Client) GetCubeFromFilters added in v1.0.0

func (c Client) GetCubeFromFilters(ctx context.Context, tags map[string]string, fromTime, toTime time.Time, instanceID string, crs string, pix2crs [6]float64, sizeX, sizeY int32, format Format, compression int, headersOnly bool) (*CubeIterator, error)

GetCubeFromFilters gets a cube from a list of filters

func (Client) GetCubeFromGroupedRecords added in v1.0.0

func (c Client) GetCubeFromGroupedRecords(ctx context.Context, recordsID [][]string, instanceID string, crs string, pix2crs [6]float64, sizeX, sizeY int32, format Format, compression int, headersOnly bool) (*CubeIterator, error)

GetCubeFromGroupedRecords gets a cube from a list of grouped records

func (Client) GetCubeFromRecords

func (c Client) GetCubeFromRecords(ctx context.Context, recordsID []string, instanceID string, crs string, pix2crs [6]float64, sizeX, sizeY int32, format Format, compression int, headersOnly bool) (*CubeIterator, error)

GetCubeFromRecords gets a cube from a list of records

func (Client) GetCubeFromTile added in v0.4.0

func (c Client) GetCubeFromTile(ctx context.Context, tile *Tile, instanceID string, recordIDs []string, gRecordIDs [][]string, tags map[string]string, fromTime, toTime time.Time, format Format, compression int, headersOnly bool) (*CubeIterator, error)

GetCubeFromTile gets a cube from a tile and a list of records or filters

func (*Client) GetDownloaderClient added in v0.4.0

func (clt *Client) GetDownloaderClient() DownloaderClient

func (Client) GetJob

func (c Client) GetJob(ctx context.Context, jobID string) (*Job, error)

GetJob returns the job with the given ID

func (Client) GetVariable

func (c Client) GetVariable(ctx context.Context, id string) (*Variable, error)

GetVariable returns the variable that id

func (Client) GetVariableFromInstanceID

func (c Client) GetVariableFromInstanceID(ctx context.Context, id string) (*VariableInstance, error)

GetVariableFromInstanceID returns the variable & instance with that instance id

func (Client) GetVariableFromName

func (c Client) GetVariableFromName(ctx context.Context, name string) (*Variable, error)

GetVariableFromName returns the variable with that name

func (Client) IndexDataset

func (c Client) IndexDataset(ctx context.Context, uri string, managed bool, containerSubdir, recordID, instanceID string, bands []int64, dformat *DataFormat, realMin, realMax, exponent float64) error

IndexDataset indexes a dataset

func (Client) IndexDatasets

func (c Client) IndexDatasets(ctx context.Context, uri string, managed bool, datasets []*pb.Dataset) error

IndexDatasets indexes a batch of datasets

func (Client) InstantiateVariable

func (c Client) InstantiateVariable(ctx context.Context, variableID, name string, metadata map[string]string) (string, error)

InstantiateVariable instantiates a variable with name and metadata

func (Client) ListJobs

func (c Client) ListJobs(ctx context.Context, nameLike string) ([]*Job, error)

ListJobs returns the jobs with a name like name (or all if name="")

func (Client) ListLayouts

func (c Client) ListLayouts(ctx context.Context, nameLike string) ([]*Layout, error)

func (Client) ListRecords

func (c Client) ListRecords(ctx context.Context, name string, tags map[string]string, aoi AOI, fromTime, toTime time.Time, limit, page int, returnAOI bool) ([]*Record, error)

ListRecords lists records that fit the search parameters (all are optionnal)

func (Client) ListVariables

func (c Client) ListVariables(ctx context.Context, namelike string, limit, page int) ([]Variable, error)

ListVariables returns a list of variables that fit the search parameters

func (Client) RemoveRecordsTags

func (c Client) RemoveRecordsTags(ctx context.Context, ids []string, tags []string) (int64, error)

AddRecordsTags delete tags from list of records returns the number of updated records

func (Client) RetryJob

func (c Client) RetryJob(ctx context.Context, jobID string, forceAnyState bool) error

RetryJob retries the job with the given ID

func (*Client) ServerVersion

func (c *Client) ServerVersion(ctx context.Context) (string, error)

ServerVersion returns the version of the Geocube serveur

func (Client) TileAOI

func (c Client) TileAOI(ctx context.Context, aoi AOI, layoutName string, layout *Layout) (<-chan Tile, error)

func (Client) UpdateInstance

func (c Client) UpdateInstance(ctx context.Context, instanceID string, name *string, addMetadata map[string]string, delMetadataKeys []string) error

UpdateInstance updates the non-nil/non-empty fields of the instance

func (Client) UpdateVariable

func (c Client) UpdateVariable(ctx context.Context, id string, name, unit, description, palette, resamplingAlg *string) error

UpdateVariable updates the non-nil fields of the variable

type ClientConnector added in v0.4.0

type ClientConnector struct {
	Connector
	DownloaderConnector *DownloaderConnector
}

func (*ClientConnector) Dial added in v0.4.0

func (c *ClientConnector) Dial() (Client, error)

Dial creates a new client connected to the server

type ClientStream added in v0.4.0

type ClientStream struct{ pb.Geocube_GetCubeClient }

func (ClientStream) Recv added in v0.4.0

func (s ClientStream) Recv() (CubeResponse, error)

type ColorPoint

type ColorPoint pb.ColorPoint

type Connector added in v0.4.0

type Connector struct {
	Server string
	Creds  credentials.TransportCredentials
	ApiKey string
}

type ConsolidationParams

type ConsolidationParams pb.ConsolidationParams

type CubeElem

type CubeElem struct {
	Data         []byte
	Shape        [3]int32
	DType        pb.DataFormat_Dtype
	Records      []*Record
	DatasetsMeta *DatasetMeta
	Order        pb.ByteOrder
	Err          string
}

type CubeHeader

type CubeHeader struct {
	Count         int64
	NbDatasets    int64
	RefDformat    *DataFormat
	ResamplingAlg pb.Resampling
	Geotransform  *pb.GeoTransform
	Crs           string
	Width, Height int32
}

type CubeIterator

type CubeIterator struct {
	// contains filtered or unexported fields
}

func NewCubeIterator

func NewCubeIterator(stream CubeStream, width, height int32) (*CubeIterator, error)

func (*CubeIterator) Err

func (cit *CubeIterator) Err() error

Err returns the error if the iterator failed to go to next Element.

func (*CubeIterator) Header

func (cit *CubeIterator) Header() CubeHeader

Header (global Header)

func (*CubeIterator) Next

func (cit *CubeIterator) Next() bool

Next loads the next element of the cube and returns true. It returns false if there is no more elements or an error occured. In the latter case, check .Err().

func (*CubeIterator) Value

func (cit *CubeIterator) Value() *CubeElem

Value returns a pointer to the current element. The pointer remains valid as long as cubeiterator is. The value is updated when cit.Next() is called. Check CubeElem.Err for a potential error on this element.

type CubeResponse added in v0.4.0

type CubeResponse interface {
	GetGlobalHeader() *pb.GetCubeResponseHeader
	GetHeader() *pb.ImageHeader
	GetChunk() *pb.ImageChunk
}

type CubeStream added in v0.4.0

type CubeStream interface {
	Recv() (CubeResponse, error)
}

type DataFormat added in v0.4.0

type DataFormat pb.DataFormat

func ToDFormat added in v0.4.0

func ToDFormat(s string) (*DataFormat, error)

ToDFormat returns a DataFormat from the user-defined string Format is "datatype,nodata,min,max" with datatype in {"byte, uint8, uint16, uint32, int8,int16, int32, float32, float64, complex64, auto, u1, u2, u4, i1, i2, i4, f4, f8, c8"} with nodata, min and max as float value

type DatasetMeta added in v0.4.0

type DatasetMeta struct {
	Internals []*InternalMeta
}

type DownloaderClient added in v0.4.0

type DownloaderClient struct {
	// contains filtered or unexported fields
}

func (DownloaderClient) DownloadCube added in v0.4.0

func (d DownloaderClient) DownloadCube(ctx context.Context, iter *CubeIterator, format Format) (*CubeIterator, error)

func (DownloaderClient) Version added in v1.0.0

func (c DownloaderClient) Version(ctx context.Context) (string, error)

Version returns the version of the Geocube downloader

type DownloaderConnector added in v0.4.0

type DownloaderConnector Connector

func (*DownloaderConnector) Dial added in v0.4.0

Dial creates a new downloader client connected to a downloader service

type DownloaderStream added in v0.4.0

type DownloaderStream struct {
	pb.GeocubeDownloader_DownloadCubeClient
}

func (DownloaderStream) Recv added in v0.4.0

func (s DownloaderStream) Recv() (CubeResponse, error)

type Format

type Format pb.FileFormat

type GroupByKeyFunc added in v1.0.0

type GroupByKeyFunc func(*Record) string

convert types take an int and return a string value.

type InternalMeta added in v0.4.0

type InternalMeta struct {
	ContainerURI       string
	ContainerSubDir    string
	Bands              []int64
	InternalDataFormat *DataFormat
	ExternalMinValue   float64
	ExternalMaxValue   float64
	Exponent           float64
}

func NewInternalMetaFromPb added in v0.4.0

func NewInternalMetaFromPb(prtb *pb.InternalMeta) *InternalMeta

type Job

type Job pb.Job

func (*Job) ToString

func (j *Job) ToString() string

ToString returns a string with a representation of the job

type Layout

type Layout pb.Layout

func NewRegularLayout added in v0.4.0

func NewRegularLayout(name, crs string, resolution float64, sizeXPx, sizeYPx, originX, originY, blockXSize, blockYSize, maxRecords, overviewsMinSize int64, interlacingPattern string) Layout

func (*Layout) ToString

func (l *Layout) ToString() string

ToString returns a string with a representation of the layout

type Record

type Record struct {
	ID    string
	Name  string
	Time  time.Time
	Tags  map[string]string
	AOIID string
	AOI   *AOI
}

func (*Record) ToPb added in v0.4.0

func (r *Record) ToPb() pb.Record

func (*Record) ToString

func (r *Record) ToString() string

ToString returns a string representation of a Record

type Tile

type Tile struct {
	Transform     [6]float64
	CRS           string
	Width, Height int32
	// contains filtered or unexported fields
}

func NewTileFromPb

func NewTileFromPb(pbt *pb.Tile) *Tile

func TileError added in v0.4.0

func TileError(err error) Tile

TileError is an erroneous tile

func (*Tile) Error added in v0.4.0

func (t *Tile) Error() error

Error returns an error if the tile is an erroneous tile

type TokenAuth

type TokenAuth struct {
	Token string
}

TokenAuth to use with grpc.WithPerRPCCredentials

func (TokenAuth) GetRequestMetadata

func (t TokenAuth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error)

GetRequestMetadata implements grpc.PerRPCCredentials

func (TokenAuth) RequireTransportSecurity

func (TokenAuth) RequireTransportSecurity() bool

RequireTransportSecurity implements grpc.PerRPCCredentials

type Variable

type Variable struct {
	pb.Variable
	// contains filtered or unexported fields
}

func (*Variable) Instance

func (v *Variable) Instance(name string) *VariableInstance

Instance returns a VariableInstance or nil if the instance does not exist

func (*Variable) SetDescription

func (v *Variable) SetDescription(ctx context.Context, description string) error

SetDescription sets the description of the variable

func (*Variable) SetName

func (v *Variable) SetName(ctx context.Context, name string) error

SetName sets the name of the variable

func (*Variable) SetPalette

func (v *Variable) SetPalette(ctx context.Context, palette string) error

SetPalette sets the name of the palette. Empty string removes the palette

func (*Variable) SetResamplingAlg

func (v *Variable) SetResamplingAlg(ctx context.Context, resamplingAlg string) error

SetResamplingAlg sets the algorithm used for resampling

func (*Variable) SetUnit

func (v *Variable) SetUnit(ctx context.Context, unit string) error

SetUnit sets the unit of the variable

func (*Variable) ToString

func (v *Variable) ToString() string

ToString returns a string representation of the variable

type VariableInstance

type VariableInstance struct {
	*Variable
	InstanceID       string
	InstanceName     string
	InstanceMetadata map[string]string
}

func (*VariableInstance) ToString

func (vi *VariableInstance) ToString() string

ToString returns a string representation of the instance

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL