ctucx.git: oeffisearch

[nimlang] fast and simple tripplanner

commit b623e279a5369e49a0ec0daa5b96cda0b9b82d1f
parent a998e4b244bc5aab1c6ee4398c9d23b25310d170
Author: Milan Pässler <me@pbb.lc>
Date: Fri, 14 Feb 2020 16:57:09 +0100

fix polylines
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/src/backend/hafas/parse/leg.nim b/src/backend/hafas/parse/leg.nim
@@ -27,13 +27,12 @@ proc parseLegPart(common: CommonData, lp: JsonNode): LegPart =
 proc mkParseLeg*(common: CommonData): proc =
   proc parseLeg(l: JsonNode): Leg =
 
-    if l{"polyG"}{"polyX"}.getElems().len() > 0:
-      result.polyline = Polyline(
-        type: "FeatureCollection"
-      )
-      for n in l{"polyG"}{"polyX"}.getElems():
-        result.polyline.features &= common.polylines[n.getInt()].features
-    echo pretty(%result.polyline)
+    if l{"jny"}{"polyG"}{"polyXL"}.getElems().len() > 0:
+      result.polyline = some(Polyline(
+        type: "FeatureCollection",
+      ))
+      for n in l{"jny"}{"polyG"}{"polyXL"}.getElems():
+        result.polyline.get.features &= common.polylines[n.getInt()].features
 
     let typeStr = l{"type"}.getStr()
     if typeStr == "JNY":
diff --git a/src/types.nim b/src/types.nim
@@ -69,7 +69,7 @@ type
     cancelled*:            bool
     departure*:            LegPart
     arrival*:              LegPart
-    polyline*:             Polyline
+    polyline*:             Option[Polyline]
     distance*:             Option[int]              # required for isWalking or isTransfer
     tripId*:               Option[string]           # required for not isWalking and not isTranfer
     line*:                 Option[Line]             # required for not isWalking and not isTranfer