diff --git a/layer_proc.go b/layer_proc.go index d5413a4..df4a36d 100644 --- a/layer_proc.go +++ b/layer_proc.go @@ -1,6 +1,7 @@ package main import ( + "context" "encoding/json" "fmt" "net/http" @@ -8,16 +9,6 @@ import ( "sort" "strings" - // "net/url" - - // REST routing - - // Database - "context" - // "github.com/jackc/pgtype" - // "github.com/lib/pq" - // "github.com/jackc/pgtype" - // Logging log "github.com/sirupsen/logrus" @@ -174,64 +165,6 @@ func (lyr *LayerFunction) getFunctionDetailJson(req *http.Request) (FunctionDeta return td, nil } -/* -func (lyr *LayerFunction) GetLayerFunctionArgs(vals url.Values) map[string]string { - funcArgs := make(map[string]string) - for _, arg := range lyr.Arguments { - if val, ok := vals[arg]; ok { - funcArgs[arg] = val[0] - } - } - return funcArgs -} -*/ - -func (lyr *LayerFunction) GetTile(tile *Tile, args map[string]string) ([]byte, error) { - - db, err := DbConnect() - if err != nil { - log.Fatal(err) - } - - // Need ordered list of named parameters and values to - // pass into the Query - keys := make([]string, 0) - vals := make([]interface{}, 0) - i := 1 - for k, v := range args { - keys = append(keys, fmt.Sprintf("%s => $%d", k, i)) - switch k { - case "x": - vals = append(vals, tile.X) - case "y": - vals = append(vals, tile.Y) - case "z": - vals = append(vals, tile.Zoom) - default: - vals = append(vals, v) - } - i += 1 - } - - // Build the SQL - sql := fmt.Sprintf("SELECT %s(%s)", lyr.Id, strings.Join(keys, ", ")) - log.WithFields(log.Fields{ - "event": "function.gettile", - "topic": "sql", - "key": sql, - }).Debugf("Func GetTile: %s", sql) - - row := db.QueryRow(context.Background(), sql, vals...) - var mvtTile []byte - err = row.Scan(&mvtTile) - if err != nil { - log.Warn(err) - return nil, err - } else { - return mvtTile, nil - } -} - func GetFunctionLayers() ([]LayerFunction, error) { // Valid functions **must** have signature of diff --git a/layer_table.go b/layer_table.go index 90f1d4d..c7ad8c5 100644 --- a/layer_table.go +++ b/layer_table.go @@ -10,11 +10,10 @@ import ( "strconv" "strings" - // REST routing - - // "github.com/lib/pq" - + // Database "github.com/jackc/pgtype" + + // Logging log "github.com/sirupsen/logrus" // Configuration