PostGIS  2.1.10dev-r@@SVN_REVISION@@
LWGEOM* lwgeom_force_sfs ( LWGEOM geom,
int  version 
)

Definition at line 700 of file lwgeom.c.

References CIRCSTRINGTYPE, COLLECTIONTYPE, COMPOUNDTYPE, CURVEPOLYTYPE, LWCOLLECTION::geoms, lwcollection_as_lwgeom(), lwgeom_free(), lwgeom_segmentize(), lwmpoly_as_lwgeom(), lwpoly_as_lwgeom(), lwpoly_from_lwlines(), MULTICURVETYPE, MULTISURFACETYPE, LWCOLLECTION::ngeoms, POLYHEDRALSURFACETYPE, TINTYPE, TRIANGLETYPE, LWGEOM::type, and LWCOLLECTION::type.

Referenced by do_geom_test(), do_type_test(), and LWGEOM_force_sfs().

701 {
702  LWCOLLECTION *col;
703  int i;
704  LWGEOM *g;
705 
706  /* SFS 1.2 version */
707  if (version == 120)
708  {
709  switch(geom->type)
710  {
711  /* SQL/MM types */
712  case CIRCSTRINGTYPE:
713  case COMPOUNDTYPE:
714  case CURVEPOLYTYPE:
715  case MULTICURVETYPE:
716  case MULTISURFACETYPE:
717  return lwgeom_segmentize(geom, 32);
718 
719  case COLLECTIONTYPE:
720  col = (LWCOLLECTION*)geom;
721  for ( i = 0; i < col->ngeoms; i++ )
722  col->geoms[i] = lwgeom_force_sfs((LWGEOM*)col->geoms[i], version);
723 
724  return lwcollection_as_lwgeom((LWCOLLECTION*)geom);
725 
726  default:
727  return (LWGEOM *)geom;
728  }
729  }
730 
731 
732  /* SFS 1.1 version */
733  switch(geom->type)
734  {
735  /* SQL/MM types */
736  case CIRCSTRINGTYPE:
737  case COMPOUNDTYPE:
738  case CURVEPOLYTYPE:
739  case MULTICURVETYPE:
740  case MULTISURFACETYPE:
741  return lwgeom_segmentize(geom, 32);
742 
743  /* SFS 1.2 types */
744  case TRIANGLETYPE:
745  g = lwpoly_as_lwgeom(lwpoly_from_lwlines((LWLINE*)geom, 0, NULL));
746  lwgeom_free(geom);
747  return g;
748 
749  case TINTYPE:
750  col = (LWCOLLECTION*) geom;
751  for ( i = 0; i < col->ngeoms; i++ )
752  {
753  g = lwpoly_as_lwgeom(lwpoly_from_lwlines((LWLINE*)col->geoms[i], 0, NULL));
754  lwgeom_free(col->geoms[i]);
755  col->geoms[i] = g;
756  }
757  col->type = COLLECTIONTYPE;
758  return lwmpoly_as_lwgeom((LWMPOLY*)geom);
759 
761  geom->type = COLLECTIONTYPE;
762  return (LWGEOM *)geom;
763 
764  /* Collection */
765  case COLLECTIONTYPE:
766  col = (LWCOLLECTION*)geom;
767  for ( i = 0; i < col->ngeoms; i++ )
768  col->geoms[i] = lwgeom_force_sfs((LWGEOM*)col->geoms[i], version);
769 
770  return lwcollection_as_lwgeom((LWCOLLECTION*)geom);
771 
772  default:
773  return (LWGEOM *)geom;
774  }
775 }
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
Definition: lwgeom.c:239
#define MULTICURVETYPE
Definition: liblwgeom.h:70
uint8_t type
Definition: liblwgeom.h:459
#define CURVEPOLYTYPE
Definition: liblwgeom.h:69
#define COMPOUNDTYPE
Definition: liblwgeom.h:68
#define TRIANGLETYPE
Definition: liblwgeom.h:73
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:72
LWGEOM * lwgeom_segmentize(LWGEOM *geom, uint32_t perQuad)
Definition: lwsegmentize.c:446
LWGEOM * lwmpoly_as_lwgeom(const LWMPOLY *obj)
Definition: lwgeom.c:204
LWGEOM ** geoms
Definition: liblwgeom.h:465
#define TINTYPE
Definition: liblwgeom.h:74
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
Definition: lwgeom.c:219
LWPOLY * lwpoly_from_lwlines(const LWLINE *shell, uint32_t nholes, const LWLINE **holes)
Definition: lwpoly.c:250
LWGEOM * lwgeom_force_sfs(LWGEOM *geom, int version)
Definition: lwgeom.c:700
#define MULTISURFACETYPE
Definition: liblwgeom.h:71
uint8_t type
Definition: liblwgeom.h:352
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:67
void lwgeom_free(LWGEOM *lwgeom)
Definition: lwgeom.c:1006
#define COLLECTIONTYPE
Definition: liblwgeom.h:66

Here is the call graph for this function:

Here is the caller graph for this function: