Skip to content

Commit

Permalink
Merge pull request #6 from USACE/feature/2d-areas
Browse files Browse the repository at this point in the history
Feature/2d areas
  • Loading branch information
ShaneMPutnam committed Jan 11, 2021
2 parents 8439447 + 99e9c67 commit 6110a47
Show file tree
Hide file tree
Showing 10 changed files with 1,206 additions and 434 deletions.
8 changes: 5 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (
)

type APIConfig struct {
Host string
Port int
FileStore *filestore.FileStore
Host string
Port int
FileStore *filestore.FileStore
DestinationCRS int
}

// Address tells the application where to run the api out of
Expand All @@ -24,6 +25,7 @@ func Init() *APIConfig {
config.Host = "" // 0.0.0.0
config.Port = 5600
config.FileStore = FileStoreInit(false)
config.DestinationCRS = 4326
return config
}

Expand Down
8 changes: 4 additions & 4 deletions handlers/geospatialdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package handlers
import (
"net/http"

"github.com/USACE/mcat-ras/config"
ras "github.com/USACE/mcat-ras/tools"

"github.com/USACE/filestore"
"github.com/labstack/echo/v4"
)

Expand All @@ -19,17 +19,17 @@ import (
// @Success 200 {object} interface{}
// @Failure 500 {object} SimpleResponse
// @Router /geospatialdata [get]
func GeospatialData(fs *filestore.FileStore) echo.HandlerFunc {
func GeospatialData(ac *config.APIConfig) echo.HandlerFunc {
return func(c echo.Context) error {

definitionFile := c.QueryParam("definition_file")

rm, err := ras.NewRasModel(definitionFile, *fs)
rm, err := ras.NewRasModel(definitionFile, *ac.FileStore)
if err != nil {
return c.JSON(http.StatusInternalServerError, SimpleResponse{http.StatusInternalServerError, err.Error()})
}

data, err := rm.GeospatialData()
data, err := rm.GeospatialData(ac.DestinationCRS)
if err != nil {
return c.JSON(http.StatusInternalServerError, SimpleResponse{http.StatusInternalServerError, err.Error()})
}
Expand Down
10 changes: 5 additions & 5 deletions handlers/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ func Index(fs *filestore.FileStore) echo.HandlerFunc {
if err != nil {
return c.JSON(http.StatusInternalServerError, SimpleResponse{http.StatusInternalServerError, err.Error()})
}
mod, err := rm.Index()
if err != nil {
return c.JSON(http.StatusInternalServerError, SimpleResponse{http.StatusInternalServerError, err.Error()})
}
// mod, err := rm.Index()
// if err != nil {
// return c.JSON(http.StatusInternalServerError, SimpleResponse{http.StatusInternalServerError, err.Error()})
// }

return c.JSON(http.StatusOK, mod)
return c.JSON(http.StatusOK, rm)
}
}
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func main() {
e.GET("/isgeospatial", handlers.IsGeospatial(appConfig.FileStore))
e.GET("/modeltype", handlers.ModelType(appConfig.FileStore))
e.GET("/modelversion", handlers.ModelVersion(appConfig.FileStore))
e.GET("/geospatialdata", handlers.GeospatialData(appConfig.FileStore))
e.GET("/geospatialdata", handlers.GeospatialData(appConfig))

e.Logger.Fatal(e.Start(appConfig.Address()))
}
Loading

0 comments on commit 6110a47

Please sign in to comment.