diff --git a/datastore.go b/datastore.go index ba1e0c8..a4519e8 100644 --- a/datastore.go +++ b/datastore.go @@ -2,6 +2,7 @@ package gismanager import "fmt" +//DatastoreConfig configuration type DatastoreConfig struct { Host string `yaml:"host"` Port uint `yaml:"port"` @@ -11,7 +12,7 @@ type DatastoreConfig struct { Name string `yaml:"name"` } -//BuildConnectionString return gdal postgres connection as string +//BuildConnectionString return GDAL postgres connection as string func (ds *DatastoreConfig) BuildConnectionString() string { return fmt.Sprintf("PG: host=%s port=%d dbname=%s user=%s password=%s", ds.Host, ds.Port, ds.DBName, ds.DBUser, ds.DBPass) } diff --git a/layer.go b/layer.go index ac92111..68def0f 100644 --- a/layer.go +++ b/layer.go @@ -13,13 +13,13 @@ type GdalLayer struct { *gdal.Layer } -//LayerField Field +//LayerField Layer Field type LayerField struct { Name string Type string } -//PublishGeoserverLayer publish Layer to postgis +//PublishGeoserverLayer Publish Layer to Geoserver instance func (manager *ManagerConfig) PublishGeoserverLayer(layer *GdalLayer) (ok bool, err error) { catalog := manager.GetGeoserverCatalog() workspaceExists, _ := catalog.WorkspaceExists(manager.Geoserver.WorkspaceName) @@ -89,6 +89,9 @@ func (layer *GdalLayer) LayerToPostgis(targetSource *gdal.DataSource, manager *M func (layer *GdalLayer) GetGeomtryName() (geometryName string) { geom := gdal.Create(layer.Layer.Type()) geometryName = geom.Name() + if len(geometryName) == 0 { + geometryName = "geom" + } return } @@ -97,9 +100,6 @@ func (layer *GdalLayer) GetLayerSchema() (fields []*LayerField) { if layer.Layer != nil { layerDef := layer.Layer.Definition() geomName := layer.Layer.GeometryColumn() - if len(geomName) == 0 { - geomName = "geom" - } geomField := LayerField{ Name: geomName, Type: layer.GetGeomtryName(), diff --git a/manager.go b/manager.go index c256084..155a68c 100644 --- a/manager.go +++ b/manager.go @@ -31,13 +31,13 @@ type ManagerConfig struct { logger *logrus.Logger } -//GetGeoserverCatalog publish return geoserver Catalog +//GetGeoserverCatalog return geoserver Catalog instance to deal with geoserver func (manager *ManagerConfig) GetGeoserverCatalog() *gsconfig.GeoServer { gsCatalog := gsconfig.GetCatalog(manager.Geoserver.ServerURL, manager.Geoserver.Username, manager.Geoserver.Password) return gsCatalog } -//OpenSource open data source from path +//OpenSource open data source from a given Path and access permission 0/1 func (manager *ManagerConfig) OpenSource(path string, access int) (source *gdal.DataSource, ok bool) { driver, err := manager.GetDriver(path) if err != nil { @@ -51,7 +51,7 @@ func (manager *ManagerConfig) OpenSource(path string, access int) (source *gdal. return } -//GetDriver return the proper driver based on file path +//GetDriver return the proper driver based on file path/database connection func (manager *ManagerConfig) GetDriver(path string) (driver gdal.OGRDriver, err error) { if pgRegex.MatchString(path) { driver = gdal.OGRDriverByName(postgreSQLDriver) diff --git a/utils.go b/utils.go index 4805784..3de6425 100644 --- a/utils.go +++ b/utils.go @@ -17,7 +17,7 @@ import ( yaml "gopkg.in/yaml.v2" ) -//FromConfig load geoserver config from yaml file +//FromConfig load GIS Manager config from yaml file func FromConfig(configFile string) (config *ManagerConfig, err error) { gpkgConfig := ManagerConfig{} gpkgConfig.logger = GetLogger()