Opened 8 years ago

Closed 8 years ago

#3658 closed defect (invalid)

ST_Azimuth shows unexpected results

Reported by: darkblueb Owned by: pramsey
Priority: medium Milestone: PostGIS 2.2.4
Component: postgis Version: 2.2.x
Keywords: Azimuth Cc:

Description

Given a POLY, its ENVELOPE, and the CENTROID of the ENVELOPE, call ST_Azimuth( centroid, corner_point) for all corner points. Do this in EPSG:4326 and EPSG:900913. Note that the results do not match — in one corner only —

EPSG:4326; 
------------------------------------------------
POINT (-69.96961422411715 12.524908758632279)

POLYGON ((-70.06240800672413 12.417669988878856, -70.06240800672413 12.632147528385701, -69.87682044151018 12.632147528385701, -69.87682044151018 12.417669988878856, -70.06240800672413 12.417669988878856))

---
SELECT 

degrees(ST_Azimuth(
  'POINT (-69.96961422411715 12.524908758632279)'::geometry,
  'POINT (-70.06240800672413 12.417669988878856)'::geometry
)) as a1,

degrees(ST_Azimuth(
  'POINT (-69.96961422411715 12.524908758632279)'::geometry,
  'POINT (-70.06240800672413 12.632147528385701)'::geometry
)) as a2,

degrees(ST_Azimuth(
  'POINT (-69.96961422411715 12.524908758632279)'::geometry,
  'POINT (-69.87682044151018 12.632147528385701)'::geometry
)) as a3,

degrees(ST_Azimuth(
  'POINT (-69.96961422411715 12.524908758632279)'::geometry,
  'POINT (-69.87682044151018 12.417669988878856)'::geometry
)) as a4
;  
--

