Ruby on rails 带有PostGIS的轨道-线串赢得';不要超过零下90度
我有一个简单的PostGIS数据库表,如下所示:Ruby on rails 带有PostGIS的轨道-线串赢得';不要超过零下90度,ruby-on-rails,postgresql,gis,postgis,latitude-longitude,Ruby On Rails,Postgresql,Gis,Postgis,Latitude Longitude,我有一个简单的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_
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
标志有关。在PostGIS中,坐标的顺序是经度优先,其次是纬度。您的坐标已交换,因此无效
另一方面,超出边界的坐标变化很大,可以忽略问题、限制到适当的边界、环游地球、从极点返回等等,一种保持这些直线的方法(无论如何对我来说很有效)。经度测量东西方向,并与笛卡尔平面中的x坐标相对应。纬度测量赤道的南北方向,并与笛卡尔平面上的y坐标相对应。