PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwgeom_force_sfs()

LWGEOM* lwgeom_force_sfs ( LWGEOM geom,
int  version 
)

Definition at line 838 of file lwgeom.c.

839 {
840  LWCOLLECTION *col;
841  uint32_t i;
842  LWGEOM *g;
843 
844  /* SFS 1.2 version */
845  if (version == 120)
846  {
847  switch(geom->type)
848  {
849  /* SQL/MM types */
850  case CIRCSTRINGTYPE:
851  case COMPOUNDTYPE:
852  case CURVEPOLYTYPE:
853  case MULTICURVETYPE:
854  case MULTISURFACETYPE:
855  return lwgeom_stroke(geom, 32);
856 
857  case COLLECTIONTYPE:
858  col = (LWCOLLECTION*)geom;
859  for ( i = 0; i < col->ngeoms; i++ )
860  col->geoms[i] = lwgeom_force_sfs((LWGEOM*)col->geoms[i], version);
861 
862  return lwcollection_as_lwgeom((LWCOLLECTION*)geom);
863 
864  default:
865  return (LWGEOM *)geom;
866  }
867  }
868 
869 
870  /* SFS 1.1 version */
871  switch(geom->type)
872  {
873  /* SQL/MM types */
874  case CIRCSTRINGTYPE:
875  case COMPOUNDTYPE:
876  case CURVEPOLYTYPE:
877  case MULTICURVETYPE:
878  case MULTISURFACETYPE:
879  return lwgeom_stroke(geom, 32);
880 
881  /* SFS 1.2 types */
882  case TRIANGLETYPE:
883  g = lwpoly_as_lwgeom(lwpoly_from_lwlines((LWLINE*)geom, 0, NULL));
884  lwgeom_free(geom);
885  return g;
886 
887  case TINTYPE:
888  col = (LWCOLLECTION*) geom;
889  for ( i = 0; i < col->ngeoms; i++ )
890  {
891  g = lwpoly_as_lwgeom(lwpoly_from_lwlines((LWLINE*)col->geoms[i], 0, NULL));
892  lwgeom_free(col->geoms[i]);
893  col->geoms[i] = g;
894  }
895  col->type = COLLECTIONTYPE;
896  return lwmpoly_as_lwgeom((LWMPOLY*)geom);
897 
899  geom->type = COLLECTIONTYPE;
900  return (LWGEOM *)geom;
901 
902  /* Collection */
903  case COLLECTIONTYPE:
904  col = (LWCOLLECTION*)geom;
905  for ( i = 0; i < col->ngeoms; i++ )
906  col->geoms[i] = lwgeom_force_sfs((LWGEOM*)col->geoms[i], version);
907 
908  return lwcollection_as_lwgeom((LWCOLLECTION*)geom);
909 
910  default:
911  return (LWGEOM *)geom;
912  }
913 }
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
#define COMPOUNDTYPE
Definition: liblwgeom.h:93
#define CURVEPOLYTYPE
Definition: liblwgeom.h:94
#define MULTISURFACETYPE
Definition: liblwgeom.h:96
LWGEOM * lwgeom_stroke(const LWGEOM *geom, uint32_t perQuad)
Definition: lwstroke.c:768
#define TINTYPE
Definition: liblwgeom.h:99
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:97
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
#define MULTICURVETYPE
Definition: liblwgeom.h:95
#define TRIANGLETYPE
Definition: liblwgeom.h:98
LWPOLY * lwpoly_from_lwlines(const LWLINE *shell, uint32_t nholes, const LWLINE **holes)
Definition: lwpoly.c:360
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
Definition: lwgeom.c:300
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
Definition: lwgeom.c:320
LWGEOM * lwgeom_force_sfs(LWGEOM *geom, int version)
Definition: lwgeom.c:838
LWGEOM * lwmpoly_as_lwgeom(const LWMPOLY *obj)
Definition: lwgeom.c:285
void lwgeom_free(LWGEOM *lwgeom)
Definition: lwgeom.c:1144
uint32_t ngeoms
Definition: liblwgeom.h:510
uint8_t type
Definition: liblwgeom.h:506
LWGEOM ** geoms
Definition: liblwgeom.h:512
uint8_t type
Definition: liblwgeom.h:399
unsigned int uint32_t
Definition: uthash.h:78

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

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

Here is the call graph for this function:
Here is the caller graph for this function: