geography/handlers/admin/storage.go

26 lines
575 B
Go

package admin
import (
"fmt"
"github.com/paulmach/orb/geojson"
"github.com/spf13/viper"
)
type AdminIndex interface {
GeoSearch(*geojson.Feature) (map[string]*geojson.Feature, error)
Find(layer, id string) (*geojson.Feature, error)
}
func NewAdminIndex(cfg *viper.Viper) (AdminIndex, error) {
storage_type := cfg.GetString("storage.index.type")
if storage_type == "bleve" {
return NewAdminBleveIndex(cfg)
} else if storage_type == "memory_rtree" {
return NewAdminMemoryRTreeIndex(cfg)
}
return nil, fmt.Errorf("unknown storage type : %v", storage_type)
}