【问题标题】:PostGIS: Precision of functionsPostGIS:功能精度
【发布时间】:2022-01-12 10:32:33
【问题描述】:

为什么两个 Postgres/PostGIS 安装的相同查询的结果会不同?

我在一个通用主机(Windows 上的 VMWare)中有两个 Linux VM(Centos 9、Postgres 12.8;Kubuntu 20.04、postgres 12.9),每个都运行带有 PostGIS 扩展的 Postgres。 在两者上使用相同的 testdata 运行回归测试会给出不同的结果: ST_AsText 舍入不同,除非我限制精度(例如 ST_AsText(_ , 13) 而不是默认的 ST_AsText(_ , 15)。

我知道精确到小数点后 13 位就足够了。不过,我想了解安装的哪些特性会导致观察到的差异。

CentOS:
psql (12.4, server 12.8)
Type "help" for help.

testdb=> select p, ST_AsText(p, 15)  from (select ST_PointN(path_geogr::geometry, 18) as p from track where id=4) as _;
                         p                          |                st_astext
----------------------------------------------------+------------------------------------------
 0101000020E6100000000080C731971C400000B8488E754940 | POINT(7.14765083044767 50.9184046648443)
(1 row)

Kubuntu:
psql (12.4, server 12.9 (Ubuntu 12.9-2.pgdg20.04+1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.

testdb=> select p, ST_AsText(p, 15)  from (select ST_PointN(path_geogr::geometry, 18) as p from track where id=4) as _;
                         p                          |                  st_astext
----------------------------------------------------+---------------------------------------------
 0101000020E6100000000080C731971C400000B8488E754940 | POINT(7.147650830447674 50.918404664844275)
(1 row)

【问题讨论】:

  • 如上所述:在 kubuntu 上运行 postgres 12.9,在 centos 12.8 上

标签: postgresql rounding postgis


【解决方案1】:

PostGIS 使用double precision 表示坐标。如果计算略有不同(例如,不同的执行计划),结果可能会略有不同。

【讨论】:

  • 我理解“执行计划”描述了 RDBMS 收集查询请求的信息的方式(通常在涉及多个表时,例如使用哪个索引),所以它是那种EXPLAIN / ALANYZE 提供的信息。这如何影响数值计算的舍入?
  • 嗯,例如,数字相加的顺序会有所不同。
猜你喜欢
  • 1970-01-01
  • 2020-07-26
  • 1970-01-01
  • 2011-05-24
  • 2019-07-02
  • 2021-06-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多