1081 static const double DEFAULT_MITRE_LIMIT = 5.0;
1082 static const int DEFAULT_JOIN_STYLE = JOIN_ROUND;
1083 double mitreLimit = DEFAULT_MITRE_LIMIT;
1084 int joinStyle = DEFAULT_JOIN_STYLE;
1086 char *paramstr = NULL;
1090 gser_input = PG_GETARG_GSERIALIZED_P(0);
1091 size = PG_GETARG_FLOAT8(1);
1094 if (size == 0) PG_RETURN_POINTER(gser_input);
1098 if ( ! lwgeom_input )
1099 lwpgerror(
"ST_OffsetCurve: lwgeom_from_gserialized returned NULL");
1103 PG_RETURN_POINTER(gser_input);
1108 text *wkttext = PG_GETARG_TEXT_P(2);
1111 POSTGIS_DEBUGF(3,
"paramstr: %s", paramstr);
1113 for ( param=paramstr; ; param=NULL )
1116 param = strtok(param,
" ");
1118 POSTGIS_DEBUGF(3,
"Param: %s", param);
1121 val = strchr(key,
'=');
1122 if (!val || *(val + 1) ==
'\0')
1124 lwpgerror(
"ST_OffsetCurve: Missing value for buffer parameter %s", key);
1130 POSTGIS_DEBUGF(3,
"Param: %s : %s", key, val);
1132 if ( !strcmp(key,
"join") )
1134 if ( !strcmp(val,
"round") )
1136 joinStyle = JOIN_ROUND;
1138 else if ( !(strcmp(val,
"mitre") && strcmp(val,
"miter")) )
1140 joinStyle = JOIN_MITRE;
1142 else if ( ! strcmp(val,
"bevel") )
1144 joinStyle = JOIN_BEVEL;
1149 "Invalid buffer end cap style: %s (accept: 'round', 'mitre', 'miter' or 'bevel')",
1154 else if ( !strcmp(key,
"mitre_limit") ||
1155 !strcmp(key,
"miter_limit") )
1158 mitreLimit = atof(val);
1160 else if ( !strcmp(key,
"quad_segs") )
1163 quadsegs = atoi(val);
1168 "Invalid buffer parameter: %s (accept: 'join', 'mitre_limit', 'miter_limit and 'quad_segs')",
1173 POSTGIS_DEBUGF(3,
"joinStyle:%d mitreLimit:%g", joinStyle, mitreLimit);
1177 lwgeom_result =
lwgeom_offsetcurve(lwgeom_input, size, quadsegs, joinStyle, mitreLimit);
1180 lwpgerror(
"ST_OffsetCurve: lwgeom_offsetcurve returned NULL");
1185 PG_RETURN_POINTER(gser_result);
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
GSERIALIZED * gserialized_from_lwgeom(LWGEOM *geom, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.
void lwgeom_free(LWGEOM *geom)
LWGEOM * lwgeom_offsetcurve(const LWGEOM *geom, double size, int quadsegs, int joinStyle, double mitreLimit)
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
char * text_to_cstring(const text *textptr)