@@ -121,18 +121,45 @@ public Scorer scorer(LeafReaderContext context) throws IOException {
121
121
122
122
val pointToTime = new Long2IntOpenHashMap (valueArray .size ());
123
123
124
- val results =
125
- protoFetcher .getTimes (
126
- ttQuery .getParams ().getOrigin (),
127
- decodedArray ,
128
- ttQuery .getParams ().getLimit (),
129
- ttQuery .getParams ().getMode (),
130
- ttQuery .getParams ().getCountry (),
131
- ttQuery .getParams ().getRequestType ());
132
-
133
- for (int index = 0 ; index < results .size (); index ++) {
134
- if (results .get (index ) >= 0 ) {
135
- pointToTime .put (valueArray .getLong (index ), results .get (index ).intValue ());
124
+ if (ttQuery .getParams ().isIncludeDistance ()) {
125
+ val pointToDistance = new Long2IntOpenHashMap (valueArray .size ());
126
+
127
+ val mode = Util .unsafeCastToDistanceTransportation (ttQuery .getParams ().getMode ());
128
+
129
+ val timeDistance =
130
+ protoFetcher .getTimesAndDistances (
131
+ ttQuery .getParams ().getOrigin (),
132
+ decodedArray ,
133
+ ttQuery .getParams ().getLimit (),
134
+ mode ,
135
+ ttQuery .getParams ().getCountry (),
136
+ ttQuery .getParams ().getRequestType ());
137
+
138
+ val times = timeDistance .getLeft ();
139
+ val distances = timeDistance .getRight ();
140
+
141
+ for (int index = 0 ; index < times .size (); index ++) {
142
+ if (times .get (index ) >= 0 ) {
143
+ pointToTime .put (valueArray .getLong (index ), times .get (index ).intValue ());
144
+ pointToDistance .put (valueArray .getLong (index ), distances .get (index ).intValue ());
145
+ }
146
+ }
147
+
148
+ TraveltimeCache .DISTANCE .add (ttQuery .getParams (), pointToDistance );
149
+ } else {
150
+ val results =
151
+ protoFetcher .getTimes (
152
+ ttQuery .getParams ().getOrigin (),
153
+ decodedArray ,
154
+ ttQuery .getParams ().getLimit (),
155
+ ttQuery .getParams ().getMode (),
156
+ ttQuery .getParams ().getCountry (),
157
+ ttQuery .getParams ().getRequestType ());
158
+
159
+ for (int index = 0 ; index < results .size (); index ++) {
160
+ if (results .get (index ) >= 0 ) {
161
+ pointToTime .put (valueArray .getLong (index ), results .get (index ).intValue ());
162
+ }
136
163
}
137
164
}
138
165
0 commit comments