models

package
v0.0.0-...-623ea98 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(database *gorm.DB)

func MapToDomain

func MapToDomain(modelTile Tile) domain.Tile

MapToDomain converts a models.Tile to a domain.Tile.

func Paginate

func Paginate(page int, pageSize int) func(db *gorm.DB) *gorm.DB

Types

type FormBase

type FormBase struct {
	ID        string    `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type ModelBase

type ModelBase struct {
	ID        string `gorm:"type:char(36);primary_key;"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

func (*ModelBase) BeforeCreate

func (base *ModelBase) BeforeCreate(db *gorm.DB) error

type Satellite

type Satellite struct {
	ModelBase
	Name    string `gorm:"size:255;not null"`        // Satellite name
	NoradID string `gorm:"size:255;unique;not null"` // NORAD ID
	Type    string `gorm:"size:255"`                 // Satellite type (e.g., telescope, communication)
}

Satellite Model

func (*Satellite) MapToForm

func (model *Satellite) MapToForm() *SatelliteForm

type SatelliteForm

type SatelliteForm struct {
	FormBase
	Name    string `json:"name" validate:"required,min=2,max=50"`     // Satellite name
	NoradID string `json:"norad_id" validate:"required,min=1,max=10"` // NORAD ID (unique identifier)
	Type    string `json:"type" validate:"required,min=2,max=80"`     // Satellite type
}

func (*SatelliteForm) MapToModel

func (form *SatelliteForm) MapToModel() *Satellite

type TLE

type TLE struct {
	ModelBase
	NoradID string    `gorm:"size:255;not null;index"` // Foreign key to Satellite table via Norad ID
	Line1   string    `gorm:"size:255;not null"`
	Line2   string    `gorm:"size:255;not null"`
	Epoch   time.Time `gorm:"not null"` // Time associated with the TLE
}

TLE Model

func (*TLE) MapToForm

func (model *TLE) MapToForm() *TLEForm

MapToForm converts the TLE model to a TLEForm structure

type TLEForm

type TLEForm struct {
	FormBase
	NoradID string `json:"norad_id" validate:"required"`                            // Reference to the Satellite via NORAD ID
	Line1   string `json:"line1" validate:"required"`                               // First line of TLE
	Line2   string `json:"line2" validate:"required"`                               // Second line of TLE
	Epoch   string `json:"epoch" validate:"required,datetime=2006-01-02T15:04:05Z"` // Epoch time (ISO8601 format)
}

func (*TLEForm) MapToModel

func (form *TLEForm) MapToModel() *TLE

MapToModel maps TLEForm to a TLE model

type Tile

type Tile struct {
	ModelBase
	Quadkey        string  `gorm:"size:256;unique;not null"`   // Unique identifier for the tile (Quadkey)
	ZoomLevel      int     `gorm:"not null"`                   // Zoom level for the tile
	CenterLat      float64 `gorm:"not null"`                   // Center latitude of the tile
	CenterLon      float64 `gorm:"not null"`                   // Center longitude of the tile
	SpatialIndex   string  `gorm:"type:geometry;spatialIndex"` // Geometry column for spatial queries
	NbFaces        int     `gorm:"not null"`                   // Number of faces in the tile's shape
	Radius         float64 `gorm:"not null"`                   // Radius of the tile in meters
	BoundariesJSON string  `gorm:"type:json"`                  // Serialized JSON of the boundary vertices of the tile
}

Tile Model

func MapFromDomain

func MapFromDomain(domainTile domain.Tile) Tile

MapFromDomain converts a domain.Tile to a models.Tile.

func (*Tile) Validate

func (t *Tile) Validate() error

Validate validates the fields of the Tile model.

type TileForm

type TileForm struct {
	FormBase
	Quadkey   string  `json:"quadkey" validate:"required"`                     // Unique Quadkey for the tile
	ZoomLevel int     `json:"zoom_level" validate:"required,min=1,max=20"`     // Zoom level (1 = world, higher = more detailed)
	CenterLat float64 `json:"center_lat" validate:"required,min=-90,max=90"`   // Center latitude of the tile
	CenterLon float64 `json:"center_lon" validate:"required,min=-180,max=180"` // Center longitude of the tile
}

func (*TileForm) MapToModel

func (form *TileForm) MapToModel() *Tile

type TileSatelliteMapping

type TileSatelliteMapping struct {
	ModelBase
	NoradID      string    `gorm:"size:255;not null;index"` // Foreign key to Satellite table via NORAD ID
	TileID       string    `gorm:"type:char(36);not null"`  // Foreign key to Tile table
	Aos          time.Time `gorm:"not null"`                // Visibility start time
	MaxElevation float64   `gorm:"not null"`                // Max elevation during visibility in degrees
}

func (*TileSatelliteMapping) MapToForm

func (model *TileSatelliteMapping) MapToForm() *TileSatelliteMappingForm

MapToForm converts the Visibility model to a form structure

type TileSatelliteMappingForm

type TileSatelliteMappingForm struct {
	FormBase
	NoradID      string  `json:"norad_id"`   // NORAD ID for the satellite
	TileID       string  `json:"tile_id"`    // Tile ID (string to match updated schema)
	Aos          string  `json:"start_time"` // ISO8601 format
	EndTime      string  `json:"end_time"`   // ISO8601 format
	MaxElevation float64 `json:"max_elevation"`
}

func (*TileSatelliteMappingForm) MapToModel

func (form *TileSatelliteMappingForm) MapToModel() *TileSatelliteMapping

MapToModel converts a VisibilityForm to a Visibility model

Jump to

Keyboard shortcuts

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