From b52f19d3569444be0adbd7f78fbf69eb52f334fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20GR=C3=89GOIRE?= Date: Thu, 28 Nov 2024 15:35:52 +0100 Subject: [PATCH] Fix #84. NPE validating GTFS w/ shapepoint at 0,0. --- .../gtfsvtor/dao/inmemory/InMemoryLinearGeometryIndex.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/mecatran/gtfsvtor/dao/inmemory/InMemoryLinearGeometryIndex.java b/src/main/java/com/mecatran/gtfsvtor/dao/inmemory/InMemoryLinearGeometryIndex.java index a579f71..410d507 100644 --- a/src/main/java/com/mecatran/gtfsvtor/dao/inmemory/InMemoryLinearGeometryIndex.java +++ b/src/main/java/com/mecatran/gtfsvtor/dao/inmemory/InMemoryLinearGeometryIndex.java @@ -210,8 +210,10 @@ private ProjectedShapePatternImpl computePatternIndex(GtfsTrip trip, .getPointsOfShape(trip.getShapeId()); ProjectedShapePatternImpl ret; - if (trip.getShapeId() == null || shapePoints.size() < 2) { - // No shape, linear index on inter-stop distance + if (trip.getShapeId() == null || shapePoints.size() < 2 + || shapePoints.stream().anyMatch( + p -> p == null || p.getCoordinates() == null)) { + // No shape or broken, linear index on inter-stop distance ret = computeShapelessPatternIndex(trip, stopTimes, dao); } else { // A shape is present, check shape_dist_traveled