natural_earth2-# degrees(ST_Azimuth(
natural_earth2(#   'POINT (-69.96961422411715 12.524908758632279)'::geometry,
natural_earth2(#   'POINT (-70.06240800672413 12.417669988878856)'::geometry
natural_earth2(# )) as a1,
natural_earth2-# 
natural_earth2-# degrees(ST_Azimuth(
natural_earth2(#   'POINT (-69.96961422411715 12.524908758632279)'::geometry,
natural_earth2(#   'POINT (-70.06240800672413 12.632147528385701)'::geometry
natural_earth2(# )) as a2,
natural_earth2-# 
natural_earth2-# degrees(ST_Azimuth(
natural_earth2(#   'POINT (-69.96961422411715 12.524908758632279)'::geometry,
natural_earth2(#   'POINT (-69.87682044151018 12.632147528385701)'::geometry
natural_earth2(# )) as a3,
natural_earth2-# 
natural_earth2-# degrees(ST_Azimuth(
natural_earth2(#   'POINT (-69.96961422411715 12.524908758632279)'::geometry,
natural_earth2(#   'POINT (-69.87682044151018 12.417669988878856)'::geometry
natural_earth2(# )) as a4
natural_earth2-# ;  
        a1        |        a2        |        a3        |        a4        
------------------+------------------+------------------+------------------
 220.869659035397 | 319.130340964603 | 40.8696590353968 | 139.130340964603
(1 row)


================================================================================
EPSG:900913; Given a POLY, its ENVELOPE, and the CENTROID of the ENVELOPE:
---

select 
ST_AsEWKT(st_transform( 'SRID=4326;POINT (-69.96961422411715 12.524908758632279)'::geometry,
900913));

select
ST_AsEWKT(st_transform( 'SRID=4326;POLYGON ((-70.06240800672413 12.417669988878856, -70.06240800672413 12.632147528385701, -69.87682044151018 12.632147528385701, -69.87682044151018 12.417669988878856, -70.06240800672413 12.417669988878856))'::geometry,
900913));


 SRID=900913;POINT(-7788981.82643051 1405505.48023334)

 SRID=900913;POLYGON((-7799311.5830591 1393279.22657004,-7799311.5830591 1417736.81854813,-7778652.06980192 1417736.81854813,-7778652.06980192 1393279.22657004,-7799311.5830591 1393279.22657004))

---
SELECT 

degrees(ST_Azimuth(
  'SRID=900913;POINT (-7788981.82643051 1405505.48023334)'::geometry,
  'SRID=900913;POINT (-7799311.5830591 1393279.22657004)'::geometry
)) as m1,

degrees(ST_Azimuth(
  'SRID=900913;POINT (-7788981.82643051 1405505.48023334)'::geometry,
  'SRID=900913;POINT (-7799311.5830591 1417736.81854813)'::geometry
)) as m2,

degrees(ST_Azimuth(
  'SRID=900913;POINT (-7788981.82643051 1405505.48023334)'::geometry,
  'SRID=900913;POINT (7778652.06980192 1417736.81854813)'::geometry
)) as m3,

degrees(ST_Azimuth(
  'SRID=900913;POINT (-7788981.82643051 1405505.48023334)'::geometry,
  'SRID=900913;POINT (-7778652.06980192 1393279.22657004)'::geometry
)) as m4
;  

natural_earth2=# SELECT 
natural_earth2-# 
natural_earth2-# degrees(ST_Azimuth(
natural_earth2(#   'POINT (-7788981.82643051 1405505.48023334)'::geometry,
natural_earth2(#   'POINT (-7799311.5830591 1393279.22657004)'::geometry
natural_earth2(# )) as m1,
natural_earth2-# 
natural_earth2-# degrees(ST_Azimuth(
natural_earth2(#   'POINT (-7788981.82643051 1405505.48023334)'::geometry,
natural_earth2(#   'POINT (-7799311.5830591 1417736.81854813)'::geometry
natural_earth2(# )) as m2,
natural_earth2-# 
natural_earth2-# degrees(ST_Azimuth(
natural_earth2(#   'POINT (-7788981.82643051 1405505.48023334)'::geometry,
natural_earth2(#   'POINT (7778652.06980192 1417736.81854813)'::geometry
natural_earth2(# )) as m3,
natural_earth2-# 
natural_earth2-# degrees(ST_Azimuth(
natural_earth2(#   'POINT (-7788981.82643051 1405505.48023334)'::geometry,
natural_earth2(#   'POINT (-7778652.06980192 1393279.22657004)'::geometry
natural_earth2(# )) as m4
natural_earth2-# ;  
       m1        |        m2        |        m3        |        m4        
-----------------+------------------+------------------+------------------
 220.19390618527 | 319.817837775187 | 89.9549832733927 | 139.806093814733
(1 row)

===============================================


\db22=# SELECT 
db22-# 
db22-# degrees(ST_Azimuth(
db22(#   'SRID=900913;POINT (-7788981.82643051 1405505.48023334)'::geometry,
db22(#   'SRID=900913;POINT (-7799311.5830591 1393279.22657004)'::geometry
db22(# )) as m1,
db22-# 
db22-# degrees(ST_Azimuth(
db22(#   'SRID=900913;POINT (-7788981.82643051 1405505.48023334)'::geometry,
db22(#   'SRID=900913;POINT (-7799311.5830591 1417736.81854813)'::geometry
db22(# )) as m2,
db22-# 
db22-# degrees(ST_Azimuth(
db22(#   'SRID=900913;POINT (-7788981.82643051 1405505.48023334)'::geometry,
db22(#   'SRID=900913;POINT (7778652.06980192 1417736.81854813)'::geometry
db22(# )) as m3,
db22-# 
db22-# degrees(ST_Azimuth(
db22(#   'SRID=900913;POINT (-7788981.82643051 1405505.48023334)'::geometry,
db22(#   'SRID=900913;POINT (-7778652.06980192 1393279.22657004)'::geometry
db22(# )) as m4
db22-# ;  
       m1        |        m2        |        m3        |        m4        
-----------------+------------------+------------------+------------------
 220.19390618527 | 319.817837775187 | 89.9549832733927 | 139.806093814733



===========
select 
ST_AsEWKT(st_transform( 'SRID=4326;POINT (-69.96961422411715 12.524908758632279)'::geometry,
900913));

select
ST_AsEWKT(st_transform( 'SRID=4326;POLYGON ((-70.06240800672413 12.417669988878856, -70.06240800672413 12.632147528385701, -69.87682044151018 12.632147528385701, -69.87682044151018 12.417669988878856, -70.06240800672413 12.417669988878856))'::geometry,
900913));


 SRID=900913;POINT(-7788981.82643051 1405505.48023334)

 SRID=900913;POLYGON((-7799311.5830591 1393279.22657004,-7799311.5830591 1417736.81854813,-7778652.06980192 1417736.81854813,-7778652.06980192 1393279.22657004,-7799311.5830591 1393279.22657004))

---
SELECT 

degrees(ST_Azimuth(
  'SRID=900913;POINT (-7788981.82643051 1405505.48023334)'::geometry,
  'SRID=900913;POINT (-7799311.5830591 1393279.22657004)'::geometry
)) as m1,

degrees(ST_Azimuth(
  'SRID=900913;POINT (-7788981.82643051 1405505.48023334)'::geometry,
  'SRID=900913;POINT (-7799311.5830591 1417736.81854813)'::geometry
)) as m2,

degrees(ST_Azimuth(
  'SRID=900913;POINT (-7788981.82643051 1405505.48023334)'::geometry,
  'SRID=900913;POINT (7778652.06980192 1417736.81854813)'::geometry
)) as m3,

degrees(ST_Azimuth(
  'SRID=900913;POINT (-7788981.82643051 1405505.48023334)'::geometry,
  'SRID=900913;POINT (-7778652.06980192 1393279.22657004)'::geometry
)) as m4
;  

natural_earth2=# SELECT 
natural_earth2-# 
natural_earth2-# degrees(ST_Azimuth(
natural_earth2(#   'POINT (-7788981.82643051 1405505.48023334)'::geometry,
natural_earth2(#   'POINT (-7799311.5830591 1393279.22657004)'::geometry
natural_earth2(# )) as m1,
natural_earth2-# 
natural_earth2-# degrees(ST_Azimuth(
natural_earth2(#   'POINT (-7788981.82643051 1405505.48023334)'::geometry,
natural_earth2(#   'POINT (-7799311.5830591 1417736.81854813)'::geometry
natural_earth2(# )) as m2,
natural_earth2-# 
natural_earth2-# degrees(ST_Azimuth(
natural_earth2(#   'POINT (-7788981.82643051 1405505.48023334)'::geometry,
natural_earth2(#   'POINT (7778652.06980192 1417736.81854813)'::geometry
natural_earth2(# )) as m3,
natural_earth2-# 
natural_earth2-# degrees(ST_Azimuth(
natural_earth2(#   'POINT (-7788981.82643051 1405505.48023334)'::geometry,
natural_earth2(#   'POINT (-7778652.06980192 1393279.22657004)'::geometry
natural_earth2(# )) as m4
natural_earth2-# ;  
       m1        |        m2        |        m3        |        m4        
-----------------+------------------+------------------+------------------
 220.19390618527 | 319.817837775187 | 89.9549832733927 | 139.806093814733
(1 row)

===============================================

Change History (1)

comment:1 by darkblueb, 8 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.