utils

package
v0.0.0-...-1152cda Latest Latest
Warning

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

Go to latest
Published: May 9, 2018 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const ISOFormat = "2006-01-02T15:04:05.000Z"

string used to format Go ISO times

View Source
const ISOZeroTime = "0001-01-01T00:00:00.000Z"
View Source
const WGS84WKT = `` /* 257-byte string literal not displayed */

Variables

View Source
var DataDir = "/usr/local/share"
View Source
var EtcDir = "/usr/local/etc"
View Source
var LibexecDir = "/usr/local/libexec"
View Source
var WMSRegexpMap map[string]string = map[string]string{"service": `^WMS$`,
	"request": `^GetCapabilities$|^GetFeatureInfo$|^DescribeLayer$|^GetMap$|^GetLegendGraphic$`,
	"crs":     `^(?i)(?:[A-Z]+):(?:[0-9]+)$`,
	"bbox":    `^[-+]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?(,[-+]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?){3}$`,
	"x":       `^[0-9]+$`,
	"y":       `^[0-9]+$`,
	"width":   `^[0-9]+$`,
	"height":  `^[0-9]+$`,
	"time":    `^\d{4}-(?:1[0-2]|0[1-9])-(?:3[01]|0[1-9]|[12][0-9])T[0-2]\d:[0-5]\d:[0-5]\d\.\d+Z$`}

WMSRegexMap maps WMS request parameters to regular expressions for doing validation when parsing. --- These regexp do not avoid every case of --- invalid code but filter most of the malformed --- cases. Error free JSON deserialisation into types --- also validates correct values.

View Source
var WPSRegexpMap map[string]string = map[string]string{"service": `^WPS$`,
	"request": `^GetCapabilities$|^DescribeProcess$|^Execute$`,
	"time":    `^\d{4}-(?:1[0-2]|0[1-9])-(?:3[01]|0[1-9]|[12][0-9])T[0-2]\d:[0-5]\d:[0-5]\d\.\d+Z$`}

WPSRegexMap maps WPS request parameters to regular expressions for doing validation when parsing. --- These regexp do not avoid every case of --- invalid code but filter most of the malformed --- cases. Error free JSON deserialisation into types --- also validates correct values.

Functions

func BBox2Geot

func BBox2Geot(width, height int, bbox []float64) []float64

BBox2Geot return the geotransform from the parameters received in a WMS GetMap request

func CompileWMSRegexMap

func CompileWMSRegexMap() map[string]*regexp.Regexp

func CompileWPSRegexMap

func CompileWPSRegexMap() map[string]*regexp.Regexp

func ExecuteWriteTemplateFile

func ExecuteWriteTemplateFile(w io.Writer, data interface{}, filePath string) error

General template compilation, execution and writting in to a stream.

func GenerateDates

func GenerateDates(name string, start, end time.Time, stepMins time.Duration) []string

func GenerateDatesAux

func GenerateDatesAux(start, end time.Time, stepMins time.Duration) []string

func GenerateDatesChirps20

func GenerateDatesChirps20(start, end time.Time, stepMins time.Duration) []string

func GenerateDatesMCD43A4

func GenerateDatesMCD43A4(start, end time.Time, stepMins time.Duration) []string

GenerateDates function is used to generate the list of ISO dates from its especification in the Config.Layer struct.

func GenerateDatesRegular

func GenerateDatesRegular(start, end time.Time, stepMins time.Duration) []string

func GenerateMonthlyDates

func GenerateMonthlyDates(start, end time.Time, stepMins time.Duration) []string

func GenerateYearlyDates

func GenerateYearlyDates(start, end time.Time, stepMins time.Duration) []string

func GetArea

func GetArea(wgs84Poly geo.Geometry) float64

func GetCoordinates

func GetCoordinates(params WMSParams) (float64, float64, error)

GetCoordinates returns the x and y coordinates in the original projection from the tile relative WMS parameters.

func GetLayerIndex

func GetLayerIndex(params WMSParams, config *Config) (int, error)

GetLayerIndex returns the index of the specified layer inside the Config.Layers field.

func NormaliseKeys

func NormaliseKeys(params map[string][]string) map[string][]string

func ParsePost

func ParsePost(rc io.ReadCloser) (map[string][]string, error)

Types

type CacheLevel

type CacheLevel struct {
	Path   string  `json:"path"`
	MinRes float64 `json:"min_res"`
	MaxRes float64 `json:"max_res"`
}

DataSource contains the source files of one layer as well as the max and min resolutions it represents. Its fields encode the path to the collection and the maximum and mimum resolution that can be served. This enables the definition of different versions of the same dataset with different resolutions to speedup response times.

type CompData

type CompData struct {
	Identifier string `json:"identifier"`
	Title      string `json:"title"`
	Abstract   string `json:"abstract"`
	MimeType   string `json:"mime_type"`
	Encoding   string `json:"encoding"`
	Schema     string `json:"schema"`
}

DataInput contains the description of a variable used to compute a WPS operation

type Config

type Config struct {
	ServiceConfig ServiceConfig `json:"service_config"`
	Layers        []Layer       `json:"layers"`
	Processes     []Process     `json:"processes"`
}

