【发布时间】:2021-08-21 19:02:25
【问题描述】:
我有一个简单的 PostGIS 数据库表如下:
create_table :blocked_search_regions do |t|
# use PostGIS
t.line_string :path, geographic: true
t.string :name
t.timestamps null: false
end
# PostGIS index
add_index :blocked_search_regions, :path, using: :gist
我可以通过运行以下命令来创建BlockedSearchRegion:
linestring = "LINESTRING (48.0 -122.1, 47.74 -90.0, 47.52 -90.0, 47.35 -90.0)"
bsr = BlockedSearchRegion.create!(name: 'new region', path: linestring)
据我所知,LINESTRING 参数只是 LAT LON。这似乎主要工作......除了超过-90度时。保存BlockedSearchRegion 时,坐标-122.1(或任何低于-90 度的坐标)将自动转换为-90.0:
=> #<BlockedSearchRegion:
path: #<RGeo::Geographic::SphericalLineStringImpl:0x2b004c8535c8 "LINESTRING (48.0 -90.0, 47.74 -90.0, 47.52 -90.0, 47.35 -90.0)">,
name: "new region",
created_at: Thu, 03 Jun 2021 16:12:54 UTC +00:00,
updated_at: Thu, 03 Jun 2021 16:12:54 UTC +00:00>
如何输入超过 90 度的纬度/经度?
我感觉这与我的表格列上的 geographic: true 标志有关。
【问题讨论】:
标签: ruby-on-rails postgresql gis postgis latitude-longitude