【问题标题】:Rails with PostGIS - LineString won't go past -90 degrees带有 PostGIS 的 Rails - LineString 不会超过 -90 度
【发布时间】: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


    【解决方案1】:

    在 PostGIS 中,坐标的顺序是先经度,后纬度。您的坐标已交换,因此无效。

    附带说明,越界坐标会发生什么变化很大,范围可以从忽略问题、限制到适当的边界、环游地球、从极点返回等

    【讨论】:

    • 一种保持这些直线的方法(无论如何对我来说都很好)。经度测量东/西,对应于笛卡尔平面中的 x 坐标。纬度测量赤道的北/南,对应于笛卡尔平面中的 y 坐标。
    猜你喜欢
    • 2019-02-05
    • 2011-07-15
    • 2021-12-08
    • 2020-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-16
    • 1970-01-01
    相关资源
    最近更新 更多