j2me中移动设备导航算法的实现

发布于 2024-09-30 23:29:46 字数 631 浏览 7 评论 0原文

作为我大学项目的一部分,我正在开发一个定制的移动导航应用程序。我正在使用J2ME。

我所说的定制是指该应用程序只能在用户希望使用它们的地方使用。现在,“定制”区域是我的大学校园。因此,如果任何学生需要前往教室或街区的路线,他将被引导到该位置。

我无法使用谷歌地图,因为校园没有完全被它们覆盖。因此,我获取所有街区和道路的坐标并将其存储在我的地标商店中,并创建一个迷你坐标地图。

现在真正的问题是“我如何实现应用程序的导航部分”? 这就是我目前的实施行动计划。

我决定使用 Dijkstra 算法来找到最短路径。我只需将用户的当前位置添加到图中并将其称为源。 成本邻接矩阵将填充在程序内。

现在,算法开始工作,并使用第一条指令生成最短路径,例如:向北移动100米。

用户照此进行,但犯了错误并且走错了方向。如何不断检查用户是否朝着正确的方向前进? 如果我每 10 秒检查一次他的位置并提醒他是否走错了路线(我也不知道该怎么做!即检查他是否走在正确的路线上)并再次生成新的方向,不是吗?会减慢应用程序的速度吗?

有更好的实现方法吗?

PS:请帮助我如何将坐标存储在我的数据库(landmarkstore)中 我应该存储每个小距离(例如 5 米)的坐标还是应该使用更长的距离,以便减少图中的节点数量并且算法运行得更快。

As part of my college project I'm developing a customized mobile navigation application. I'm using J2ME.

By customized I mean the application can be used in places only where the user wishes to use them. Now, the 'customized' area is my college premises. So if any student needs directions to reach his classroom or block he will be guided to that location.

I cannot use the google maps because the campus is not totally covered in them. So i take coordinates of all the blocks and roads and store in my landmarkstore and create a mini map of coordinates.

Now the real problem is 'How do i implement the navigation part of the application'?
This is what is my current plan of action for the implementation.

I decided to use the Dijkstra's algorithm to find the shortest path. I'll just add the current position of the user into the graph and call it the source.
The cost-adjacency matrix will be populated within the program.

Now the algorithm works and the shortest path is generated with the first instruction saying eg. Move 100mts due north.

The user proceeds as such but makes a mistake and goes in the wrong direction . How do I constantly check if the user is proceeding in the right direction?
If i do check with his position every 10seconds and alert him if he is on the wrong course,(I dont know how to do this either! ie, checking if he is on the right course) and generate new directions again won't I be slowing the application down?

Is there a better way of implementing it?

PS: Please help me with how the coordinates must be stored in my database(landmarkstore)
Should i store the coordinates for every small distance(eg. 5mts) or should i use a longer distance so that the number of nodes in the graph is reduced and the algorithm works faster.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ヤ经典坏疍 2024-10-07 23:29:46

首先,“走错路线”很容易被检测到:到达目的地的最短路径的长度正在增加。或者,如果您的最佳路径上有一些“检查点”,那么用户就会离开下一个检查点。

考虑到复杂性,不要每 5 米或其他距离使用一个点:您需要在地图上有一些主要点(每扇门、走廊交叉口...),您可以为您提供总体方向。你甚至可以想象预先计算每栋建筑之间以及每栋建筑内部的最短路径;你首先需要离开大楼去另一栋大楼。

无论如何,一旦有了这些要点,您只需在地图上添加一个点(用户位置)并将其连接到相邻的“要点”。

目前您的图表中有多少个节点?


EDIT :

基本上,这个想法如下:给定所有道路,很容易预先计算从道路的任何点到任何建筑物的最短路径。无需对每条道路都执行此操作,只需将每个交叉路口或建筑物视为图中的节点即可。然后,给定道路上的一个点,您只有两种可能性来读取节点:向左或向右。 (当然,这假设人们不走路,但可以很容易地适应;))。

现在给定一个人的位置,找到最近的道路并找到到这些道路的最短路径。现在,您在不同的道路上有几个位置,可以轻松计算到达目的地的最短路径。由于几乎所有内容都是预先计算的,因此您每秒会多次更新您的信息。

您可以向该人发出指示,如果您注意到到目的地的距离正在增加,您可以警告他,他走错了方向。

First of all "being on the wrong course" can be easily detected : the length of the shortest path to the destination is increasing. Or if you have some "checkpoints" along your optimal path then the user is going away from the next checkpoint.

For the complexity don't use a point every 5mts or other distance : you need to have some main points in your map (each door, hallway crossing...) you can give you general direction. You can even imagine prec-omputing shortest path between each building and then inside each building ; your first need to leave the building to go to the other one.

Anyway once you have these main points you only need to add one point to you map (the user position) and connect it to the neighboring "main points".

How many nodes do you have in your graph for now ?


EDIT :

Basically the idea is the following one : given all the roads it is really easy to pre-compute the shortest path from any point of the road to any building. No need to do that for every road, only consider every intersection or building as a node in your graph. Then given a point on the road yon only have two possibilities to read a node : left or right. (This suppose of course that people stay of the road but can be easily adapted ;) ).

Now given a person position find the closest road and find the shortest path to these roads. You now have a few positions on different roads and it's easy to compute the shortest path to the destination. Since almost everything is pre-computing you an update your info multiple times per second.

You can give instruction to the person and if you notice that the distance to destination is increasing you can warn him he is going in the wrong direction.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文