domain

package
v0.0.0-...-86abe10 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAccountExists   = errors.New("Account already exists")
	ErrAccountActive   = errors.New("Account was already activated")
	ErrAccountNotFound = errors.New("Account not found")
)
View Source
var (
	ErrProjectNotExists     = errors.New("project does not exists")
	ErrFileNotExists        = errors.New("project file does not exists")
	ErrProjectAlreadyExists = errors.New("project already exists")
)
View Source
var (
	ErrInvalidQgisMeta = errors.New("invalid qgis meta data")
)
View Source
var ErrInvalidTree = errors.New("Invalid tree structure")

Functions

This section is empty.

Types

type Account

type Account struct {
	Username  string
	Email     string
	Password  []byte
	FirstName string
	LastName  string
	Superuser bool
	Active    bool
	Created   *time.Time
	Confirmed *time.Time
	LastLogin *time.Time
	Profile   Profile
}

Account entity

func NewAccount

func NewAccount(username, email, firstName, lastName, password string) (Account, error)

func (*Account) Activate

func (a *Account) Activate() error

func (*Account) CheckPassword

func (a *Account) CheckPassword(password string) bool

func (*Account) FullName

func (a *Account) FullName() string

func (*Account) IsActive

func (a *Account) IsActive() bool

func (*Account) SetPassword

func (a *Account) SetPassword(password string) error

type AccountConfig

type AccountConfig struct {
	ProjectsCountLimit int      `json:"projects_limit"`
	ProjectSizeLimit   ByteSize `json:"project_size_limit"`
	StorageLimit       ByteSize `json:"storage_limit"`
}

func (*AccountConfig) CheckProjectSizeLimit

func (c *AccountConfig) CheckProjectSizeLimit(size int64) bool

func (*AccountConfig) CheckProjectsLimit

func (c *AccountConfig) CheckProjectsLimit(count int) bool

func (*AccountConfig) CheckStorageLimit

func (c *AccountConfig) CheckStorageLimit(size int64) bool

func (*AccountConfig) HasProjectSizeLimit

func (c *AccountConfig) HasProjectSizeLimit() bool

func (*AccountConfig) HasStorageLimit

func (c *AccountConfig) HasStorageLimit() bool

type AccountsRepository

type AccountsRepository interface {
	Create(account Account) error
	Update(account Account) error
	UpdateProfile(account Account) error
	UpdateProfile2(username string, profile Profile) error
	Delete(username string) error
	GetByUsername(username string) (Account, error)
	GetByEmail(email string) (Account, error)
	EmailExists(email string) (bool, error)
	UsernameExists(username string) (bool, error)
	GetAllAccounts() ([]Account, error)
	GetActiveAccounts() ([]Account, error)
}

AccountsRepository repository interface

type AttributeSettings

type AttributeSettings struct {
	Widget    string                 `json:"widget,omitempty"`
	Config    map[string]interface{} `json:"config,omitempty"`
	Formatter string                 `json:"format,omitempty"`
}

type Authentication

type Authentication struct {
	Type  string        `json:"type"`
	Users []string      `json:"users,omitempty"`
	Roles []ProjectRole `json:"roles,omitempty"`
}

type ByteSize

type ByteSize int64

func (*ByteSize) Set

func (b *ByteSize) Set(s string) error

Satisfy the flag package Value interface.

func (*ByteSize) UnmarshalJSON

func (s *ByteSize) UnmarshalJSON(b []byte) error

type FieldsConfig

type FieldsConfig struct {
	Global    StringArray `json:"global,omitempty"`
	Infopanel StringArray `json:"infopanel,omitempty"`
	Table     StringArray `json:"table,omitempty"`
}

type FileInfo

type FileInfo struct {
	Hash  string `json:"hash,omitempty"`
	Size  int64  `json:"size"`
	Mtime int64  `json:"mtime"`
}

type FilesChanges

type FilesChanges struct {
	Removes []string
	Updates []ProjectFile
}

type FilesReader

type FilesReader func() (string, io.ReadCloser, error)

type Flags

type Flags []string

func (Flags) Clone

func (f Flags) Clone() Flags

func (Flags) Filter

func (f Flags) Filter(test func(item string) bool) []string

func (Flags) Has

func (f Flags) Has(flag string) bool

func (Flags) Intersection

func (f Flags) Intersection(flags Flags) Flags

func (Flags) Union

func (f Flags) Union(flags Flags) Flags

type Geocoding

type Geocoding struct {
	Service     string             `json:"service,omitempty"`
	URL         string             `json:"url,omitempty"`
	QueryParams []SearchQueryParam `json:"query_params,omitempty"`
}

type GroupSettings

type GroupSettings struct {
	Collapsed    bool `json:"collapsed"`
	VirtualLayer bool `json:"virtual_layer"`
}

type GroupTreeNode

type GroupTreeNode struct {
	Name              string     `json:"name"`
	WmsName           string     `json:"wms_name,omitempty"`
	Layers            []TreeNode `json:"layers"`
	MutuallyExclusive bool       `json:"mutually_exclusive,omitempty"`
}

func (GroupTreeNode) Children

func (g GroupTreeNode) Children() []TreeNode

func (GroupTreeNode) GroupName

func (g GroupTreeNode) GroupName() string

func (GroupTreeNode) IsGroup

func (g GroupTreeNode) IsGroup() bool

func (GroupTreeNode) LayerID

func (g GroupTreeNode) LayerID() string

type LayerAttribute

type LayerAttribute struct {
	Alias       string                 `json:"alias,omitempty"`
	Name        string                 `json:"name"`
	Type        string                 `json:"type"`
	Constraints Flags                  `json:"constraints,omitempty"`
	Widget      string                 `json:"widget,omitempty"`
	Config      map[string]interface{} `json:"config,omitempty"`
	Format      string                 `json:"format,omitempty"`
}

type LayerMeta

type LayerMeta struct {
	Id           string                     `json:"id"`
	Name         string                     `json:"name"`
	Title        string                     `json:"title"`
	Type         string                     `json:"type"`
	Extent       []float64                  `json:"extent"`
	Projection   string                     `json:"projection"`
	Flags        Flags                      `json:"flags"`
	LegendURL    string                     `json:"legend_url,omitempty"`
	Provider     string                     `json:"provider_type"`
	SourceParams QueryParams                `json:"source_params"`
	Metadata     map[string]string          `json:"metadata"`
	Attribution  map[string]string          `json:"attribution,omitempty"`
	Attributes   []LayerAttribute           `json:"attributes,omitempty"` // vector layers
	Bands        []string                   `json:"bands,omitempty"`      // raster layers
	Options      map[string]json.RawMessage `json:"options,omitempty"`
	Visible      bool                       `json:"visible"`
	Relations    []map[string]any           `json:"relations,omitempty"`
}

type LayerNode

type LayerNode struct {
	ID     string      `json:"id"`
	Name   string      `json:"name"`
	Layers []LayerNode `json:"layers"`
}

type LayerPermission

type LayerPermission struct {
	View         bool `json:"view"`
	Insert       bool `json:"insert"`
	Update       bool `json:"update"`
	Delete       bool `json:"delete"`
	EditGeometry bool `json:"edit_geom"`
}

type LayerSettings

type LayerSettings struct {
	Flags              Flags                        `json:"flags"`
	Attributes         map[string]AttributeSettings `json:"attributes"`
	InfoPanelComponent string                       `json:"infopanel_component,omitempty"` // or group with other possible settings into generic map[string]interface{}
	// AttributeTableFields []string                     `json:"attr_table_fields,omitempty"`   // TODO: remove
	// InfoPanelFields      []string                     `json:"info_panel_fields,omitempty"`   // TODO: remove
	ExportFields []string `json:"export_fields,omitempty"`
	// FieldsOrder          json.RawMessage              `json:"fields_order,omitempty"`
	// ExcludedFields   json.RawMessage `json:"excluded_fields,omitempty"`
	FieldsOrder      *FieldsConfig             `json:"fields_order,omitempty"`
	ExcludedFields   *FieldsConfig             `json:"excluded_fields,omitempty"`
	LegendDisabled   bool                      `json:"legend_disabled,omitempty"`
	QgisRelations    map[string]map[string]any `json:"qgis_relations,omitempty"`
	Relations        []map[string]any          `json:"relations,omitempty"`
	CustomProperties json.RawMessage           `json:"custom,omitempty"`
}

type LayerTreeNode

type LayerTreeNode struct {
	ID string `json:"id"`
}

func (LayerTreeNode) Children

func (l LayerTreeNode) Children() []TreeNode

func (LayerTreeNode) GroupName

func (l LayerTreeNode) GroupName() string

func (LayerTreeNode) IsGroup

func (l LayerTreeNode) IsGroup() bool

func (LayerTreeNode) LayerID

func (l LayerTreeNode) LayerID() string

type Object

type Object = map[string]interface{}

type ParamValue

