models

package
v0.0.0-...-1bee6ba Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

generated by ModelGongFileTemplate

Index

Constants

View Source
const (
	ORIGINAL_CONFIGURATION = "ORIGINAL_CONFIGURATION"
	SPREAD_CONFIGURATION   = "SPREAD_CONFIGURATION"
)

Variables

View Source
var (
	Trace   *log.Logger
	Info    *log.Logger
	Warning *log.Logger
	Error   *log.Logger
)

Functions

func CreateORMCountrySpec

func CreateORMCountrySpec(countryspec *CountrySpec)

CreateORMCountrySpec enables dynamic staging of a CountrySpec instance

func CreateORMCountryWithBodies

func CreateORMCountryWithBodies(countrywithbodies *CountryWithBodies)

CreateORMCountryWithBodies enables dynamic staging of a CountryWithBodies instance

func DeleteORMCountrySpec

func DeleteORMCountrySpec(countryspec *CountrySpec)

DeleteORMCountrySpec enables dynamic staging of a CountrySpec instance

func DeleteORMCountryWithBodies

func DeleteORMCountryWithBodies(countrywithbodies *CountryWithBodies)

DeleteORMCountryWithBodies enables dynamic staging of a CountryWithBodies instance

func Init

func Init(
	traceHandle io.Writer,
	infoHandle io.Writer,
	warningHandle io.Writer,
	errorHandle io.Writer)

Types

type AllModelsStructCreateInterface

type AllModelsStructCreateInterface interface {
	CreateORMCountrySpec(CountrySpec *CountrySpec)
	CreateORMCountryWithBodies(CountryWithBodies *CountryWithBodies)
}

swagger:ignore

type AllModelsStructDeleteInterface

type AllModelsStructDeleteInterface interface {
	DeleteORMCountrySpec(CountrySpec *CountrySpec)
	DeleteORMCountryWithBodies(CountryWithBodies *CountryWithBodies)
}

type BackRepoInterface

type BackRepoInterface interface {
	Commit(stage *StageStruct)
	Checkout(stage *StageStruct)
	Backup(stage *StageStruct, dirPath string)
	Restore(stage *StageStruct, dirPath string)
	BackupXL(stage *StageStruct, dirPath string)
	RestoreXL(stage *StageStruct, dirPath string)
	// insertion point for Commit and Checkout signatures
	CommitCountrySpec(countryspec *CountrySpec)
	CheckoutCountrySpec(countryspec *CountrySpec)
	CommitCountryWithBodies(countrywithbodies *CountryWithBodies)
	CheckoutCountryWithBodies(countrywithbodies *CountryWithBodies)
	GetLastCommitNb() uint
	GetLastPushFromFrontNb() uint
}

type BodySetChoice

type BodySetChoice string

type CountrySpec

type CountrySpec struct {
	Name           string
	NbBodies, Step int
}

func (*CountrySpec) Checkout

func (countryspec *CountrySpec) Checkout() *CountrySpec

Checkout countryspec to the back repo (if it is already staged)

func (*CountrySpec) Commit

func (countryspec *CountrySpec) Commit() *CountrySpec

commit countryspec to the back repo (if it is already staged)

func (*CountrySpec) DeleteStageAndCommit

func (countryspec *CountrySpec) DeleteStageAndCommit() *CountrySpec

DeleteStageAndCommit appends countryspec to the model stage and commit to the orm repo

func (*CountrySpec) Stage

func (countryspec *CountrySpec) Stage() *CountrySpec

Stage puts countryspec to the model stage

func (*CountrySpec) StageAndCommit

func (countryspec *CountrySpec) StageAndCommit() *CountrySpec

StageAndCommit appends countryspec to the model stage and commit to the orm repo

func (*CountrySpec) StageCopy

func (countryspec *CountrySpec) StageCopy() *CountrySpec

StageCopy appends a copy of countryspec to the model stage

func (*CountrySpec) StageCopyAndCommit

func (countryspec *CountrySpec) StageCopyAndCommit() *CountrySpec

StageCopyAndCommit appends a copy of countryspec to the model stage and commit to the orm repo

func (*CountrySpec) Unstage

func (countryspec *CountrySpec) Unstage() *CountrySpec

Unstage removes countryspec off the model stage

type CountryWithBodies

type CountryWithBodies struct {
	grump.Country

	NbBodies int // nb of bodies according to the filename

	VilCoordinates [][]int
	Step           int // step when the simulation stopped
	// contains filtered or unexported fields
}

func (*CountryWithBodies) Checkout

func (countrywithbodies *CountryWithBodies) Checkout() *CountryWithBodies

Checkout countrywithbodies to the back repo (if it is already staged)

func (*CountryWithBodies) ClosestBodyInOriginalPosition

func (country *CountryWithBodies) ClosestBodyInOriginalPosition(lat, lng float64) (
	distance,
	latClosest, lngClosest,
	xSpread, ySpread float64,
	closestIndex int)

given lat, lng, get coords after simulation

func (*CountryWithBodies) Commit

func (countrywithbodies *CountryWithBodies) Commit() *CountryWithBodies

commit countrywithbodies to the back repo (if it is already staged)

func (*CountryWithBodies) ComputeBaryCenters

func (country *CountryWithBodies) ComputeBaryCenters()

compute villages barycenters

func (*CountryWithBodies) DeleteStageAndCommit

func (countrywithbodies *CountryWithBodies) DeleteStageAndCommit() *CountryWithBodies

DeleteStageAndCommit appends countrywithbodies to the model stage and commit to the orm repo

func (*CountryWithBodies) Init

func (country *CountryWithBodies) Init()

init variables

