gospatial

package
v0.0.0-...-6555678 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2018 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TCP_DEFAULT_CONN_HOST = "localhost"
	TCP_DEFAULT_CONN_PORT = "3333"
	TCP_DEFAULT_CONN_TYPE = "tcp"
)
View Source
const HTTP_DEFAULT_PORT = 8080
View Source
const (
	VERSION string = "1.11.4"
)

Variables

View Source
var (
	DB              Database
	COMMIT_LOG_FILE string = "commit.log"
)

DB application Database

View Source
var (
	Verbose       bool = false
	ServerLogger  seelog.LoggerInterface
	NetworkLogger seelog.LoggerInterface
	LogDirectory  string = "log"
	LogLevel      string = "trace"
)
View Source
var (
	ActiveTcpClients int
)
View Source
var Hub = hub{
	Sockets: make(map[string]map[int]*websocket.Conn),
}

Hub contains active websockets for bidirectional communication

View Source
var (
	SuperuserKey string = utils.NewAPIKey(12)
)

Functions

func AllCustomerDatasources

func AllCustomerDatasources(w http.ResponseWriter, r *http.Request)

Pull all customer datasource pairs Distributed System

func CheckAuthKey

func CheckAuthKey(w http.ResponseWriter, r *http.Request) bool

check request for valid authkey

func CheckCustomerForDatasource

func CheckCustomerForDatasource(w http.ResponseWriter, r *http.Request, customer Customer, ds string) bool

Check customer datasource list

func DashboardHandler

func DashboardHandler(w http.ResponseWriter, r *http.Request)

DashboardHandler returns customer management gui. Allows customers to create and delete both geojson layers and tile baselayers.

func DeleteLayerHandler

func DeleteLayerHandler(w http.ResponseWriter, r *http.Request)

DeleteLayerHandler deletes layer from database and removes it from customer list. @param ds @param apikey @return json

func DisableLog

func DisableLog()

DisableLog disables all library log output

func EditFeatureHandler

func EditFeatureHandler(w http.ResponseWriter, r *http.Request)

EditFeatureHandler finds feature in layer via array index. Edits feature. @param apikey customer id @oaram ds datasource uuid

func GetApikeyFromRequest

func GetApikeyFromRequest(w http.ResponseWriter, r *http.Request) string

Check for apikey in request

func IndexHandler

func IndexHandler(w http.ResponseWriter, r *http.Request)

IndexHandler returns html page containing api docs

func MapHandler

func MapHandler(w http.ResponseWriter, r *http.Request)

MapHandler returns leaflet map view for customer layers @param apikey customer id @return map template

func MarshalJsonFromString

func MarshalJsonFromString(w http.ResponseWriter, r *http.Request, data string) ([]byte, error)

func MarshalJsonFromStruct

func MarshalJsonFromStruct(w http.ResponseWriter, r *http.Request, data interface{}) ([]byte, error)

func NewCustomerHandler

func NewCustomerHandler(w http.ResponseWriter, r *http.Request)

NewCustomerHandler superuser route to create new api customers/apikeys

func NewFeatureHandler

func NewFeatureHandler(w http.ResponseWriter, r *http.Request)

NewFeatureHandler creates a new feature and adds it to a layer. Layer is then saved to database. All active clients viewing layer are notified of update via websocket hub. @param apikey customer id @oaram ds datasource uuid @return json

func NewLayerHandler

func NewLayerHandler(w http.ResponseWriter, r *http.Request)

NewLayerHandler creates a new geojson layer. Saves layer to database and adds layer to customer @param apikey @return json

func NewTileLayerHandler

func NewTileLayerHandler(w http.ResponseWriter, r *http.Request)

NewLayerHandler creates a new geojson layer. Saves layer to database and adds layer to customer @param apikey @return json

func PingHandler

func PingHandler(w http.ResponseWriter, r *http.Request)

PingHandler provides an api route for server health check

func ResetLogging

func ResetLogging()

func RoundToPrecision

func RoundToPrecision(f float64, places int) float64

func Router

func Router() *mux.Router

Router for http api calls

func SendJsonResponse

func SendJsonResponse(w http.ResponseWriter, r *http.Request, js []byte)

Sends http response

func ViewFeatureHandler

func ViewFeatureHandler(w http.ResponseWriter, r *http.Request)

ViewFeatureHandler finds feature in layer via array index. Returns feature geojson. @param apikey customer id @oaram ds datasource uuid @return feature geojson

func ViewLayerHandler

func ViewLayerHandler(w http.ResponseWriter, r *http.Request)

ViewLayerHandler returns geojson of requested layer. Apikey/customer is checked for permissions to requested layer. @param ds @param apikey @return geojson

func ViewLayersHandler

func ViewLayersHandler(w http.ResponseWriter, r *http.Request)