type ParamValue []string
type ParamValue struct {
	values []string
}
func (p *ParamValue) UnmarshalJSON(b []byte) error {
	if len(b) == 0 {
		return fmt.Errorf("no bytes to unmarshal")
	}
	switch b[0] {
	case '"':
		var value string
		if err := json.Unmarshal(b, &value); err != nil {
			return err
		}
		p.values = []string{value}
	case '[':
		return json.Unmarshal(b, &p.values)
	}
	return nil
}
func (p *ParamValue) String() string {
	if len(p.values) > 0 {
		return p.values[0]
	}
	return ""
}
func (p *ParamValue) StringArray() []string {
	return p.values
}

func (*ParamValue) String

func (p *ParamValue) String() string

func (*ParamValue) StringArray

func (p *ParamValue) StringArray() []string

func (*ParamValue) UnmarshalJSON

func (p *ParamValue) UnmarshalJSON(b []byte) error

type Profile

type Profile map[string]any

type Project

type Project struct {
	Info     ProjectFileInfo
	Meta     map[string]interface{}
	Settings ProjectSettings
}

TODO: remove

func (*Project) ProjectionCode

func (p *Project) ProjectionCode() string

type ProjectFile

type ProjectFile struct {
	Path  string `json:"path"`
	Hash  string `json:"hash,omitempty"`
	Size  int64  `json:"size"`
	Mtime int64  `json:"mtime"`
}

type ProjectFileInfo

type ProjectFileInfo struct {
	User     string
	Folder   string
	Name     string
	FullName string
	Map      string
}

Old code, currently used in mapcache package

type ProjectInfo

type ProjectInfo struct {
	Name           string    `json:"name,omitempty"`
	Title          string    `json:"title"`
	QgisFile       string    `json:"qgis_file"`
	Created        time.Time `json:"created"`
	LastUpdate     time.Time `json:"last_update"`
	Projection     string    `json:"projection"` // projection code
	Mapcache       bool      `json:"mapcache"`
	Authentication string    `json:"authentication"`
	// empty, pending update, hidden
	State     string `json:"state"`
	Size      int64  `json:"size"` // size in bytes
	Thumbnail bool   `json:"thumbnail"`
}

type ProjectRole

type ProjectRole struct {
	Auth        string          `json:"type"`
	Name        string          `json:"name"`
	Note        string          `json:"note,omitempty"`
	Users       []string        `json:"users"`
	Permissions RolePermissions `json:"permissions"`
}

func FilterUserRoles

func FilterUserRoles(u User, roles []ProjectRole) []ProjectRole

type ProjectSettings

type ProjectSettings struct {
	Auth             Authentication           `json:"auth"`
	SettingsAuth     SettingsAuthentication   `json:"settings_auth"`
	BaseLayers       []string                 `json:"base_layers"`
	Layers           map[string]LayerSettings `json:"layers"`
	Groups           map[string]GroupSettings `json:"groups"`
	Title            string                   `json:"title"`
	MapCache         bool                     `json:"use_mapcache"`
	Topics           []Topic                  `json:"topics"`
	Extent           []float64                `json:"extent"`
	InitialExtent    []float64                `json:"initial_extent"`
	Scales           json.RawMessage          `json:"scales"`
	TileResolutions  []float64                `json:"tile_resolutions"`
	MapTiling        bool                     `json:"map_tiling"`
	Formatters       []json.RawMessage        `json:"formatters,omitempty"`
	Proj4            map[string]string        `json:"proj4,omitempty"`
	Geocoding        *Geocoding               `json:"geocoding"`
	SearchByLocation bool                     `json:"search_by_coords"`
}

func (ProjectSettings) UserLayerAttrinutesFlags

func (s ProjectSettings) UserLayerAttrinutesFlags(u User, layerId string) map[string]Flags

func (ProjectSettings) UserLayerPermissionsFlags

func (s ProjectSettings) UserLayerPermissionsFlags(u User, layerId string) Flags

type Projection

type Projection struct {
	Proj4       string `json:"proj4"`
	IsGeografic bool   `json:"is_geographic"`
}

type ProjectsRepository

