data_import

package
v0.0.0-...-670d40f Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DQC_SECURITY_NAME = "DonnéesQC Security"
	DQC_SECURITY_URL  = "http://geoegl.msp.gouv.qc.ca/apis/wss/historiquesc.fcgi"
	DQC_START_YEAR    = 2024
)
View Source
const (
	DQC_WEATHER_NAME = "DonnéesQC Weather"
	DQC_WEATHER_URL  = "https://geoegl.msp.gouv.qc.ca/ws/igo_gouvouvert.fcgi"
)
View Source
const (
	HQC_URL         = "http://pannes.hydroquebec.com/pannes/donnees/v3_0"
	HQC_TIME_FMT    = "2006-01-02 15:04:05"
	HQC_OUTAGE_NAME = "Hydro-Québec Outage"
)
View Source
const (
	DQC_VERSION  = "2.0.0"
	DQC_TIME_FMT = "2006/01/02 15:04"
	DQC_DATE_FMT = "2006-01-02"
)
View Source
const MUN_POLYGONS_FILE = "munic_polygons/switchedCoordinatesMunPolygons.json"
View Source
const SYSTEM_USER_GUID = "dcf54266-549e-4546-9431-872f2d2fe8b3"

Variables

This section is empty.

Functions

func DownloadFile

func DownloadFile(url string, filepath string) error

func ExtractKMLFile

func ExtractKMLFile(src string, dst string) error

func GetMunicipalityPolygons

func GetMunicipalityPolygons() map[string][][][]float64

func MakeWFSGetRequest

func MakeWFSGetRequest(baseUrl string, request string, params map[string]string) ([]byte, error)

func MakeWFSPostRequest

func MakeWFSPostRequest(baseUrl string, body string, params map[string]string) ([]byte, error)

func ParseSeverity

func ParseSeverity(severity string) event.DangerLevel

func ParseUrgency

func ParseUrgency(urgency string) event.UrgencyType

func ToGetParams

func ToGetParams(params map[string]string) string

func UpdateAll

func UpdateAll(db *clover.DB) error

func UpdateFromSource

func UpdateFromSource(db *clover.DB, source EventSource) ([]event.Event, error)

Types

type DQCSecurityEventSource

type DQCSecurityEventSource struct{}

func (DQCSecurityEventSource) GetAllEvents

func (source DQCSecurityEventSource) GetAllEvents() ([]event.Event, error)

func (DQCSecurityEventSource) GetName

func (source DQCSecurityEventSource) GetName() string

func (DQCSecurityEventSource) GetNewEventsFromDate

func (source DQCSecurityEventSource) GetNewEventsFromDate(date time.Time) ([]event.Event, error)

type DQCWeatherEventSource

type DQCWeatherEventSource struct{}

func (DQCWeatherEventSource) GetAllEvents

func (source DQCWeatherEventSource) GetAllEvents() ([]event.Event, error)

func (DQCWeatherEventSource) GetName

func (source DQCWeatherEventSource) GetName() string

func (DQCWeatherEventSource) GetNewEventsFromDate

func (source DQCWeatherEventSource) GetNewEventsFromDate(date time.Time) ([]event.Event, error)

type EventSource

type EventSource interface {
	GetName() string
	GetAllEvents() ([]event.Event, error)

	//TODO: Incremental load with cron
	GetNewEventsFromDate(date time.Time) ([]event.Event, error)
}

func GetEventSourceByName

func GetEventSourceByName(name string) EventSource

func GetEventSources

func GetEventSources() []EventSource

type Geometry

type Geometry struct {
	GeomType    string    `json:"type"`
	Coordinates []float64 `json:"coordinates"`
}

type HQCOutageEventSource

type HQCOutageEventSource struct{}

func (HQCOutageEventSource) DownloadKmlFile

func (source HQCOutageEventSource) DownloadKmlFile(bisVersion string) error

TODO: Need to cleanup old KML files

func (HQCOutageEventSource) GetAllEvents

func (source HQCOutageEventSource) GetAllEvents() ([]event.Event, error)

func (HQCOutageEventSource) GetLatestBis

func (source HQCOutageEventSource) GetLatestBis() (string, error)

func (HQCOutageEventSource) GetName

func (source HQCOutageEventSource) GetName() string

func (HQCOutageEventSource) GetOutageAreas

func (source HQCOutageEventSource) GetOutageAreas(bisVersion string) error

func (HQCOutageEventSource) GetOutageEvents

func (source HQCOutageEventSource) GetOutageEvents(bisVersion string) ([]event.Event, error)

type KML

type KML struct {
	XMLName  xml.Name    `xml:"kml"`
	XMLNS    string      `xml:"xmlns,attr"`
	GX       string      `xml:"gx,attr"`
	Document KMLDocument `xml:"Document"`
}

func LoadKmlFile

func LoadKmlFile(fileName string) (*KML, error)

type KMLDocument

type KMLDocument struct {
	XMLName   xml.Name       `xml:"Document"`
	Placemark []KMLPlacemark `xml:"Placemark"`
}

type KMLPlacemark

type KMLPlacemark struct {
	Centroid string `xml:"ExtendData>Data>value"`
	Polygon  string `xml:"Polygon"`
}

type ListePannes

type ListePannes struct {
	Pannes []Panne `json:"pannes"`
}

type Panne

type Panne struct {
	NbAffectes    int
	DateDebut     time.Time
	DateFinPrevue time.Time
	CoordX        float64
	CoordY        float64
	Statut        string
	Cause         string
}

func (Panne) ToEvent

func (p Panne) ToEvent() (event.Event, error)

func (*Panne) UnmarshalJSON

func (p *Panne) UnmarshalJSON(bs []byte) error

type SecurityFeature

type SecurityFeature struct {
	Id         int32              `json:"id"`
	Type       string             `json:"type"`
	Properties SecurityProperties `json:"properties"`
	Geometry   mapobject.Geometry `json:"geometry"`
}

func (SecurityFeature) GetDanger

func (f SecurityFeature) GetDanger() event.DangerLevel

func (SecurityFeature) GetDate

func (f SecurityFeature) GetDate() (time.Time, error)

func (SecurityFeature) GetSeverity

func (f SecurityFeature) GetSeverity() event.UrgencyType

calculate based on date?

func (SecurityFeature) ToEvent

func (f SecurityFeature) ToEvent() (event.Event, error)

type SecurityFeatureCollection

type SecurityFeatureCollection struct {
	Name     string            `json:"name"`
	Type     string            `json:"type"`
	Features []SecurityFeature `json:"features"`
}

type SecurityProperties

type SecurityProperties struct {
	Code_alea               int32   `json:"code_alea"`
	Alea                    string  `json:"alea"`
	Code_municipalite       string  `json:"code_municipalite"`
	Municipalite            string  `json:"municipalite"`
	Precision_localisation  string  `json:"precision_localisation"`
	Info_compl_localisation string  `json:"info_compl_localisation"`
	Severite                string  `json:"severite"`
	Date_signalement        string  `json:"date_signalement"`
	Date_debut              string  `json:"date_debut"`
	Date_debut_imprecise    string  `json:"date_debut_imprecise"`
	Commentaire_date_debut  string  `json:"commentaire_date_debut"`
	Date_fin                string  `json:"date_fin"`
	Coord_x                 float32 `json:"coord_x"`
	Coord_y                 float32 `json:"coord_y"`
}

type WFSSearch

type WFSSearch struct {
	LogicalOperator string
	PropertyName    string
	PropertyValue   string
	TypeName        string
}

func (WFSSearch) ToSecuritySearchPayload

func (params WFSSearch) ToSecuritySearchPayload() string

func (WFSSearch) ToWeatherSearchPayload

func (params WFSSearch) ToWeatherSearchPayload(srsName string, outputFormat string) string

type WeatherFeature

type WeatherFeature struct {
	FeatureType string             `json:"type"`
	Properties  WeatherProperties  `json:"properties"`
	Geometry    mapobject.Geometry `json:"geometry"`
}

func (*WeatherFeature) ToEvent

func (feature *WeatherFeature) ToEvent() (event.Event, error)

type WeatherFeatureCollection

type WeatherFeatureCollection struct {
	Name           string           `json:"name"`
	CollectionType string           `json:"type"`
	Features       []WeatherFeature `json:"features"`
}

type WeatherProperties

type WeatherProperties struct {
	Nom              string `json:"nom"`
	Source           string `json:"source"`
	Territoire       string `json:"territoire"`
	Certitude        string `json:"certitude"`
	Severite         string `json:"severite"`
	Date_mise_a_jour string `json:"date_mise_a_jour"`
	Id_alerte        string `json:"id_alerte"`
	Urgence          string `json:"urgence"`
	Description      string `json:"description"`
	Type             string `json:"type"`
}

Jump to

Keyboard shortcuts

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