Opened 3 years ago

Last modified 16 months ago

#3195 new defect

ST_Length on 3D geography gives 3D length

Reported by: Mike Toews Owned by: pramsey
Priority: medium Milestone: PostGIS Fund Me
Component: postgis Version: trunk
Keywords: Cc:

Description

ST_Length on a 3D geometry gives a 2D length, as clearly documented. However, ST_Length on a 3D geography gives a 3D length, which is not documented. Either:

  1. the function behaviour on geography needs to change to be similar to geography type, or
  2. the documentation for ST_Length needs to be updated to reflect the behaviour for 3D geography

As a side note, ST_Length_Spheroid on a 3D geometry gives a 3D length, as documented.

Here's an example:

SELECT ST_Length(geom) AS geom_2d_length, ST_3DLength(geom) AS geom_3d_length,
  ST_Length(ST_Transform(geom, 4326)::geography) AS geog_3d_length,
  ST_Length(ST_Transform(ST_Force2D(geom), 4326)::geography) AS geog_2d_length,
  ST_Length_Spheroid(ST_Transform(ST_Force2D(geom), 4326), spheroid) AS spheroid_length_2d,
  ST_Length_Spheroid(ST_Transform(geom, 4326), spheroid) AS spheroid_length_3d
FROM (
  SELECT 'SRID=27700;MULTILINESTRING((
 423216.279 574665.249 0, 423206.315 574708.077 44.649,
 423158.458 574896.911 242.525, 423132.406 574993.061 344))'::geometry AS geom,
 'SPHEROID["WGS 84",6378137,298.257223563]'::spheroid
) AS f;
-[ RECORD 1 ]------+-----------------
geom_2d_length     | 338.39264086563
geom_3d_length     | 482.54086040695
geog_3d_length     | 482.622196178051
geog_2d_length     | 338.515774984236
spheroid_length_2d | 338.515774984236
spheroid_length_3d | 482.622196178051

Change History (1)

comment:1 Changed 16 months ago by robe

Milestone: PostGIS FuturePostGIS Fund Me

Milestone renamed

Note: See TracTickets for help on using tickets.