type ProjectsRepository interface {
	CheckProjectExists(name string) bool
	Create(name string, qmeta json.RawMessage) (*ProjectInfo, error)
	AllProjects(skipErrors bool) ([]string, error)
	UserProjects(user string) ([]string, error) // or should it require User object?
	GetProjectInfo(name string) (ProjectInfo, error)
	Delete(name string) error
	// SaveFile(projectName, filename string, r io.Reader) error
	CreateFile(projectName, directory, pattern string, r io.Reader) (ProjectFile, error)
	SaveFile(project string, finfo ProjectFile, path string) error

	GetFileInfo(project, path string) (FileInfo, error)
	GetFilesInfo(project string, paths ...string) (map[string]FileInfo, error)
	ListProjectFiles(project string, checksum bool) ([]ProjectFile, []ProjectFile, error)

	ParseQgisMetadata(projectName string, data interface{}) error
	UpdateMeta(projectName string, meta json.RawMessage) error

	GetSettings(projectName string) (ProjectSettings, error)
	UpdateSettings(projectName string, data json.RawMessage) error

	GetThumbnailPath(projectName string) string
	SaveThumbnail(projectName string, r io.Reader) error

	UpdateFiles(projectName string, info FilesChanges, next FilesReader) ([]ProjectFile, error)
	GetScripts(projectName string) (Scripts, error)
	UpdateScripts(projectName string, scripts Scripts) error
	GetProjectCustomizations(projectName string) (json.RawMessage, error)
	Close()
}

type QgisMeta

type QgisMeta struct {
	File   string    `json:"file"`
	Title  string    `json:"title"`
	Extent []float64 `json:"extent"`
	Scales []float64 `json:"scales"`
	// LayersTree        []TreeNode             `json:"layers_tree"`
	LayersTree        []interface{}          `json:"layers_tree"`
	LayersOrder       []string               `json:"layers_order"`
	BaseLayers        []string               `json:"base_layers"`
	Layers            map[string]LayerMeta   `json:"layers"`
	Projection        string                 `json:"projection"`
	Projections       map[string]*Projection `json:"projections"`
	Units             map[string]interface{} `json:"units"`
	ComposerTemplates []interface{}          `json:"composer_templates"`
	Client            map[string]interface{} `json:"client_info"`
	ProjectHash       string                 `json:"project_hash"`
}

type QueryParams

type QueryParams map[string]json.RawMessage

func (QueryParams) String

func (p QueryParams) String(key string) string

func (QueryParams) StringArray

func (p QueryParams) StringArray(key string) []string

func (QueryParams) Value

func (p QueryParams) Value(key string) (ParamValue, bool)

type RolePermissions

type RolePermissions struct {
	Attributes map[string]map[string]Flags `json:"attributes"`
	Layers     map[string]Flags            `json:"layers"`
	Topics     []string                    `json:"topics"`
}

type ScriptModule

type ScriptModule struct {
	Path       string   `json:"path"`
	Components []string `json:"components"`
}

type Scripts

type Scripts map[string]ScriptModule

type SearchQueryParam

type SearchQueryParam struct {
	Path  string `json:"path"`
	Name  string `json:"name"`
	Value string `json:"value"`
}

type SettingsAuthentication

type SettingsAuthentication struct {
	AdminUsers []string `json:"admin_users,omitempty"`
}

type StringArray

type StringArray = Flags

type Topic

type Topic struct {
	ID       string   `json:"id"`
	Title    string   `json:"title"`
	Abstract string   `json:"abstract"`
	Layers   []string `json:"visible_overlays"`
}

type TreeNode

type TreeNode interface {
	IsGroup() bool
	Children() []TreeNode
	GroupName() string
	LayerID() string
}

func CreateTree2

func CreateTree2(items []interface{}) ([]TreeNode, error)

type User

type User struct {
	Username        string  `json:"username"`
	Email           string  `json:"email"`
	FirstName       string  `json:"first_name"`
	LastName        string  `json:"last_name"`
	IsSuperuser     bool    `json:"is_superuser"`
	IsAuthenticated bool    `json:"-"`
	IsGuest         bool    `json:"is_guest"`
	Profile         Profile `json:"profile,omitempty"`
}

func AccountToUser

func AccountToUser(account Account) User

type UserRolesPermissions

type UserRolesPermissions struct {
	// contains filtered or unexported fields
}

func NewUserRolesPermissions

func NewUserRolesPermissions(user User, auth Authentication) *UserRolesPermissions

func (*UserRolesPermissions) AttributesFlags

func (p *UserRolesPermissions) AttributesFlags(layerId string) map[string]Flags

func (*UserRolesPermissions) LayerFlags

func (p *UserRolesPermissions) LayerFlags(layerId string) Flags

func (*UserRolesPermissions) UserTopics

func (p *UserRolesPermissions) UserTopics() []string

Jump to

Keyboard shortcuts

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