如何做一个简单的公交路线搜索引擎? [英] How do I make a simple bus route search Engine?

查看:142
本文介绍了如何做一个简单的公交路线搜索引擎?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[不是:用户在铁路查询系统的开发,需要在Databse中注意吗?]
我的问题描述:

[Not:e user is asking this again at Development of railway enquiry system, need attention in Databse? ] My Problem Description:

我在ROUTE-1中有一个 BUS-123 ,它将在ROUTE-2中通过A,B,C,D,E,F,G,H和 BUS- >通过D,E,F, X,Y,Z
如果有人输入B作为源点,F作为目标点,则使用BUS-123的ROUTE-1应显示在结果中。但是如果有人输入H作为源并且A作为目的地结果不应该显示,因为返回可能不总是与被行进的相同。
但如果某人输入A作为来源,Z作为目的地,则 BUS-123 ROUTE-1 BUS-321

Suppose I have a BUS-123 in ROUTE-1 it will travel through A, B, C, D, E, F, G, H and BUS-321 in ROUTE-2 through D, E, F, X, Y, Z . if someone enters B as a source point and F as a destination point then ROUTE-1 with BUS-123 should display in the result. But if someone enters H as a source and A as destination result should not display, because returning may not always same with one that is traveled. But if a person enters A as a source and Z as destination then BUS-123 with ROUTE-1 and BUS-321 with ROUTE-2 should display.

我的问题是:
如何在数据库中存储路由信息?如果我存储在RDBMS如下面

My Problem is: How do I store that route information in Database? if i store in RDBMS like the following

BUS_NUMBER   ROUTE_NUMBER    VIA_ROUTES
BUS-123      ROUTE-1         A, B, C, D, E, F, G, H
BUS-321      ROUTE-2         D, E, F, X, Y, Z

然后我的搜索将如何工作。我的意思是如何在一个字符串中搜索。
如果我将所有的VIA_ROUTES存储在不同的列中,那么它将是什么?请用我自己的技术建议我。

Then how my search will work. I mean how to search it in a string. And if I store all the VIA_ROUTES in different different columns then how it will be..? Please suggest me with your own technique. It is not urgent but I am planning to make a basic bus route search, so your comment with help is appreciated.

推荐答案

我不知道如何解决这个问题。将其建模为循环图。每个公共汽车站由一个顶点表示。两个停靠点之间的每个直接连接由标记有路线编号的边缘表示;因此,每个路由是连接边的序列。使边缘也指向。从停靠站A到停靠站B的所有路线都不一定从停靠站B到停靠站A在另一个方向上行驶。

I'd model it as a cyclic graph. Each bus stop is represented by a vertice. Each direct connection between two stops is represented by an edge labelled with the route number; consequently, each route is a sequence of connected edges. Make the edges directed, too. Not all routes travelling from stop A to stop B will necessarily also travel from stop B to stop A in the other direction.

可能希望在每个边缘填充估计的行程时间,这条腿的方差测量(或多个测量) - 在星期日晚上凌晨2点,方差可能很低,但是在星期五晚上5点,它可能非常高,以及出发时间列表。

Probably want to populate each edge with the estimated travel time, a measure (or measures) of variance for that leg -- at 2am on a Sunday night, the variance might be low, but at 5pm on a Friday evening, it might be very high, and list of departure times as well.

然后它的图遍历和找到最低成本路线,但是你选择定义最低成本 - 你可能想考虑的因素包括

Then its a matter of graph traversal and finding the "least cost" route, however you choose to define "least cost" -- Factors you might want to consider would include:


  • 总旅行时间

  • 等待下一个航段离开的总时间。

应该注意,太多的等待时间是不好的(1月份时,等待一辆公共汽车的时间为-10 F?)40分钟。太少也是坏的,因为它增加了错过连接的可能性,因为公共汽车往往对他们的日程表有相当大的变化,因为他们对当地交通条件的波动高度反应。

One should note that too much wait time is bad (ever spend 40 minutes waiting for a bus in January when it's -10 F?). Too little is bad, too, as it increases the probability of missing a connection, given that buses tend to have a fairly large variability to their schedules since they are highly responsive to fluctuations in local traffic conditions.

这是我该怎么做。

我不相信我会尝试直接在SQL中解决它。

I don't believe I'd try to solve it directly in SQL, though.

然而,这个模型很适合SQL。您需要以下实体,然后一些,因为您需要表示日程表等:

The model is a good fit for SQL, though. You need the following entities, and then some, since you'll need to represent schedules, etc.:


  • 停止。 / strong> A巴士站。图表的顶点。

  • 路线。公共汽车路线。

  • 细分。两个停靠点之间的直接链接。图表的边缘。

  • RouteSegment。代表构成路线的区段的有序序列的关联实体。

  • Stop. A Bus stop. The vertices of the graph.
  • Route. A bus route.
  • Segment. The direct link between two stops. The edges of the graph.
  • RouteSegment. An associative entity representing ordered sequence of segments that composes the route.

这篇关于如何做一个简单的公交路线搜索引擎?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