PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwgeom_transform()

int lwgeom_transform ( LWGEOM geom,
projPJ  inpj,
projPJ  outpj 
)

Transform given SERIALIZED geometry from inpj projection to outpj projection.

Transform (reproject) a geometry in-place.

Definition at line 74 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().

75 {
76  int i;
77 
78  /* No points to transform in an empty! */
79  if ( lwgeom_is_empty(geom) )
80  return LW_SUCCESS;
81 
82  switch(geom->type)
83  {
84  case POINTTYPE:
85  case LINETYPE:
86  case CIRCSTRINGTYPE:
87  case TRIANGLETYPE:
88  {
89  LWLINE *g = (LWLINE*)geom;
90  if ( ! ptarray_transform(g->points, inpj, outpj) ) return LW_FAILURE;
91  break;
92  }
93  case POLYGONTYPE:
94  {
95  LWPOLY *g = (LWPOLY*)geom;
96  for ( i = 0; i < g->nrings; i++ )
97  {
98  if ( ! ptarray_transform(g->rings[i], inpj, outpj) ) return LW_FAILURE;
99  }
100  break;
101  }
102  case MULTIPOINTTYPE:
103  case MULTILINETYPE:
104  case MULTIPOLYGONTYPE:
105  case COLLECTIONTYPE:
106  case COMPOUNDTYPE:
107  case CURVEPOLYTYPE:
108  case MULTICURVETYPE:
109  case MULTISURFACETYPE:
111  case TINTYPE:
112  {
113  LWCOLLECTION *g = (LWCOLLECTION*)geom;
114  for ( i = 0; i < g->ngeoms; i++ )
115  {
116  if ( ! lwgeom_transform(g->geoms[i], inpj, outpj) ) return LW_FAILURE;
117  }
118  break;
119  }
120  default:
121  {
122  lwerror("lwgeom_transform: Cannot handle type '%s'",
123  lwtype_name(geom->type));
124  return LW_FAILURE;
125  }
126  }
127  return LW_SUCCESS;
128 }
#define LINETYPE
Definition: liblwgeom.h:86
#define MULTICURVETYPE
Definition: liblwgeom.h:95
int lwgeom_transform(LWGEOM *geom, projPJ inpj, projPJ outpj)
Transform given SERIALIZED geometry from inpj projection to outpj projection.
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define CURVEPOLYTYPE
Definition: liblwgeom.h:94
#define COMPOUNDTYPE
Definition: liblwgeom.h:93
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
#define LW_SUCCESS
Definition: liblwgeom.h:80
#define TRIANGLETYPE
Definition: liblwgeom.h:98
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:97
#define LW_FAILURE
Definition: liblwgeom.h:79
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
LWGEOM ** geoms
Definition: liblwgeom.h:509
#define TINTYPE
Definition: liblwgeom.h:99
POINTARRAY ** rings
Definition: liblwgeom.h:457
int nrings
Definition: liblwgeom.h:455
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
#define MULTISURFACETYPE
Definition: liblwgeom.h:96
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
uint8_t type
Definition: liblwgeom.h:396
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
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:1346
#define MULTILINETYPE
Definition: liblwgeom.h:89
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
int ptarray_transform(POINTARRAY *pa, projPJ inpj, projPJ outpj)
Transform given POINTARRAY from inpj projection to outpj projection.
POINTARRAY * points
Definition: liblwgeom.h:422
Here is the call graph for this function:
Here is the caller graph for this function: