PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ point4d_transform()

int point4d_transform ( POINT4D pt,
projPJ  srcpj,
projPJ  dstpj 
)

Definition at line 118 of file liblwgeom/lwgeom_transform.c.

References LWDEBUGF, lwerror(), lwnotice(), to_dec(), to_rad(), POINT4D::x, POINT4D::y, and POINT4D::z.

Referenced by ptarray_transform().

119 {
120  int* pj_errno_ref;
121  POINT4D orig_pt;
122 
123  /* Make a copy of the input point so we can report the original should an error occur */
124  orig_pt.x = pt->x;
125  orig_pt.y = pt->y;
126  orig_pt.z = pt->z;
127 
128  if (pj_is_latlong(srcpj)) to_rad(pt) ;
129 
130  LWDEBUGF(4, "transforming POINT(%f %f) from '%s' to '%s'", orig_pt.x, orig_pt.y, pj_get_def(srcpj,0), pj_get_def(dstpj,0));
131 
132  /* Perform the transform */
133  pj_transform(srcpj, dstpj, 1, 0, &(pt->x), &(pt->y), &(pt->z));
134 
135  /* For NAD grid-shift errors, display an error message with an additional hint */
136  pj_errno_ref = pj_get_errno_ref();
137 
138  if (*pj_errno_ref != 0)
139  {
140  if (*pj_errno_ref == -38)
141  {
142  lwnotice("PostGIS was unable to transform the point because either no grid shift files were found, or the point does not lie within the range for which the grid shift is defined. Refer to the ST_Transform() section of the PostGIS manual for details on how to configure PostGIS to alter this behaviour.");
143  lwerror("transform: couldn't project point (%g %g %g): %s (%d)",
144  orig_pt.x, orig_pt.y, orig_pt.z, pj_strerrno(*pj_errno_ref), *pj_errno_ref);
145  return 0;
146  }
147  else
148  {
149  lwerror("transform: couldn't project point (%g %g %g): %s (%d)",
150  orig_pt.x, orig_pt.y, orig_pt.z, pj_strerrno(*pj_errno_ref), *pj_errno_ref);
151  return 0;
152  }
153  }
154 
155  if (pj_is_latlong(dstpj)) to_dec(pt);
156  return 1;
157 }
double x
Definition: liblwgeom.h:336
static void to_dec(POINT4D *pt)
convert radians to decimal degress
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Definition: lwutil.c:61
double z
Definition: liblwgeom.h:336
static void to_rad(POINT4D *pt)
convert decimal degress to radians
double y
Definition: liblwgeom.h:336
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:74
Here is the call graph for this function:
Here is the caller graph for this function: