Back to official API
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
nemunaire 2024-07-26 12:47:08 +02:00
commit 3e39c5e5c0
6 changed files with 202 additions and 301 deletions

View file

@ -97,29 +97,18 @@ func convertLineType(old string) string {
}
}
func convertCode(t, code string) string {
if !strings.HasPrefix(code, "line:IDFM:") {
if t == "tram" && !strings.HasPrefix(code, "T") {
code = "T" + code
}
if t == "noctilien" && !strings.HasPrefix(code, "N") {
code = "N" + code
}
if len(code) != 6 || !strings.HasPrefix(code, "C") {
code = searchLine(t, code)
}
code = "line:IDFM:" + code
}
return code
}
func searchLine(t, code string) string {
for _, line := range IDFMLines {
if line.Fields.ShortName == code && (line.Fields.TransportMode == t || strings.ToLower(line.Fields.NetworkName) == t) {
return line.Fields.IdLine
if t == "rer" {
for _, line := range IDFMLines {
if strings.HasSuffix(line.Fields.ShortName, code) && (line.Fields.TransportMode == t || strings.ToLower(line.Fields.NetworkName) == t) {
return line.Fields.IdLine
}
}
} else {
for _, line := range IDFMLines {
if line.Fields.ShortName == code && (line.Fields.TransportMode == t || strings.ToLower(line.Fields.NetworkName) == t) {
return line.Fields.IdLine
}
}
}
@ -165,10 +154,10 @@ func declareLinesRoutes(router *gin.RouterGroup) {
}
pgline := PGLine{
Code: line.Fields.ShortName,
Code: fmt.Sprintf("STIF:Line::%s:", line.Fields.IdLine),
Name: name,
Directions: "",
Id: fmt.Sprintf("STIF:Line::%s:", line.Fields.IdLine),
Id: line.Fields.IdLine,
}
lines = append(lines, pgline)