PostGIS  3.4.0dev-r@@SVN_REVISION@@
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages

◆ lwgeom_force_sfs()

LWGEOM* lwgeom_force_sfs ( LWGEOM geom,
int  version 
)

Definition at line 849 of file lwgeom.c.

850 {
851  LWCOLLECTION *col;
852  uint32_t i;
853  LWGEOM *g;
854 
855  /* SFS 1.2 version */
856  if (version == 120)
857  {
858  switch(geom->type)
859  {
860  /* SQL/MM types */
861  case CIRCSTRINGTYPE:
862  case COMPOUNDTYPE:
863  case CURVEPOLYTYPE:
864  case MULTICURVETYPE:
865  case MULTISURFACETYPE:
866  return lwgeom_stroke(geom, 32);
867 
868  case COLLECTIONTYPE:
869  col = (LWCOLLECTION*)geom;
870  for ( i = 0; i < col->ngeoms; i++ )
871  col->geoms[i] = lwgeom_force_sfs((LWGEOM*)col->geoms[i], version);
872 
873  return lwcollection_as_lwgeom((LWCOLLECTION*)geom);
874 
875  default:
876  return (LWGEOM *)geom;
877  }
878  }
879 
880 
881  /* SFS 1.1 version */
882  switch(geom->type)
883  {
884  /* SQL/MM types */
885  case CIRCSTRINGTYPE:
886  case COMPOUNDTYPE:
887  case CURVEPOLYTYPE:
888  case MULTICURVETYPE:
889  case MULTISURFACETYPE:
890  return lwgeom_stroke(geom, 32);
891 
892  /* SFS 1.2 types */
893  case TRIANGLETYPE:
894  g = lwpoly_as_lwgeom(lwpoly_from_lwlines((LWLINE*)geom, 0, NULL));
895  lwgeom_free(geom);
896  return g;
897 
898  case TINTYPE:
899  col = (LWCOLLECTION*) geom;
900  for ( i = 0; i < col->ngeoms; i++ )
901  {
902  g = lwpoly_as_lwgeom(lwpoly_from_lwlines((LWLINE*)col->geoms[i], 0, NULL));
903  lwgeom_free(col->geoms[i]);
904  col->geoms[i] = g;
905  }
906  col->type = COLLECTIONTYPE;
907  return lwmpoly_as_lwgeom((LWMPOLY*)geom);
908 
910  geom->type = COLLECTIONTYPE;
911  return (LWGEOM *)geom;
912 
913  /* Collection */
914  case COLLECTIONTYPE:
915  col = (LWCOLLECTION*)geom;
916  for ( i = 0; i < col->ngeoms; i++ )
917  col->geoms[i] = lwgeom_force_sfs((LWGEOM*)col->geoms[i], version);
918 
919  return lwcollection_as_lwgeom((LWCOLLECTION*)geom);
920 
921  default:
922  return (LWGEOM *)geom;
923  }
924 }
#define COLLECTIONTYPE
Definition: liblwgeom.h:108
#define COMPOUNDTYPE
Definition: liblwgeom.h:110
#define CURVEPOLYTYPE
Definition: liblwgeom.h:111
#define MULTISURFACETYPE
Definition: liblwgeom.h:113
LWGEOM * lwgeom_stroke(const LWGEOM *geom, uint32_t perQuad)
Convert type with arcs into equivalent linearized type.
Definition: lwstroke.c:871
#define TINTYPE
Definition: liblwgeom.h:116
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:114
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:109
#define MULTICURVETYPE
Definition: liblwgeom.h:112
#define TRIANGLETYPE
Definition: liblwgeom.h:115
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:309
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
Definition: lwgeom.c:329
LWGEOM * lwgeom_force_sfs(LWGEOM *geom, int version)
Definition: lwgeom.c:849
LWGEOM * lwmpoly_as_lwgeom(const LWMPOLY *obj)
Definition: lwgeom.c:294
void lwgeom_free(LWGEOM *lwgeom)
Definition: lwgeom.c:1155
uint32_t ngeoms
Definition: liblwgeom.h:580
uint8_t type
Definition: liblwgeom.h:578
LWGEOM ** geoms
Definition: liblwgeom.h:575
uint8_t type
Definition: liblwgeom.h:462

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: