handlers

package
v0.0.0-...-97c21ed Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2016 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package handlers provides support for various handlers within the PDAL microservice.

The primary handler is for calls to the /pdal endpoint. Currently, this parses the S3 bucket/key from the incoming JSON message, downloads the data, and executes the PDAL application with the given function name (e.g., info, translate).

The /pdal resource can be extended by adding additional functions. To add a new function, simply add a case statement such as:

case "foo":
  utils.MakeFunction(functions.Foo)(w, r, &res, msg)

This will call the MakeFunction routine within the github.com/venicegeo/pzsvc-sdk-go/utils package, downloading source data, processing the data using your custome Foo function, and uploading the result, as needed.

Your custom function should have the following signature.

type FunctionFunc func(http.ResponseWriter, *http.Request, *job.OutputMsg, job.InputMsg)

The http.ResponseWriter is required so that we can properly communicate errors back. The http.Request was originally included so that we would have access to the original Request - not exactly sure it will be needed. The input and output job messages are required so that we can understand the job that has been dispatched to us and so that we can return the proper response.

We need to add more documentation to the github.com/venicegeo/pzsvc-pdal/functions package, but this is where the magic actually happens. Everything here, in the end, is just a call to PDAL. You should be able to do anything that PDAL can do (depending of course on how you've build PDAL). That includes running kernels (info, translate, merge) and creating pipelines from the CLI. We tend to do more of the latter. Our function options correspond to PDAL CLI arguments. We assume that we always have one input file and one output file (though that's not even a hard requirement). The remainder of the options are parsed and passed. Close examination of any of the existing functions should give you a pretty good sense of what is going on.

The translate function is the all-powerful function (many of the other functions are themselves just translate calls with a little sugar on top). Translate takes a single string as a parameter, which is passed to PDAL. As long as this is something you could run locally with the PDAL CLI, it will run here.

$ pdal translate <input> <output> [everything else]

For example,

$ pdal translate <input> <output> ground
$ pdal translate <input> <output> statisticaloutlier ground height ferry --filters.ferry.dimensions="Height=Z"

Many custom functions will simply be building up these types of PDAL pipelines for common operations. The same readers, writers, and filters can be used in different configurations and with different parameters to produce very different products (e.g., terrain model generation vs. feature extraction).

A secondary handler is a simplified mockup of the Piazza job manager for updating job status.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppError

type AppError struct {
	Error   error
	Message string
	Code    int
}

func PdalHandler

func PdalHandler(w http.ResponseWriter, r *http.Request) *AppError

PdalHandler handles PDAL jobs.

func PipelineHandler

func PipelineHandler(w http.ResponseWriter, r *http.Request) *AppError

PipelineHandler handles PDAL jobs.

func VoHandler

func VoHandler(w http.ResponseWriter, r *http.Request) *AppError

VoHandler handles PDAL jobs.

type FunctionFunc

type FunctionFunc func(InputMsg) ([]byte, error)

FunctionFunc defines the signature of our function creator.

func MakeFunction

func MakeFunction(fn func(string, string, *json.RawMessage) ([]byte, error)) FunctionFunc

MakeFunction wraps the individual PDAL functions. Parse the input and output filenames, creating files as needed. Download the input data and upload the output data.

type InputMsg

type InputMsg struct {
	Source      interface{}      `json:"source,omitempty"`
	Function    *string          `json:"function,omitempty"`
	Options     *json.RawMessage `json:"options,omitempty"`
	Destination s3.Bucket        `json:"destination,omitempty"`
}

InputMsg defines the expected input JSON structure. We currently support S3 input (bucket/key), though provider-specific (e.g., GRiD) may be legitimate.

type VoOptions

type VoOptions struct {
	Filename    *string `json:"filename"` // list of input file paths
	AGL         float64 `json:"agl"`
	MaxSize     uint16  `json:"max_size"`
	MinSize     uint16  `json:"min_size"`
	Resolution  float64 `json:"resolution"`
	Tolerance   float64 `json:"tolerance"`
	Z0Tolerance float64 `json:"z0_tolerance"`
	Denoise     bool    `json:"denoise"`
	InSRS       *string `json:"in_srs"`
	OutSRS      *string `json:"out_srs"`
}

VoOptions defines options for the VO function.

func NewVoOptions

func NewVoOptions() *VoOptions

NewVoOptions constructs VoOptions with default values.

Jump to

Keyboard shortcuts

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