Class Cast Exception - GraphBuilder

52 views
Skip to first unread message

Colin

unread,
Jun 22, 2012, 1:19:41 AM6/22/12
to opentrippl...@googlegroups.com
Hey guys,

I'm in the process of updating to the latest ofp.zip (0.7.6) and have come across a ClassCastException for a couple locations so far. I'm experiencing this issue with Louisville (http://googletransit.ridetarc.org/feed/google_transit.zip) and Spokane (http://www.gtfs-data-exchange.com/agency/spokane-transit-authority/latest.zip).

2012-06-22 14:36:30,380 WARN  [GTFSPatternHopFactory.java:1137] : Shape geometry for shape_id STA_17026 cannot be used with stop times StopTime(seq=22 stop=STA_918 trip=STA_417038 times=06:38:27-06:38:27) and StopTime(seq=23 stop=STA_919 trip=STA_417038 times=06:39:44-06:39:44); using straight-line path instead (annotation registered)
Exception in thread "main" java.lang.ClassCastException: com.vividsolutions.jts.geom.GeometryCollection cannot be cast to com.vividsolutions.jts.geom.LineString
	at org.opentripplanner.routing.edgetype.factory.GTFSPatternHopFactory.getSegmentGeometry(GTFSPatternHopFactory.java:1129)
	at org.opentripplanner.routing.edgetype.factory.GTFSPatternHopFactory.getHopGeometry(GTFSPatternHopFactory.java:1058)
	at org.opentripplanner.routing.edgetype.factory.GTFSPatternHopFactory.makeTripPattern(GTFSPatternHopFactory.java:896)
	at org.opentripplanner.routing.edgetype.factory.GTFSPatternHopFactory.run(GTFSPatternHopFactory.java:350)
	at org.opentripplanner.graph_builder.impl.GtfsGraphBuilderImpl.buildGraph(GtfsGraphBuilderImpl.java:140)
	at org.opentripplanner.graph_builder.GraphBuilderTask.run(GraphBuilderTask.java:135)
	at org.opentripplanner.graph_builder.GraphBuilderMain.main(GraphBuilderMain.java:49)

As always many thanks for any help :-)

David Turner

unread,
Jun 22, 2012, 1:52:43 AM6/22/12
to opentrippl...@googlegroups.com
I'll bet that warning and that exception are unrelated.

This piece of code uses JTS's LocationIndexedLine, which is known to be
extremely buggy (I've reported like four bugs in it already, but this is
a new one). I'll investigate next time I get the chance, but it might
be a few days because I have another project taking up all my time right
now.

If you happen to have the time to extract a SSCCE, and submit it to the
JTS mailing list, that would be fantastic, and would save some time,
since I'm going to want to have the bug reported before I hack (another)
workaround into OTP.

Colin

unread,
Jun 22, 2012, 2:01:52 AM6/22/12
to opentrippl...@googlegroups.com
Correct David, I provided the WARN line to help put the error in context.

What's an SSCCE and what's JTS? No worries with the timeline, I'll just run an old OTP instance alongside the 0.7.6 instances.

P.S. Do you ever sleep?

David Turner

unread,
Jun 22, 2012, 2:18:23 AM6/22/12
to opentrippl...@googlegroups.com
A Short Self Contained Correct Example: http://sscce.org/

And JTS stands for the JTS Topology Suite (yes, the J in JTS stands for
JTS) -- it's the geometry library that we use.

I do sleep -- usually from around now until 10 or 11 EST (EDT).
Goodnight!

David Turner

unread,
Jun 26, 2012, 4:42:46 PM6/26/12
to OpenTripPlanner-users
The Spokane GTFS is bad.

The max shape_dist_traveled from stop_times.txt for trip_id 417038 is
6.0189. The max from shapes.txt is 5.1098.

JTS is at least arguably correct by returning an empty
GeometryCollection when asked for a zero-length subset of a linestring,
so I think I'm not going to report a bug upstream there, even though the
docs are a bit unclear.

OTP, of course, should handle this case more gracefully. I just
committed a fix for this. I haven't tested it on Louisville, but it's
probably a similar issue.

Thanks so much for the report, and please continue to let us know if
there are other issues we can correct.

On Thu, 2012-06-21 at 22:19 -0700, Colin wrote:

Colin

unread,
Jun 27, 2012, 10:00:56 AM6/27/12
to opentrippl...@googlegroups.com
As always thank you David, and sorry I couldn't submit the SSCCE, I have so many bits and pieces on the go I haven't had the time :-( Well I guess I've only got myself to blame for choosing an intensive hobby!

I'll report back on the Spokane and Louisville fix when I start/finish my next round of graph rebuilds. Thank you for the bug fix, and you're sure to hear from me for a while to come :-)
Reply all
Reply to author
Forward
0 new messages