Skip to content

Commit 6497ce9

Browse files
authored
Merge pull request #111 from opentripplanner/zero-length-leg-geometry-fix
Fix a bug that occurred when rendering geometry with 0 length
2 parents e37a7df + e9cd12b commit 6497ce9

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Diff for: lib/components/map/base-map.js

+1
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ class BaseMap extends Component {
275275
center={center}
276276
// onClick={this._onLeftClick}
277277
zoom={config.map.initZoom || 13}
278+
maxZoom={config.map.maxZoom}
278279
onOverlayAdd={this._onOverlayAdd}
279280
onOverlayRemove={this._onOverlayRemove}
280281
onViewportChanged={this._onViewportChanged}

Diff for: lib/util/itinerary.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,21 @@ export function getItineraryBounds (itinerary) {
228228
return latLngBounds(coords)
229229
}
230230

231+
/**
232+
* Return a leaflet LatLngBounds object that encloses the given leg's geometry.
233+
*/
231234
export function getLegBounds (leg) {
232-
return latLngBounds(polyline
235+
const coords = polyline
233236
.toGeoJSON(leg.legGeometry.points)
234237
.coordinates.map(c => [c[1], c[0]])
235-
)
238+
239+
// in certain cases, there might be zero-length coordinates in the leg
240+
// geometry. In these cases, build us an array of coordinates using the from
241+
// and to data of the leg.
242+
if (coords.length === 0) {
243+
coords.push([leg.from.lat, leg.from.lon], [leg.to.lat, leg.to.lon])
244+
}
245+
return latLngBounds(coords)
236246
}
237247

238248
export function routeComparator (a, b) {

0 commit comments

Comments
 (0)