translation

package
v0.0.0-...-cd9892f Latest Latest
Warning

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

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

Documentation

Overview

Package translation provides functions for managing a translation between two countries.

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 Init

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

Types

type BodySetChoice

type BodySetChoice string

type CountrySpec

type CountrySpec struct {
	Name           string
	NbBodies, Step int
}

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) 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) ComputeBaryCenters

func (country *CountryWithBodies) ComputeBaryCenters()

compute villages barycenters

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) 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 Point

type Point struct {
	X, Y float64
}

func MakePoint

func MakePoint(x float64, y float64) Point

type PointList

type PointList []Point

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