ViewLayersHandler returns json containing customer layers @param apikey customer id @return json

Types

type Customer

type Customer struct {
	Apikey      string      `json:"apikey"`
	Datasources []string    `json:"datasources"`
	TileLayers  []TileLayer `json:"tilelayers"`
}

Customer structure for database

func GetCustomerFromDatabase

func GetCustomerFromDatabase(w http.ResponseWriter, r *http.Request, apikey string) (Customer, error)

Get customer from database

type Database

type Database struct {
	File    string
	Cache   map[string]*LayerCache
	Apikeys map[string]Customer

	Precision int
	WriteLock bool
	// contains filtered or unexported fields
}

Database strust for application.

func (*Database) CommitQueueLength

func (self *Database) CommitQueueLength() int

CommitQueueLength returns length of database commit_log_queue @returns int

func (*Database) Connect

func (self *Database) Connect() *bolt.DB

Connect to bolt database. Returns open database connection. @returns *bolt.DB

func (*Database) CreateTable

func (self *Database) CreateTable(conn *bolt.DB, table string) error

CreateTable creates bucket to store data @param table @returns Error

func (*Database) DeleteLayer

func (self *Database) DeleteLayer(datasource_id string) error

DeleteLayer deletes layer from database @param datasource {string} @returns Error

func (*Database) EditFeature

func (self *Database) EditFeature(datasource_id string, geo_id string, feat *geojson.Feature) error

EditFeature Edits feature in layer. Updates layer in Database @param datasource {string} @param geo_id {string} @param feat {Geojson Feature} @returns Error

func (*Database) GetCustomer

func (self *Database) GetCustomer(apikey string) (Customer, error)

GetCustomer returns customer from database @param apikey {string} @returns Customer @returns Error

func (*Database) GetLayer

func (self *Database) GetLayer(datasource_id string) (*geojson.FeatureCollection, error)

GetLayer returns layer from database @param datasource {string} @returns Geojson @returns Error

func (*Database) Init

func (self *Database) Init() error

Init creates bolt database if existing one not found. Creates layers and apikey tables. Starts database caching for layers @returns Error

func (*Database) Insert

func (self *Database) Insert(table string, key string, value []byte) error

func (*Database) InsertCustomer

func (self *Database) InsertCustomer(customer Customer) error

InsertCustomer inserts customer into apikeys table @param customer {Customer} @returns Error

func (*Database) InsertFeature

func (self *Database) InsertFeature(datasource_id string, feat *geojson.Feature) error

InsertFeature adds feature to layer. Updates layer in Database @param datasource {string} @param feat {Geojson Feature} @returns Error

func (*Database) InsertLayer

func (self *Database) InsertLayer(datasource_id string, geojs *geojson.FeatureCollection) error

InsertLayer inserts layer into database @param datasource {string} @param geojs {Geojson} @returns Error

func (*Database) NewLayer

func (self *Database) NewLayer() (string, error)

NewLayer creates new datasource layer @returns string - datasource id @returns Error TODO: RENAME TO NewDatasource

func (*Database) Select

func (self *Database) Select(table string, key string) ([]byte, error)

func (*Database) SelectAll

func (self *Database) SelectAll(table string) ([]string, error)

type HttpMessageResponse

type HttpMessageResponse struct {
	Status     string      `json:"status"`
	Datasource string      `json:"datasource,omitempty"`
	Apikey     string      `json:"apikey,omitempty"`
	Data       interface{} `json:"data,omitempty"`
}

type HttpServer

type HttpServer struct {
	Port int
}

func (HttpServer) Start

func (self HttpServer) Start()

type LayerCache

type LayerCache struct {
	Geojson *geojson.FeatureCollection
	Time    time.Time
}

LayerCache keeps track of Database's loaded geojson layers

type PageViewData

type PageViewData struct {
	Apikey  string
	Version string
}

MapData for html templates

type TcpData

type TcpData struct {
	Apikey      string                     `json:"apikey"`
	Datasources []string                   `json:"datasources"`
	Datasource  string                     `json:"datasource"`
	Layer       *geojson.FeatureCollection `json:"layer"`
	Feature     *geojson.Feature           `json:"feature"`
	GeoId       string                     `json:"geo_id"`
}

type TcpMessage

type TcpMessage struct {
	Authkey    string  `json:"authkey"`
	Apikey     string  `json:"apikey"`
	Method     string  `json:"method"`
	Data       TcpData `json:"data"`
	Datasource string  `json:"datasource"`
	File       string  `json:"file"`
}

type TcpServer

type TcpServer struct {
	Host             string
	Port             string
	ActiveTcpClients int
}

func (TcpServer) Start

func (self TcpServer) Start()

type TileLayer

type TileLayer struct {
	Url  string `json:"url"`
	Name string `json:"name"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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