Config is the struct representing the configuration of a WMS server. It contains information about the file index API as well as the list of WMS layers that can be served.

func (*Config) LoadConfigFile

func (config *Config) LoadConfigFile(configFile string) error

GetConfig marshall the config.json document returning an instance of a Config variable containing all the values

func (*Config) Watch

func (config *Config) Watch(infoLog, errLog *log.Logger)

type Data

type Data struct {
	ComplexData string
}

type DataInputs

type DataInputs struct {
	Input Input
}

type Execute

type Execute struct {
	Version    string `xml:"version,attr"`
	Service    string `xml:"service,attr"`
	Identifier string
	DataInputs DataInputs
}

type FileList

type FileList struct {
	Files []string `json:"files"`
}

FileList is the struct used to unmarshal the reponse from the index API

type Input

type Input struct {
	Identifier string
	Data       Data
}

type Layer

type Layer struct {
	OWSHostname string `json:"ows_hostname"`
	Name        string `json:"name"`
	Title       string `json:"title"`
	Abstract    string `json:"abstract"`
	MetadataURL string `json:"metadata_url"`
	DataURL     string `json:"data_url"`
	//CacheLevels  []CacheLevel `json:"cache_levels"`
	DataSource   string   `json:"data_source"`
	StartISODate string   `json:"start_isodate"`
	EndISODate   string   `json:"end_isodate"`
	StepDays     int      `json:"step_days"`
	StepHours    int      `json:"step_hours"`
	StepMinutes  int      `json:"step_minutes"`
	Accum        bool     `json:"accum"`
	TimeGen      string   `json:"time_generator"`
	ResFilter    *int     `json:"resolution_filter"`
	Dates        []string `json:"dates"`
	RGBProducts  []string `json:"rgb_products"`
	Mask         *Mask    `json:"mask"`
	OffsetValue  float64  `json:"offset_value"`
	ClipValue    float64  `json:"clip_value"`
	ScaleValue   float64  `json:"scale_value"`
	Palette      *Palette `json:"palette"`
	LegendPath   string   `json:"legend_path"`
	ZoomLimit    float64  `json:"zoom_limit"`
}

Layer contains all the details that a layer needs to be published and rendered

type LitData

type LitData struct {
	Identifier    string   `json:"identifier"`
	Title         string   `json:"title"`
	Abstract      string   `json:"abstract"`
	DataType      string   `json:"data_type"`
	DataTypeRef   string   `json:"data_type_ref"`
	AllowedValues []string `json:"allowed_values"`
}

DataInput contains the description of a variable used to compute a WPS operation

type Mask

type Mask struct {
	Id    string `json:"id"`
	Value string `json:"value"`
}

type Palette

type Palette struct {
	Interpolate bool         `json:"interpolate"`
	Colours     []color.RGBA `json:"colours"`
}

type Process

type Process struct {
	Paths       []string   `json:"paths"`
	Identifier  string     `json:"identifier"`
	Title       string     `json:"title"`
	Abstract    string     `json:"abstract"`
	MaxArea     float64    `json:"max_area"`
	LiteralData []LitData  `json:"literal_data"`
	ComplexData []CompData `json:"complex_data"`
}

Process contains all the details that a WPS needs to be published and processed

type ServiceConfig

type ServiceConfig struct {
	OWSHostname string   `json:"ows_hostname"`
	MASAddress  string   `json:"mas_address"`
	WorkerNodes []string `json:"worker_nodes"`
}

type WMSParams

type WMSParams struct {
	Service *string    `json:"service,omitempty"`
	Request *string    `json:"request,omitempty"`
	CRS     *string    `json:"crs,omitempty"`
	BBox    []float64  `json:"bbox,omitempty"`
	Format  *string    `json:"format,omitempty"`
	X       *int       `json:"x,omitempty"`
	Y       *int       `json:"y,omitempty"`
	Height  *int       `json:"height,omitempty"`
	Width   *int       `json:"width,omitempty"`
	Time    *time.Time `json:"time,omitempty"`
	Layers  []string   `json:"layers,omitempty"`
	Styles  []string   `json:"styles,omitempty"`
	Version *string    `json:"version,omitempty"`
}

WMSParams contains the serialised version of the parameters contained in a WMS request.

func WMSParamsChecker

func WMSParamsChecker(params map[string][]string, compREMap map[string]*regexp.Regexp) (WMSParams, error)

WMSParamsChecker checks and marshals the content of the parameters of a WMS request into a WMSParams struct.

type WPSParams

type WPSParams struct {
	Service    *string               `json:"service"`
	Request    *string               `json:"request"`
	Identifier *string               `json:"identifier"`
	Product    *string               `json:"product"`
	FeatCol    geo.FeatureCollection `json:"feature_collection"`
}

WPSParams contains the serialised version of the parameters contained in a WPS request.

func WPSParamsChecker

func WPSParamsChecker(params map[string][]string, compREMap map[string]*regexp.Regexp) (WPSParams, error)

WPSParamsChecker checks and marshals the content of the parameters of a WPS request into a WPSParams struct.

Jump to

Keyboard shortcuts

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