1101 static const double DEFAULT_MITRE_LIMIT = 5.0;
1102 static const int DEFAULT_JOIN_STYLE = JOIN_ROUND;
1103 double mitreLimit = DEFAULT_MITRE_LIMIT;
1104 int joinStyle = DEFAULT_JOIN_STYLE;
1106 char *paramstr = NULL;
1110 gser_input = PG_GETARG_GSERIALIZED_P(0);
1111 size = PG_GETARG_FLOAT8(1);
1116 lwpgerror(
"ST_OffsetCurve only works with LineStrings");
1126 PG_RETURN_POINTER(gser_input);
1130 if ( ! lwgeom_input )
1131 lwpgerror(
"ST_OffsetCurve: lwgeom_from_gserialized returned NULL");
1135 PG_RETURN_POINTER(gser_input);
1140 text *wkttext = PG_GETARG_TEXT_P(2);
1143 POSTGIS_DEBUGF(3,
"paramstr: %s", paramstr);
1145 for ( param=paramstr; ; param=NULL )
1148 param = strtok(param,
" ");
1149 if ( param == NULL )
break;
1150 POSTGIS_DEBUGF(3,
"Param: %s", param);
1153 val = strchr(key,
'=');
1154 if ( val == NULL || *(val+1) ==
'\0' )
1156 lwpgerror(
"ST_OffsetCurve: Missing value for buffer parameter %s", key);
1162 POSTGIS_DEBUGF(3,
"Param: %s : %s", key, val);
1164 if ( !strcmp(key,
"join") )
1166 if ( !strcmp(val,
"round") )
1168 joinStyle = JOIN_ROUND;
1170 else if ( !(strcmp(val,
"mitre") && strcmp(val,
"miter")) )
1172 joinStyle = JOIN_MITRE;
1174 else if ( ! strcmp(val,
"bevel") )
1176 joinStyle = JOIN_BEVEL;
1180 lwpgerror(
"Invalid buffer end cap style: %s (accept: " 1181 "'round', 'mitre', 'miter' or 'bevel')", val);
1185 else if ( !strcmp(key,
"mitre_limit") ||
1186 !strcmp(key,
"miter_limit") )
1189 mitreLimit = atof(val);
1191 else if ( !strcmp(key,
"quad_segs") )
1194 quadsegs = atoi(val);
1198 lwpgerror(
"Invalid buffer parameter: %s (accept: " 1199 "'join', 'mitre_limit', 'miter_limit and " 1200 "'quad_segs')", key);
1204 POSTGIS_DEBUGF(3,
"joinStyle:%d mitreLimit:%g", joinStyle, mitreLimit);
1210 if (lwgeom_result == NULL)
1211 lwpgerror(
"ST_OffsetCurve: lwgeom_offsetcurve returned NULL");
1216 PG_RETURN_POINTER(gser_result);
uint32_t gserialized_get_type(const GSERIALIZED *s)
Extract the geometry type from the serialized form (it hides in the anonymous data area...
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
LWGEOM * lwgeom_offsetcurve(const LWLINE *lwline, double size, int quadsegs, int joinStyle, double mitreLimit)
char * text2cstring(const text *textptr)
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
GSERIALIZED * gserialized_from_lwgeom(LWGEOM *geom, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.