This commit is contained in:
parent
8c10770023
commit
3e39c5e5c0
6 changed files with 202 additions and 301 deletions
37
api/lines.go
37
api/lines.go
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue