我正在尝试解析GTFS数据并为一条路线构建多段线形状(一组纬度和经度对)。但是在我的示例GTFS数据中,我发现行程对于一条路线具有多个形状ID。以下是GTFS数据的一段内容:
route_id,agency_id,route_short_name,route_long_name,route_desc,route_type,route_url,route_color,route_text_color 90,YRT,90,LESLIE,,3,,FDAE35,FFFFFF
route_id,service_id,trip_id,trip_headsign,trip_short_name,direction_id,block_id,shape_id,wheelchair_accessible,bikes_allowed 90,1,1286467,Richmond Green Secondary School - NB,,0,131905,59628,1,1 90,1,1286468,Richmond Green Secondary School - NB,,0,131907,59628,1,1 90,1,1286380,Richmond Green Secondary School - NB,,0,131906,59629,1,1 90,1,1286469,Richmond Green Secondary School - NB,,0,131908,59628,1,1 90,1,1286381,Richmond Green Secondary School - NB,,0,131904,59629,1,1 90,1,1286382,Richmond Green Secondary School - NB,,0,131905,59629,1,1 ... 90,1,1286399,Richmond Green Secondary School - NB,,0,131960,59629,1,1 90,1,1286400,Richmond Green Secondary School - NB,,0,131961,59629,1,1 90,1,1286470,Richmond Green Secondary School - NB,,0,131921,59630,1,1 90,1,1286471,Richmond Green Secondary School - NB,,0,131922,59630,1,1 90,1,1286401,Richmond Green Secondary School - NB,,0,131962,59629,1,1 90,1,1286402,Richmond Green Secondary School - NB,,0,131960,59629,1,2
shape_id,shape_pt_lat,shape_pt_lon,shape_pt_sequence,shape_dist_traveled 59628,43.902752,-79.398992,72,7.2214 59628,43.902585,-79.399005,73,7.2405 59629,43.775996,-79.346326,1,0.0000 59629,43.775987,-79.346238,2,0.0071 ... 59629,43.902752,-79.398992,317,15.7832 59629,43.902585,-79.399005,318,15.8022 59630,43.811197,-79.360774,1,0.0000 59630,43.812373,-79.361259,2,0.1364
我希望每次旅行都可以有一个形状,或者至少形状是连续的。但是这次旅行数据让我失望:
route_id,service_id,trip_id,trip_headsign,trip_short_name,direction_id,block_id,shape_id,wheelchair_accessible,bikes_allowed 90,1,1286400,Richmond Green Secondary School - NB,,0,131961,59629,1,1 90,1,1286470,Richmond Green Secondary School - NB,,0,131921,59630,1,1 90,1,1286471,Richmond Green Secondary School - NB,,0,131922,59630,1,1 90,1,1286401,Richmond Green Secondary School - NB,,0,131962,59629,1,1
如果您注意到#59629形状之后,则找到#59630。但是之后,我们再次看到#59629。我该如何理解?是数据问题吗?
答案 0 :(得分:1)
形状不与路线关联,形状仅与单个行程关联。一条路线包含两个或多个形状非常普遍。
实际上,由于形状明确地编码了运动方向,所以路线将始终存在至少两个形状,这些路线被分为“往返”行程对(这是简单公交路线中最常见的方法)实践)。更复杂的可能性包括具有多个分支的路线或具有短途旅行的路线。
此外,形状ID并不暗含任何排序;也就是说,59630
不在59629
之前还是之后都没有意义。原则上,它们是任意字符串。
总之,你的数据与外观做工精细,它只是没有明确的方式,做你想做的,一般情况下该怎么做。但是,根据你的情况的细节,有可能采取更手动方法和多个形状组合成单个相干折线。