func (*CountryWithBodies) LatLngToTerritoryBorder

func (country *CountryWithBodies) LatLngToTerritoryBorder(lat, lng float64) PointList

given x, y of a point, return the border in the country

func (*CountryWithBodies) LoadConfig

func (country *CountryWithBodies) LoadConfig(isOriginal bool) bool

load configuration from filename into country check that it matches the

func (*CountryWithBodies) Stage

func (countrywithbodies *CountryWithBodies) Stage() *CountryWithBodies

Stage puts countrywithbodies to the model stage

func (*CountryWithBodies) StageAndCommit

func (countrywithbodies *CountryWithBodies) StageAndCommit() *CountryWithBodies

StageAndCommit appends countrywithbodies to the model stage and commit to the orm repo

func (*CountryWithBodies) StageCopy

func (countrywithbodies *CountryWithBodies) StageCopy() *CountryWithBodies

StageCopy appends a copy of countrywithbodies to the model stage

func (*CountryWithBodies) StageCopyAndCommit

func (countrywithbodies *CountryWithBodies) StageCopyAndCommit() *CountryWithBodies

StageCopyAndCommit appends a copy of countrywithbodies to the model stage and commit to the orm repo

func (*CountryWithBodies) Unstage

func (countrywithbodies *CountryWithBodies) Unstage() *CountryWithBodies

Unstage removes countrywithbodies off the model stage

func (*CountryWithBodies) XYToLatLng

func (country *CountryWithBodies) XYToLatLng(x, y float64) (lat, lng float64)

func (*CountryWithBodies) XYtoTerritoryBodies

func (country *CountryWithBodies) XYtoTerritoryBodies(x, y float64) PointList

get the bodies of a village from x, y spread coordinates

type OnInitCommitInterface

type OnInitCommitInterface interface {
	BeforeCommit(stage *StageStruct)
}

type Point

type Point struct {
	X, Y float64
}

func MakePoint

func MakePoint(x float64, y float64) Point

type PointList

type PointList []Point

type StageStruct

type StageStruct struct {
	CountrySpecs           map[*CountrySpec]struct{}
	CountrySpecs_mapString map[string]*CountrySpec

	CountryWithBodiess           map[*CountryWithBodies]struct{}
	CountryWithBodiess_mapString map[string]*CountryWithBodies

	AllModelsStructCreateCallback AllModelsStructCreateInterface

	AllModelsStructDeleteCallback AllModelsStructDeleteInterface

	BackRepo BackRepoInterface

	// if set will be called before each commit to the back repo
	OnInitCommitCallback OnInitCommitInterface
}

StageStruct enables storage of staged instances swagger:ignore

var Stage StageStruct = StageStruct{
	CountrySpecs:           make(map[*CountrySpec]struct{}),
	CountrySpecs_mapString: make(map[string]*CountrySpec),

	CountryWithBodiess:           make(map[*CountryWithBodies]struct{}),
	CountryWithBodiess_mapString: make(map[string]*CountryWithBodies),
}

swagger:ignore instructs the gong compiler (gongc) to avoid this particular struct

func (*StageStruct) Backup

func (stage *StageStruct) Backup(dirPath string)

backup generates backup files in the dirPath

func (*StageStruct) BackupXL

func (stage *StageStruct) BackupXL(dirPath string)

backup generates backup files in the dirPath

func (*StageStruct) Checkout

func (stage *StageStruct) Checkout()

func (*StageStruct) Commit

func (stage *StageStruct) Commit()

func (*StageStruct) Nil

func (stage *StageStruct) Nil()

func (*StageStruct) Reset

func (stage *StageStruct) Reset()

func (*StageStruct) Restore

func (stage *StageStruct) Restore(dirPath string)

Restore resets Stage & BackRepo and restores their content from the restore files in dirPath

func (*StageStruct) RestoreXL

func (stage *StageStruct) RestoreXL(dirPath string)

Restore resets Stage & BackRepo and restores their content from the restore files in dirPath

type Translation

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

Definition of a translation between a source and a target country

func GetTranslateCurrent

func GetTranslateCurrent() *Translation

Singloton pattern to init the current translation

func (*Translation) BodyCoordsInSourceCountry

func (t *Translation) BodyCoordsInSourceCountry(lat, lng float64) (distance, latClosest, lngClosest, xSpread, ySpread float64, closestIndex int)

from lat, lng in source country, find the closest body in source country

func (*Translation) BodyCoordsInTargetCountry

func (t *Translation) BodyCoordsInTargetCountry(lat, lng float64) (distance, latClosest, lngClosest, xSpread, ySpread float64, closestIndex int)

from lat, lng in source country, find the closest body in source country

func (*Translation) GetSourceCountryName

func (t *Translation) GetSourceCountryName() string

func (*Translation) GetTargetCountryName

func (t *Translation) GetTargetCountryName() string

func (*Translation) LatLngToXYInTargetCountry

func (t *Translation) LatLngToXYInTargetCountry(x, y float64) (latTarget, lngTarget float64)

from x, y get closest body lat/lng in target country

func (*Translation) SetSourceCountry

func (t *Translation) SetSourceCountry(name string)

func (*Translation) SetTargetCountry

func (t *Translation) SetTargetCountry(name string)

func (*Translation) SourceBorder

func (t *Translation) SourceBorder(lat, lng float64) PointList

func (*Translation) TargetBorder

func (t *Translation) TargetBorder(x, y float64) PointList

from a coordinate in source coutry, get border

type Village

type Village struct {
	quadtree.Body     // barycenter of the villages
	NbBodies      int // nb of bodies in the village (maybe not useful)
}

Jump to

Keyboard shortcuts

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