PostGIS  2.2.7dev-r@@SVN_REVISION@@
int lwgeom_transform ( LWGEOM geom,
projPJ  inpj,
projPJ  outpj 
)

Transform (reproject) a geometry in-place.

Parameters
geomthe geometry to transform
inpjthe input (or current, or source) projection
outpjthe output (or destination) projection

Transform (reproject) a geometry in-place.

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

References CIRCSTRINGTYPE, COLLECTIONTYPE, COMPOUNDTYPE, CURVEPOLYTYPE, LWCOLLECTION::geoms, LINETYPE, LW_FAILURE, LW_SUCCESS, lwerror(), lwgeom_is_empty(), lwtype_name(), MULTICURVETYPE, MULTILINETYPE, MULTIPOINTTYPE, MULTIPOLYGONTYPE, MULTISURFACETYPE, LWCOLLECTION::ngeoms, LWPOLY::nrings, LWLINE::points, POINTTYPE, POLYGONTYPE, POLYHEDRALSURFACETYPE, ptarray_transform(), LWPOLY::rings, TINTYPE, TRIANGLETYPE, and LWGEOM::type.

Referenced by transform(), and transform_geom().

62 {
63  int i;
64 
65  /* No points to transform in an empty! */
66  if ( lwgeom_is_empty(geom) )
67  return LW_SUCCESS;
68 
69  switch(geom->type)
70  {
71  case POINTTYPE:
72  case LINETYPE:
73  case CIRCSTRINGTYPE:
74  case TRIANGLETYPE:
75  {
76  LWLINE *g = (LWLINE*)geom;
77  if ( ! ptarray_transform(g->points, inpj, outpj) ) return LW_FAILURE;
78  break;
79  }
80  case POLYGONTYPE:
81  {
82  LWPOLY *g = (LWPOLY*)geom;
83  for ( i = 0; i < g->nrings; i++ )
84  {
85  if ( ! ptarray_transform(g->rings[i], inpj, outpj) ) return LW_FAILURE;
86  }
87  break;
88  }
89  case MULTIPOINTTYPE:
90  case MULTILINETYPE:
91  case MULTIPOLYGONTYPE:
92  case COLLECTIONTYPE:
93  case COMPOUNDTYPE:
94  case CURVEPOLYTYPE:
95  case MULTICURVETYPE:
96  case MULTISURFACETYPE:
98  case TINTYPE:
99  {
100  LWCOLLECTION *g = (LWCOLLECTION*)geom;
101  for ( i = 0; i < g->ngeoms; i++ )
102  {
103  if ( ! lwgeom_transform(g->geoms[i], inpj, outpj) ) return LW_FAILURE;
104  }
105  break;
106  }
107  default:
108  {
109  lwerror("lwgeom_transform: Cannot handle type '%s'",
110  lwtype_name(geom->type));
111  return LW_FAILURE;
112  }
113  }
114  return LW_SUCCESS;
115 }
#define LINETYPE
Definition: liblwgeom.h:71
#define MULTICURVETYPE
Definition: liblwgeom.h:80
int lwgeom_transform(LWGEOM *geom, projPJ inpj, projPJ outpj)
Transform given SERIALIZED geometry from inpj projection to outpj projection.
#define POLYGONTYPE
Definition: liblwgeom.h:72
#define CURVEPOLYTYPE
Definition: liblwgeom.h:79
#define COMPOUNDTYPE
Definition: liblwgeom.h:78
#define MULTIPOINTTYPE
Definition: liblwgeom.h:73
#define LW_SUCCESS
Definition: liblwgeom.h:65
#define TRIANGLETYPE
Definition: liblwgeom.h:83
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:82
#define LW_FAILURE
Definition: liblwgeom.h:64
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:188
LWGEOM ** geoms
Definition: liblwgeom.h:493
#define TINTYPE
Definition: liblwgeom.h:84
POINTARRAY ** rings
Definition: liblwgeom.h:441
int nrings
Definition: liblwgeom.h:439
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:75
#define MULTISURFACETYPE
Definition: liblwgeom.h:81
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:70
uint8_t type
Definition: liblwgeom.h:380
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:77
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
Definition: lwgeom.c:1297
#define MULTILINETYPE
Definition: liblwgeom.h:74
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:74
#define COLLECTIONTYPE
Definition: liblwgeom.h:76
int ptarray_transform(POINTARRAY *pa, projPJ inpj, projPJ outpj)
Transform given POINTARRAY from inpj projection to outpj projection.
POINTARRAY * points
Definition: liblwgeom.h:406

Here is the call graph for this function:

Here is the caller graph for this function: