32
32
* Internal routines
33
33
*/
34
34
35
+ enum path_delim { PATH_NONE , PATH_OPEN , PATH_CLOSED };
36
+
35
37
static int point_inside (Point * p , int npts , Point * plist );
36
38
static int lseg_crossing (double x , double y , double px , double py );
37
39
static BOX * box_construct (double x1 , double x2 , double y1 , double y2 );
@@ -57,7 +59,7 @@ static int pair_decode(char *str, float8 *x, float8 *y, char **s);
57
59
static int pair_encode (float8 x , float8 y , char * str );
58
60
static int pair_count (char * s , char delim );
59
61
static int path_decode (int opentype , int npts , char * str , int * isopen , char * * ss , Point * p );
60
- static char * path_encode (bool closed , int npts , Point * pt );
62
+ static char * path_encode (enum path_delim path_delim , int npts , Point * pt );
61
63
static void statlseg_construct (LSEG * lseg , Point * pt1 , Point * pt2 );
62
64
static double box_ar (BOX * box );
63
65
static void box_cn (Point * center , BOX * box );
@@ -280,7 +282,7 @@ path_decode(int opentype, int npts, char *str, int *isopen, char **ss, Point *p)
280
282
} /* path_decode() */
281
283
282
284
static char *
283
- path_encode (bool closed , int npts , Point * pt )
285
+ path_encode (enum path_delim path_delim , int npts , Point * pt )
284
286
{
285
287
int size = npts * (P_MAXLEN + 3 ) + 2 ;
286
288
char * result ;
@@ -296,15 +298,15 @@ path_encode(bool closed, int npts, Point *pt)
296
298
result = palloc (size );
297
299
298
300
cp = result ;
299
- switch (closed )
301
+ switch (path_delim )
300
302
{
301
- case TRUE :
303
+ case PATH_CLOSED :
302
304
* cp ++ = LDELIM ;
303
305
break ;
304
- case FALSE :
306
+ case PATH_OPEN :
305
307
* cp ++ = LDELIM_EP ;
306
308
break ;
307
- default :
309
+ case PATH_NONE :
308
310
break ;
309
311
}
310
312
@@ -322,15 +324,15 @@ path_encode(bool closed, int npts, Point *pt)
322
324
pt ++ ;
323
325
}
324
326
cp -- ;
325
- switch (closed )
327
+ switch (path_delim )
326
328
{
327
- case TRUE :
329
+ case PATH_CLOSED :
328
330
* cp ++ = RDELIM ;
329
331
break ;
330
- case FALSE :
332
+ case PATH_OPEN :
331
333
* cp ++ = RDELIM_EP ;
332
334
break ;
333
- default :
335
+ case PATH_NONE :
334
336
break ;
335
337
}
336
338
* cp = '\0' ;
@@ -415,7 +417,7 @@ box_out(PG_FUNCTION_ARGS)
415
417
{
416
418
BOX * box = PG_GETARG_BOX_P (0 );
417
419
418
- PG_RETURN_CSTRING (path_encode (-1 , 2 , & (box -> high )));
420
+ PG_RETURN_CSTRING (path_encode (PATH_NONE , 2 , & (box -> high )));
419
421
}
420
422
421
423
/*
@@ -1018,7 +1020,7 @@ line_out(PG_FUNCTION_ARGS)
1018
1020
{
1019
1021
}
1020
1022
1021
- return path_encode (TRUE , 2 , (Point * ) & (ls -> p [0 ]));
1023
+ return path_encode (PATH_CLOSED , 2 , (Point * ) & (ls -> p [0 ]));
1022
1024
#else
1023
1025
ereport (ERROR ,
1024
1026
(errcode (ERRCODE_FEATURE_NOT_SUPPORTED ),
@@ -1441,7 +1443,7 @@ path_out(PG_FUNCTION_ARGS)
1441
1443
{
1442
1444
PATH * path = PG_GETARG_PATH_P (0 );
1443
1445
1444
- PG_RETURN_CSTRING (path_encode (path -> closed , path -> npts , path -> p ));
1446
+ PG_RETURN_CSTRING (path_encode (path -> closed ? PATH_CLOSED : PATH_OPEN , path -> npts , path -> p ));
1445
1447
}
1446
1448
1447
1449
/*
@@ -1823,7 +1825,7 @@ point_out(PG_FUNCTION_ARGS)
1823
1825
{
1824
1826
Point * pt = PG_GETARG_POINT_P (0 );
1825
1827
1826
- PG_RETURN_CSTRING (path_encode (-1 , 1 , pt ));
1828
+ PG_RETURN_CSTRING (path_encode (PATH_NONE , 1 , pt ));
1827
1829
}
1828
1830
1829
1831
/*
@@ -2051,7 +2053,7 @@ lseg_out(PG_FUNCTION_ARGS)
2051
2053
{
2052
2054
LSEG * ls = PG_GETARG_LSEG_P (0 );
2053
2055
2054
- PG_RETURN_CSTRING (path_encode (FALSE , 2 , (Point * ) & (ls -> p [0 ])));
2056
+ PG_RETURN_CSTRING (path_encode (PATH_OPEN , 2 , (Point * ) & (ls -> p [0 ])));
2055
2057
}
2056
2058
2057
2059
/*
@@ -3494,7 +3496,7 @@ poly_out(PG_FUNCTION_ARGS)
3494
3496
{
3495
3497
POLYGON * poly = PG_GETARG_POLYGON_P (0 );
3496
3498
3497
- PG_RETURN_CSTRING (path_encode (TRUE , poly -> npts , poly -> p ));
3499
+ PG_RETURN_CSTRING (path_encode (PATH_CLOSED , poly -> npts , poly -> p ));
3498
3500
}
3499
3501
3500
3502
/*
0 commit comments