1

我正计划构建一个 Rails 应用程序,该应用程序应该存储有关地理路线的数据(可能是数百万)。路线从智能手机记录或在网络界面中手动“绘制”。

一条路线由多个(最多约 10.000 个)坐标组成,其中包含时间戳、纬度和经度——但也可能包括高度和精度。

存储时,我需要过滤掉“pgs noice”,计算总距离并显示在地图上。

你会建议我如何存储路线数据?

我正在考虑使用 PostgreSQL,并希望将每个 Trip 存储在一行中,以便快速插入和检索(?)。这将需要一个多维数组字段,仅在 Rails 4.0 (?) 中支持。

同时,我一直在查看PostGISActiveRecord Adapter,但不确定这是否是矫枉过正或者它如何与 PostgreSQL 数组一起工作。

任何投入将不胜感激。

4

1 回答 1

0

Basically you have two options.

  1. You could use an array of points on PostgreSQL. Arrays in PostgreSQL are relatively complex and it is important to understand arrays and I the primary primitives primarily work on planes, not spheres so you lose spherical trig and the like. For these reasons I don't really recommend this approach unless you are already familiar with both and have specific reasons to choose this one. Of course you could also build your own spherical trig functions if you like.... But why you would when PostGIS is available I don't now.

  2. You can use geography types in PostGIS. These are helpful because you can store very complex multi-lines. PostGIS gives you spherical trig capabilities too. In general the types here are closer to what you are trying to do.

Finally I would recommend look at pgrouting which may give some additional functions you may find helpful.

于 2013-04-28T06:35:20.380 回答