PostGIS  3.0.0dev-r@@SVN_REVISION@@

◆ lwgeom_force_sfs()

LWGEOM* lwgeom_force_sfs ( LWGEOM geom,
int  version 
)

Definition at line 829 of file lwgeom.c.

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

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

830 {
831  LWCOLLECTION *col;
832  uint32_t i;
833  LWGEOM *g;
834 
835  /* SFS 1.2 version */
836  if (version == 120)
837  {
838  switch(geom->type)
839  {
840  /* SQL/MM types */
841  case CIRCSTRINGTYPE:
842  case COMPOUNDTYPE:
843  case CURVEPOLYTYPE:
844  case MULTICURVETYPE:
845  case MULTISURFACETYPE:
846  return lwgeom_stroke(geom, 32);
847 
848  case COLLECTIONTYPE:
849  col = (LWCOLLECTION*)geom;
850  for ( i = 0; i < col->ngeoms; i++ )
851  col->geoms[i] = lwgeom_force_sfs((LWGEOM*)col->geoms[i], version);
852 
853  return lwcollection_as_lwgeom((LWCOLLECTION*)geom);
854 
855  default:
856  return (LWGEOM *)geom;
857  }
858  }
859 
860 
861  /* SFS 1.1 version */
862  switch(geom->type)
863  {
864  /* SQL/MM types */
865  case CIRCSTRINGTYPE:
866  case COMPOUNDTYPE:
867  case CURVEPOLYTYPE:
868  case MULTICURVETYPE:
869  case MULTISURFACETYPE:
870  return lwgeom_stroke(geom, 32);
871 
872  /* SFS 1.2 types */
873  case TRIANGLETYPE:
874  g = lwpoly_as_lwgeom(lwpoly_from_lwlines((LWLINE*)geom, 0, NULL));
875  lwgeom_free(geom);
876  return g;
877 
878  case TINTYPE:
879  col = (LWCOLLECTION*) geom;
880  for ( i = 0; i < col->ngeoms; i++ )
881  {
882  g = lwpoly_as_lwgeom(lwpoly_from_lwlines((LWLINE*)col->geoms[i], 0, NULL));
883  lwgeom_free(col->geoms[i]);
884  col->geoms[i] = g;
885  }
886  col->type = COLLECTIONTYPE;
887  return lwmpoly_as_lwgeom((LWMPOLY*)geom);
888 
890  geom->type = COLLECTIONTYPE;
891  return (LWGEOM *)geom;
892 
893  /* Collection */
894  case COLLECTIONTYPE:
895  col = (LWCOLLECTION*)geom;
896  for ( i = 0; i < col->ngeoms; i++ )
897  col->geoms[i] = lwgeom_force_sfs((LWGEOM*)col->geoms[i], version);
898 
899  return lwcollection_as_lwgeom((LWCOLLECTION*)geom);
900 
901  default:
902  return (LWGEOM *)geom;
903  }
904 }
LWGEOM * lwgeom_stroke(const LWGEOM *geom, uint32_t perQuad)
Definition: lwstroke.c:760
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
Definition: lwgeom.c:311
#define MULTICURVETYPE
Definition: liblwgeom.h:94
uint8_t type
Definition: liblwgeom.h:505
#define CURVEPOLYTYPE
Definition: liblwgeom.h:93
#define COMPOUNDTYPE
Definition: liblwgeom.h:92
#define TRIANGLETYPE
Definition: liblwgeom.h:97
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:96
uint32_t ngeoms
Definition: liblwgeom.h:509
unsigned int uint32_t
Definition: uthash.h:78
LWGEOM * lwmpoly_as_lwgeom(const LWMPOLY *obj)
Definition: lwgeom.c:276
LWGEOM ** geoms
Definition: liblwgeom.h:511
#define TINTYPE
Definition: liblwgeom.h:98
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
Definition: lwgeom.c:291
LWPOLY * lwpoly_from_lwlines(const LWLINE *shell, uint32_t nholes, const LWLINE **holes)
Definition: lwpoly.c:360
LWGEOM * lwgeom_force_sfs(LWGEOM *geom, int version)
Definition: lwgeom.c:829
#define MULTISURFACETYPE
Definition: liblwgeom.h:95
uint8_t type
Definition: liblwgeom.h:398
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:91
void lwgeom_free(LWGEOM *lwgeom)
Definition: lwgeom.c:1128
#define COLLECTIONTYPE
Definition: liblwgeom.h:90
Here is the call graph for this function:
Here is the caller graph for this function: