mirror of
https://git.osgeo.org/gitea/postgis/postgis
synced 2024-10-24 00:52:40 +00:00
Remove many warnings from -pedantic build, and clean up parser globals a little more thoroughly.
git-svn-id: http://svn.osgeo.org/postgis/trunk@10661 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
parent
a4ce1e04b2
commit
dd03422897
|
@ -470,7 +470,8 @@ static void do_lwgeom_flip_coordinates(char *in, char *out)
|
|||
g = lwgeom_from_wkt(in, LW_PARSER_CHECK_NONE);
|
||||
lwgeom_add_bbox(g);
|
||||
|
||||
if ( testbox = (g->bbox != NULL) )
|
||||
testbox = (g->bbox != NULL);
|
||||
if ( testbox )
|
||||
{
|
||||
xmax = g->bbox->xmax;
|
||||
ymax = g->bbox->ymax;
|
||||
|
|
|
@ -975,7 +975,7 @@ static void out_gml2_extent(void)
|
|||
|
||||
/* GML2: MultiPolygon */
|
||||
do_gml2_extent_test(
|
||||
"MULTIPOLYGON(((1 7,7 14, 14 7, 1 7)),((-4 -6, -15 3, 0 0, -4 -6))))",
|
||||
"MULTIPOLYGON(((1 7,7 14, 14 7, 1 7)),((-4 -6, -15 3, 0 0, -4 -6)))",
|
||||
"<Box><coordinates>-15,-6 14,14</coordinates></Box>",
|
||||
NULL, 15, "");
|
||||
|
||||
|
@ -1053,7 +1053,7 @@ static void out_gml3_extent(void)
|
|||
|
||||
/* GML3: MultiPolygon */
|
||||
do_gml3_extent_test(
|
||||
"MULTIPOLYGON(((1 7,7 14, 14 7, 1 7)),((-4 -6, -15 3, 0 0, -4 -6))))",
|
||||
"MULTIPOLYGON(((1 7,7 14, 14 7, 1 7)),((-4 -6, -15 3, 0 0, -4 -6)))",
|
||||
"<Envelope><lowerCorner>-15 -6</lowerCorner><upperCorner>14 14</upperCorner></Envelope>",
|
||||
NULL, 15, 0, "");
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ static void test_lwline_split_by_point_to(void)
|
|||
coll = lwmline_construct_empty(SRID_UNKNOWN, 0, 0);
|
||||
CU_ASSERT_EQUAL(coll->ngeoms, 0);
|
||||
|
||||
line = lwgeom_as_lwline(lwgeom_from_wkt("LINESTRING(0 0,5 5, 10 0))",
|
||||
line = lwgeom_as_lwline(lwgeom_from_wkt("LINESTRING(0 0,5 5, 10 0)",
|
||||
LW_PARSER_CHECK_NONE));
|
||||
CU_ASSERT(line != NULL);
|
||||
|
||||
|
|
|
@ -412,7 +412,6 @@ int circ_tree_contains_point(const CIRC_NODE* node, const POINT2D* pt, const POI
|
|||
* If the stabline doesn't cross within the radius of a node, there's no
|
||||
* way it can cross.
|
||||
*/
|
||||
// circ_tree_print(node, 0);
|
||||
|
||||
LWDEBUGF(3, "working on node %p, edge_num %d, radius %g, center POINT(%g %g)", node, node->edge_num, node->radius, rad2deg(node->center.lon), rad2deg(node->center.lat));
|
||||
d = edge_distance_to_point(&stab_edge, &(node->center), &closest);
|
||||
|
|
|
@ -479,8 +479,9 @@ getPoint2d_cp(const POINTARRAY *pa, int n)
|
|||
void
|
||||
ptarray_set_point4d(POINTARRAY *pa, int n, const POINT4D *p4d)
|
||||
{
|
||||
uint8_t *ptr;
|
||||
assert(n >= 0 && n < pa->npoints);
|
||||
uint8_t *ptr=getPoint_internal(pa, n);
|
||||
ptr=getPoint_internal(pa, n);
|
||||
switch ( FLAGS_GET_ZM(pa->flags) )
|
||||
{
|
||||
case 3:
|
||||
|
|
|
@ -837,9 +837,10 @@ findFaceHoles(Face** faces, int nfaces)
|
|||
const GEOSGeometry *hole = GEOSGetInteriorRingN(f->geom, h);
|
||||
LWDEBUGF(2, "Looking for hole %d/%d of face %d among %d other faces", h+1, nholes, i, nfaces-i-1);
|
||||
for (j=i+1; j<nfaces; ++j) {
|
||||
const GEOSGeometry *f2er;
|
||||
Face* f2 = faces[j];
|
||||
if ( f2->parent ) continue; /* hole already assigned */
|
||||
const GEOSGeometry *f2er = GEOSGetExteriorRing(f2->geom);
|
||||
f2er = GEOSGetExteriorRing(f2->geom);
|
||||
/* TODO: can be optimized as the ring would have the
|
||||
* same vertices, possibly in different order.
|
||||
* maybe comparing number of points could already be
|
||||
|
|
|
@ -56,7 +56,7 @@ int wkt_lexer_read_srid(char *str)
|
|||
srid = clamp_srid((int)i);
|
||||
/* TODO: warn on explicit UNKNOWN srid ? */
|
||||
return srid;
|
||||
};
|
||||
}
|
||||
|
||||
static uint8_t wkt_dimensionality(char *dimensionality)
|
||||
{
|
||||
|
@ -201,7 +201,7 @@ POINT wkt_parser_coord_2(double c1, double c2)
|
|||
FLAGS_SET_Z(p.flags, 0);
|
||||
FLAGS_SET_M(p.flags, 0);
|
||||
return p;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Note, if this is an XYM coordinate we'll have to fix it later when we build
|
||||
|
@ -218,7 +218,7 @@ POINT wkt_parser_coord_3(double c1, double c2, double c3)
|
|||
FLAGS_SET_Z(p.flags, 1);
|
||||
FLAGS_SET_M(p.flags, 0);
|
||||
return p;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -233,7 +233,7 @@ POINT wkt_parser_coord_4(double c1, double c2, double c3, double c4)
|
|||
FLAGS_SET_Z(p.flags, 1);
|
||||
FLAGS_SET_M(p.flags, 1);
|
||||
return p;
|
||||
};
|
||||
}
|
||||
|
||||
POINTARRAY* wkt_parser_ptarray_add_coord(POINTARRAY *pa, POINT p)
|
||||
{
|
||||
|
@ -276,8 +276,8 @@ POINTARRAY* wkt_parser_ptarray_add_coord(POINTARRAY *pa, POINT p)
|
|||
POINTARRAY* wkt_parser_ptarray_new(POINT p)
|
||||
{
|
||||
int ndims = FLAGS_NDIMS(p.flags);
|
||||
LWDEBUG(4,"entered");
|
||||
POINTARRAY *pa = ptarray_construct_empty((ndims>2), (ndims>3), 4);
|
||||
LWDEBUG(4,"entered");
|
||||
if ( ! pa )
|
||||
{
|
||||
SET_PARSER_ERROR(PARSER_ERROR_OTHER);
|
||||
|
@ -825,9 +825,15 @@ void lwgeom_parser_result_init(LWGEOM_PARSER_RESULT *parser_result)
|
|||
void lwgeom_parser_result_free(LWGEOM_PARSER_RESULT *parser_result)
|
||||
{
|
||||
if ( parser_result->geom )
|
||||
{
|
||||
lwgeom_free(parser_result->geom);
|
||||
parser_result->geom = 0;
|
||||
}
|
||||
if ( parser_result->serialized_lwgeom )
|
||||
{
|
||||
lwfree(parser_result->serialized_lwgeom );
|
||||
parser_result->serialized_lwgeom = 0;
|
||||
}
|
||||
/* We don't free parser_result->message because
|
||||
it is a const *char */
|
||||
}
|
||||
|
@ -840,7 +846,10 @@ LWGEOM *lwgeom_from_wkt(const char *wkt, const char check)
|
|||
LWGEOM_PARSER_RESULT r;
|
||||
|
||||
if( LW_FAILURE == lwgeom_parse_wkt(&r, (char*)wkt, check) )
|
||||
{
|
||||
lwerror(r.message);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return r.geom;
|
||||
}
|
||||
|
|
|
@ -655,7 +655,7 @@ static void wkt_lexer_unknown()
|
|||
global_parser_result.errcode = PARSER_ERROR_OTHER;
|
||||
global_parser_result.message = parser_error_messages[PARSER_ERROR_OTHER];
|
||||
global_parser_result.errlocation = wkt_yylloc.last_column;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
@ -672,7 +672,7 @@ static void wkt_lexer_unknown()
|
|||
} while (0);
|
||||
|
||||
|
||||
#line 675 "lwin_wkt_lex.c"
|
||||
#line 676 "lwin_wkt_lex.c"
|
||||
|
||||
#define INITIAL 0
|
||||
|
||||
|
@ -852,10 +852,10 @@ YY_DECL
|
|||
register char *yy_cp, *yy_bp;
|
||||
register int yy_act;
|
||||
|
||||
#line 63 "lwin_wkt_lex.l"
|
||||
#line 64 "lwin_wkt_lex.l"
|
||||
|
||||
|
||||
#line 858 "lwin_wkt_lex.c"
|
||||
#line 859 "lwin_wkt_lex.c"
|
||||
|
||||
if ( !(yy_init) )
|
||||
{
|
||||
|
@ -936,7 +936,7 @@ do_action: /* This label is used only to access EOF actions. */
|
|||
|
||||
case 1:
|
||||
YY_RULE_SETUP
|
||||
#line 65 "lwin_wkt_lex.l"
|
||||
#line 66 "lwin_wkt_lex.l"
|
||||
{
|
||||
LWDEBUG(5,"DOUBLE");
|
||||
wkt_yylval.doublevalue = atof(wkt_yytext);
|
||||
|
@ -945,7 +945,7 @@ YY_RULE_SETUP
|
|||
YY_BREAK
|
||||
case 2:
|
||||
YY_RULE_SETUP
|
||||
#line 71 "lwin_wkt_lex.l"
|
||||
#line 72 "lwin_wkt_lex.l"
|
||||
{
|
||||
LWDEBUG(5,"SRID");
|
||||
wkt_yylval.integervalue = wkt_lexer_read_srid(wkt_yytext);
|
||||
|
@ -954,87 +954,87 @@ YY_RULE_SETUP
|
|||
YY_BREAK
|
||||
case 3:
|
||||
YY_RULE_SETUP
|
||||
#line 77 "lwin_wkt_lex.l"
|
||||
#line 78 "lwin_wkt_lex.l"
|
||||
{ return COLLECTION_TOK; }
|
||||
YY_BREAK
|
||||
case 4:
|
||||
YY_RULE_SETUP
|
||||
#line 78 "lwin_wkt_lex.l"
|
||||
#line 79 "lwin_wkt_lex.l"
|
||||
{ return MSURFACE_TOK; }
|
||||
YY_BREAK
|
||||
case 5:
|
||||
YY_RULE_SETUP
|
||||
#line 79 "lwin_wkt_lex.l"
|
||||
#line 80 "lwin_wkt_lex.l"
|
||||
{ return MPOLYGON_TOK; }
|
||||
YY_BREAK
|
||||
case 6:
|
||||
YY_RULE_SETUP
|
||||
#line 80 "lwin_wkt_lex.l"
|
||||
#line 81 "lwin_wkt_lex.l"
|
||||
{ return MCURVE_TOK; }
|
||||
YY_BREAK
|
||||
case 7:
|
||||
YY_RULE_SETUP
|
||||
#line 81 "lwin_wkt_lex.l"
|
||||
#line 82 "lwin_wkt_lex.l"
|
||||
{ return MLINESTRING_TOK; }
|
||||
YY_BREAK
|
||||
case 8:
|
||||
YY_RULE_SETUP
|
||||
#line 82 "lwin_wkt_lex.l"
|
||||
#line 83 "lwin_wkt_lex.l"
|
||||
{ return MPOINT_TOK; }
|
||||
YY_BREAK
|
||||
case 9:
|
||||
YY_RULE_SETUP
|
||||
#line 83 "lwin_wkt_lex.l"
|
||||
#line 84 "lwin_wkt_lex.l"
|
||||
{ return CURVEPOLYGON_TOK; }
|
||||
YY_BREAK
|
||||
case 10:
|
||||
YY_RULE_SETUP
|
||||
#line 84 "lwin_wkt_lex.l"
|
||||
#line 85 "lwin_wkt_lex.l"
|
||||
{ return POLYGON_TOK; }
|
||||
YY_BREAK
|
||||
case 11:
|
||||
YY_RULE_SETUP
|
||||
#line 85 "lwin_wkt_lex.l"
|
||||
#line 86 "lwin_wkt_lex.l"
|
||||
{ return COMPOUNDCURVE_TOK; }
|
||||
YY_BREAK
|
||||
case 12:
|
||||
YY_RULE_SETUP
|
||||
#line 86 "lwin_wkt_lex.l"
|
||||
#line 87 "lwin_wkt_lex.l"
|
||||
{ return CIRCULARSTRING_TOK; }
|
||||
YY_BREAK
|
||||
case 13:
|
||||
YY_RULE_SETUP
|
||||
#line 87 "lwin_wkt_lex.l"
|
||||
#line 88 "lwin_wkt_lex.l"
|
||||
{ return LINESTRING_TOK; }
|
||||
YY_BREAK
|
||||
case 14:
|
||||
YY_RULE_SETUP
|
||||
#line 88 "lwin_wkt_lex.l"
|
||||
#line 89 "lwin_wkt_lex.l"
|
||||
{ return POLYHEDRALSURFACE_TOK; }
|
||||
YY_BREAK
|
||||
case 15:
|
||||
YY_RULE_SETUP
|
||||
#line 89 "lwin_wkt_lex.l"
|
||||
#line 90 "lwin_wkt_lex.l"
|
||||
{ return TRIANGLE_TOK; }
|
||||
YY_BREAK
|
||||
case 16:
|
||||
YY_RULE_SETUP
|
||||
#line 90 "lwin_wkt_lex.l"
|
||||
#line 91 "lwin_wkt_lex.l"
|
||||
{ return TIN_TOK; }
|
||||
YY_BREAK
|
||||
case 17:
|
||||
YY_RULE_SETUP
|
||||
#line 91 "lwin_wkt_lex.l"
|
||||
#line 92 "lwin_wkt_lex.l"
|
||||
{ return POINT_TOK; }
|
||||
YY_BREAK
|
||||
case 18:
|
||||
YY_RULE_SETUP
|
||||
#line 92 "lwin_wkt_lex.l"
|
||||
#line 93 "lwin_wkt_lex.l"
|
||||
{ return EMPTY_TOK; }
|
||||
YY_BREAK
|
||||
case 19:
|
||||
YY_RULE_SETUP
|
||||
#line 94 "lwin_wkt_lex.l"
|
||||
#line 95 "lwin_wkt_lex.l"
|
||||
{
|
||||
LWDEBUG(5,"DIMENSIONALITY");
|
||||
wkt_yylval.stringvalue = wkt_yytext;
|
||||
|
@ -1043,33 +1043,33 @@ YY_RULE_SETUP
|
|||
YY_BREAK
|
||||
case 20:
|
||||
YY_RULE_SETUP
|
||||
#line 100 "lwin_wkt_lex.l"
|
||||
#line 101 "lwin_wkt_lex.l"
|
||||
{ LWDEBUG(5,"LBRACKET"); return LBRACKET_TOK; }
|
||||
YY_BREAK
|
||||
case 21:
|
||||
YY_RULE_SETUP
|
||||
#line 101 "lwin_wkt_lex.l"
|
||||
#line 102 "lwin_wkt_lex.l"
|
||||
{ LWDEBUG(5,"RBRACKET"); return RBRACKET_TOK; }
|
||||
YY_BREAK
|
||||
case 22:
|
||||
YY_RULE_SETUP
|
||||
#line 102 "lwin_wkt_lex.l"
|
||||
#line 103 "lwin_wkt_lex.l"
|
||||
{ LWDEBUG(5,"COMMA"); return COMMA_TOK; }
|
||||
YY_BREAK
|
||||
case 23:
|
||||
YY_RULE_SETUP
|
||||
#line 103 "lwin_wkt_lex.l"
|
||||
#line 104 "lwin_wkt_lex.l"
|
||||
{ LWDEBUG(5,"SEMICOLON"); return SEMICOLON_TOK; }
|
||||
YY_BREAK
|
||||
case 24:
|
||||
/* rule 24 can match eol */
|
||||
YY_RULE_SETUP
|
||||
#line 105 "lwin_wkt_lex.l"
|
||||
#line 106 "lwin_wkt_lex.l"
|
||||
{ /* ignore whitespace */ LWDEBUG(5,"WHITESPACE"); }
|
||||
YY_BREAK
|
||||
case 25:
|
||||
YY_RULE_SETUP
|
||||
#line 107 "lwin_wkt_lex.l"
|
||||
#line 108 "lwin_wkt_lex.l"
|
||||
{ /* Error out and stop parsing on unknown/unexpected characters */
|
||||
LWDEBUG(5,"UNKNOWN");
|
||||
wkt_lexer_unknown();
|
||||
|
@ -1078,10 +1078,10 @@ YY_RULE_SETUP
|
|||
YY_BREAK
|
||||
case 26:
|
||||
YY_RULE_SETUP
|
||||
#line 113 "lwin_wkt_lex.l"
|
||||
#line 114 "lwin_wkt_lex.l"
|
||||
ECHO;
|
||||
YY_BREAK
|
||||
#line 1084 "lwin_wkt_lex.c"
|
||||
#line 1085 "lwin_wkt_lex.c"
|
||||
case YY_STATE_EOF(INITIAL):
|
||||
yyterminate();
|
||||
|
||||
|
@ -2038,7 +2038,7 @@ void wkt_yyfree (void * ptr )
|
|||
|
||||
#define YYTABLES_NAME "yytables"
|
||||
|
||||
#line 113 "lwin_wkt_lex.l"
|
||||
#line 114 "lwin_wkt_lex.l"
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ static void wkt_lexer_unknown()
|
|||
global_parser_result.errcode = PARSER_ERROR_OTHER;
|
||||
global_parser_result.message = parser_error_messages[PARSER_ERROR_OTHER];
|
||||
global_parser_result.errlocation = wkt_yylloc.last_column;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,24 +1,21 @@
|
|||
/* A Bison parser, made by GNU Bison 2.3. */
|
||||
/* A Bison parser, made by GNU Bison 2.5. */
|
||||
|
||||
/* Skeleton interface for Bison's Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* As a special exception, you may create a larger work that contains
|
||||
part or all of the Bison parser skeleton and distribute that work
|
||||
|
@ -29,10 +26,11 @@
|
|||
special exception, which will cause the skeleton and the resulting
|
||||
Bison output files to be licensed under the GNU General Public
|
||||
License without this special exception.
|
||||
|
||||
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
|
||||
/* Tokens. */
|
||||
#ifndef YYTOKENTYPE
|
||||
# define YYTOKENTYPE
|
||||
|
@ -94,21 +92,26 @@
|
|||
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
typedef union YYSTYPE
|
||||
#line 102 "lwin_wkt_parse.y"
|
||||
{
|
||||
|
||||
/* Line 2068 of yacc.c */
|
||||
#line 98 "lwin_wkt_parse.y"
|
||||
|
||||
int integervalue;
|
||||
double doublevalue;
|
||||
char *stringvalue;
|
||||
LWGEOM *geometryvalue;
|
||||
POINT coordinatevalue;
|
||||
POINTARRAY *ptarrayvalue;
|
||||
}
|
||||
/* Line 1529 of yacc.c. */
|
||||
#line 108 "lwin_wkt_parse.h"
|
||||
YYSTYPE;
|
||||
|
||||
|
||||
|
||||
/* Line 2068 of yacc.c */
|
||||
#line 111 "lwin_wkt_parse.h"
|
||||
} YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
|
||||
extern YYSTYPE wkt_yylval;
|
||||
|
@ -127,3 +130,4 @@ typedef struct YYLTYPE
|
|||
#endif
|
||||
|
||||
extern YYLTYPE wkt_yylloc;
|
||||
|
||||
|
|
|
@ -50,12 +50,7 @@ int lwgeom_parse_wkt(LWGEOM_PARSER_RESULT *parser_result, char *wktstr, int pars
|
|||
int parse_rv = 0;
|
||||
|
||||
/* Clean up our global parser result. */
|
||||
global_parser_result.geom = NULL;
|
||||
global_parser_result.message = NULL;
|
||||
global_parser_result.serialized_lwgeom = NULL;
|
||||
global_parser_result.errcode = 0;
|
||||
global_parser_result.errlocation = 0;
|
||||
global_parser_result.size = 0;
|
||||
lwgeom_parser_result_init(&global_parser_result);
|
||||
|
||||
/* Set the input text string, and parse checks. */
|
||||
global_parser_result.wkinput = wktstr;
|
||||
|
|
|
@ -96,11 +96,11 @@ static size_t
|
|||
asx3d3_point_size(const LWPOINT *point, char *srs, int precision, int opts, const char *defid)
|
||||
{
|
||||
int size;
|
||||
//size_t defidlen = strlen(defid);
|
||||
/* size_t defidlen = strlen(defid); */
|
||||
|
||||
size = pointArray_X3Dsize(point->point, precision);
|
||||
//size += ( sizeof("<point><pos>/") + (defidlen*2) ) * 2;
|
||||
//if (srs) size += strlen(srs) + sizeof(" srsName=..");
|
||||
/* size += ( sizeof("<point><pos>/") + (defidlen*2) ) * 2; */
|
||||
/* if (srs) size += strlen(srs) + sizeof(" srsName=.."); */
|
||||
return size;
|
||||
}
|
||||
|
||||
|
@ -108,19 +108,19 @@ static size_t
|
|||
asx3d3_point_buf(const LWPOINT *point, char *srs, char *output, int precision, int opts, const char *defid)
|
||||
{
|
||||
char *ptr = output;
|
||||
//int dimension=2;
|
||||
/* int dimension=2; */
|
||||
|
||||
//if (FLAGS_GET_Z(point->flags)) dimension = 3;
|
||||
/* if (FLAGS_GET_Z(point->flags)) dimension = 3; */
|
||||
/* if ( srs )
|
||||
{
|
||||
ptr += sprintf(ptr, "<%sPoint srsName=\"%s\">", defid, srs);
|
||||
}
|
||||
else*/
|
||||
//ptr += sprintf(ptr, "%s", defid);
|
||||
/* ptr += sprintf(ptr, "%s", defid); */
|
||||
|
||||
//ptr += sprintf(ptr, "<%spos>", defid);
|
||||
/* ptr += sprintf(ptr, "<%spos>", defid); */
|
||||
ptr += pointArray_toX3D3(point->point, ptr, precision, opts, 0);
|
||||
//ptr += sprintf(ptr, "</%spos></%sPoint>", defid, defid);
|
||||
/* ptr += sprintf(ptr, "</%spos></%sPoint>", defid, defid); */
|
||||
|
||||
return (ptr-output);
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ asx3d3_line_size(const LWLINE *line, char *srs, int precision, int opts, const c
|
|||
sizeof("<LineSet vertexCount=''><Coordinate point='' /></LineSet>") + defidlen
|
||||
) * 2;
|
||||
|
||||
//if (srs) size += strlen(srs) + sizeof(" srsName=..");
|
||||
/* if (srs) size += strlen(srs) + sizeof(" srsName=.."); */
|
||||
return size;
|
||||
}
|
||||
|
||||
|
@ -158,11 +158,11 @@ static size_t
|
|||
asx3d3_line_buf(const LWLINE *line, char *srs, char *output, int precision, int opts, const char *defid)
|
||||
{
|
||||
char *ptr=output;
|
||||
//int dimension=2;
|
||||
/* int dimension=2; */
|
||||
POINTARRAY *pa;
|
||||
|
||||
|
||||
//if (FLAGS_GET_Z(line->flags)) dimension = 3;
|
||||
/* if (FLAGS_GET_Z(line->flags)) dimension = 3; */
|
||||
|
||||
pa = line->points;
|
||||
ptr += sprintf(ptr, "<LineSet %s vertexCount='%d'>", defid, pa->npoints);
|
||||
|
@ -181,7 +181,7 @@ static size_t
|
|||
asx3d3_line_coords(const LWLINE *line, char *output, int precision, int opts)
|
||||
{
|
||||
char *ptr=output;
|
||||
//ptr += sprintf(ptr, "");
|
||||
/* ptr += sprintf(ptr, ""); */
|
||||
ptr += pointArray_toX3D3(line->points, ptr, precision, opts, lwline_is_closed(line));
|
||||
return (ptr-output);
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ asx3d3_mline_coordindex(const LWMLINE *mgeom, char *output)
|
|||
geom = (LWLINE *) mgeom->geoms[i];
|
||||
pa = geom->points;
|
||||
np = pa->npoints;
|
||||
si = j; //start index of first point of linestring
|
||||
si = j; /* start index of first point of linestring */
|
||||
for (k=0; k < np ; k++)
|
||||
{
|
||||
if (k)
|
||||
|
@ -224,7 +224,7 @@ asx3d3_mline_coordindex(const LWMLINE *mgeom, char *output)
|
|||
}
|
||||
if (i < (mgeom->ngeoms - 1) )
|
||||
{
|
||||
ptr += sprintf(ptr, " -1 "); //separator for each linestring
|
||||
ptr += sprintf(ptr, " -1 "); /* separator for each linestring */
|
||||
}
|
||||
}
|
||||
return (ptr-output);
|
||||
|
@ -266,12 +266,12 @@ asx3d3_mpoly_coordindex(const LWMPOLY *psur, char *output)
|
|||
* For now will leave it as polygons stacked on top of each other -- which is what we are doing here and perhaps an option
|
||||
* to color differently. It's not ideal but the alternative sounds complicated.
|
||||
**/
|
||||
ptr += sprintf(ptr, " -1 "); //separator for each inner ring. Ideally we should probably triangulate and cut around as others do
|
||||
ptr += sprintf(ptr, " -1 "); /* separator for each inner ring. Ideally we should probably triangulate and cut around as others do */
|
||||
}
|
||||
}
|
||||
if (i < (psur->ngeoms - 1) )
|
||||
{
|
||||
ptr += sprintf(ptr, " -1 "); //separator for each subgeom
|
||||
ptr += sprintf(ptr, " -1 "); /* separator for each subgeom */
|
||||
}
|
||||
}
|
||||
return (ptr-output);
|
||||
|
@ -319,7 +319,7 @@ asx3d3_poly_buf(const LWPOLY *poly, char *srs, char *output, int precision, int
|
|||
ptr += pointArray_toX3D3(poly->rings[0], ptr, precision, opts, 1);
|
||||
for (i=1; i<poly->nrings; i++)
|
||||
{
|
||||
ptr += sprintf(ptr, " "); //inner ring points start
|
||||
ptr += sprintf(ptr, " "); /* inner ring points start */
|
||||
ptr += pointArray_toX3D3(poly->rings[i], ptr, precision, opts,1);
|
||||
}
|
||||
return (ptr-output);
|
||||
|
@ -376,24 +376,24 @@ asx3d3_multi_size(const LWCOLLECTION *col, char *srs, int precision, int opts, c
|
|||
/* the longest possible multi version needs to hold DEF=defid and coordinate breakout */
|
||||
size = sizeof("<PointSet><Coordinate point='' /></PointSet>") + defidlen;
|
||||
|
||||
//if ( srs ) size += strlen(srs) + sizeof(" srsName=..");
|
||||
/* if ( srs ) size += strlen(srs) + sizeof(" srsName=.."); */
|
||||
|
||||
for (i=0; i<col->ngeoms; i++)
|
||||
{
|
||||
subgeom = col->geoms[i];
|
||||
if (subgeom->type == POINTTYPE)
|
||||
{
|
||||
//size += ( sizeof("point=''") + defidlen ) * 2;
|
||||
/* size += ( sizeof("point=''") + defidlen ) * 2; */
|
||||
size += asx3d3_point_size((LWPOINT*)subgeom, 0, precision, opts, defid);
|
||||
}
|
||||
else if (subgeom->type == LINETYPE)
|
||||
{
|
||||
//size += ( sizeof("<curveMember>/") + defidlen ) * 2;
|
||||
/* size += ( sizeof("<curveMember>/") + defidlen ) * 2; */
|
||||
size += asx3d3_line_size((LWLINE*)subgeom, 0, precision, opts, defid);
|
||||
}
|
||||
else if (subgeom->type == POLYGONTYPE)
|
||||
{
|
||||
//size += ( sizeof("<surfaceMember>/") + defidlen ) * 2;
|
||||
/* size += ( sizeof("<surfaceMember>/") + defidlen ) * 2; */
|
||||
size += asx3d3_poly_size((LWPOLY*)subgeom, 0, precision, opts, defid);
|
||||
}
|
||||
}
|
||||
|
@ -544,7 +544,7 @@ asx3d3_psurface_buf(const LWPSURFACE *psur, char *srs, char *output, int precisi
|
|||
}
|
||||
if (i < (psur->ngeoms - 1) )
|
||||
{
|
||||
ptr += sprintf(ptr, " -1 "); //separator for each subgeom
|
||||
ptr += sprintf(ptr, " -1 "); /* separator for each subgeom */
|
||||
}
|
||||
j += k;
|
||||
}
|
||||
|
@ -556,7 +556,7 @@ asx3d3_psurface_buf(const LWPSURFACE *psur, char *srs, char *output, int precisi
|
|||
ptr += asx3d3_poly_buf(psur->geoms[i], 0, ptr, precision, opts, 1, defid);
|
||||
if (i < (psur->ngeoms - 1) )
|
||||
{
|
||||
ptr += sprintf(ptr, " "); //only add a trailing space if its not the last polygon in the set
|
||||
ptr += sprintf(ptr, " "); /* only add a trailing space if its not the last polygon in the set */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -588,7 +588,7 @@ asx3d3_tin_size(const LWTIN *tin, char *srs, int precision, int opts, const char
|
|||
int i;
|
||||
size_t size;
|
||||
size_t defidlen = strlen(defid);
|
||||
//int dimension=2;
|
||||
/* int dimension=2; */
|
||||
|
||||
/** Need to make space for size of additional attributes,
|
||||
** the coordIndex has a value for each edge for each triangle plus a space to separate so we need at least that much extra room ***/
|
||||
|
@ -612,7 +612,7 @@ asx3d3_tin_buf(const LWTIN *tin, char *srs, char *output, int precision, int opt
|
|||
char *ptr;
|
||||
int i;
|
||||
int k;
|
||||
//int dimension=2;
|
||||
/* int dimension=2; */
|
||||
|
||||
ptr = output;
|
||||
|
||||
|
|
|
@ -378,9 +378,9 @@ point to point calculation
|
|||
int
|
||||
lw_dist3d_point_point(LWPOINT *point1, LWPOINT *point2, DISTPTS3D *dl)
|
||||
{
|
||||
LWDEBUG(2, "lw_dist3d_point_point is called");
|
||||
POINT3DZ p1;
|
||||
POINT3DZ p2;
|
||||
LWDEBUG(2, "lw_dist3d_point_point is called");
|
||||
|
||||
getPoint3dz_p(point1->point, 0, &p1);
|
||||
getPoint3dz_p(point2->point, 0, &p2);
|
||||
|
@ -394,9 +394,9 @@ point to line calculation
|
|||
int
|
||||
lw_dist3d_point_line(LWPOINT *point, LWLINE *line, DISTPTS3D *dl)
|
||||
{
|
||||
LWDEBUG(2, "lw_dist3d_point_line is called");
|
||||
POINT3DZ p;
|
||||
POINTARRAY *pa = line->points;
|
||||
LWDEBUG(2, "lw_dist3d_point_line is called");
|
||||
|
||||
getPoint3dz_p(point->point, 0, &p);
|
||||
return lw_dist3d_pt_ptarray(&p, pa, dl);
|
||||
|
@ -416,9 +416,9 @@ for max distance it is always point against boundary
|
|||
int
|
||||
lw_dist3d_point_poly(LWPOINT *point, LWPOLY *poly, DISTPTS3D *dl)
|
||||
{
|
||||
LWDEBUG(2, "lw_dist3d_point_poly is called");
|
||||
POINT3DZ p, projp;/*projp is "point projected on plane"*/
|
||||
PLANE3D plane;
|
||||
LWDEBUG(2, "lw_dist3d_point_poly is called");
|
||||
getPoint3dz_p(point->point, 0, &p);
|
||||
|
||||
/*If we are lookig for max distance, longestline or dfullywithin*/
|
||||
|
@ -446,9 +446,9 @@ line to line calculation
|
|||
int
|
||||
lw_dist3d_line_line(LWLINE *line1, LWLINE *line2, DISTPTS3D *dl)
|
||||
{
|
||||
LWDEBUG(2, "lw_dist3d_line_line is called");
|
||||
POINTARRAY *pa1 = line1->points;
|
||||
POINTARRAY *pa2 = line2->points;
|
||||
LWDEBUG(2, "lw_dist3d_line_line is called");
|
||||
|
||||
return lw_dist3d_ptarray_ptarray(pa1, pa2, dl);
|
||||
}
|
||||
|
@ -459,8 +459,8 @@ line to polygon calculation
|
|||
*/
|
||||
int lw_dist3d_line_poly(LWLINE *line, LWPOLY *poly, DISTPTS3D *dl)
|
||||
{
|
||||
LWDEBUG(2, "lw_dist3d_line_poly is called");
|
||||
PLANE3D plane;
|
||||
LWDEBUG(2, "lw_dist3d_line_poly is called");
|
||||
|
||||
if (dl->mode == DIST_MAX)
|
||||
{
|
||||
|
@ -479,8 +479,8 @@ polygon to polygon calculation
|
|||
*/
|
||||
int lw_dist3d_poly_poly(LWPOLY *poly1, LWPOLY *poly2, DISTPTS3D *dl)
|
||||
{
|
||||
LWDEBUG(2, "lw_dist3d_poly_poly is called");
|
||||
PLANE3D plane;
|
||||
LWDEBUG(2, "lw_dist3d_poly_poly is called");
|
||||
if (dl->mode == DIST_MAX)
|
||||
{
|
||||
return lw_dist3d_ptarray_ptarray(poly1->rings[0], poly2->rings[0], dl);
|
||||
|
@ -597,11 +597,11 @@ depending on dl->mode (max or min)
|
|||
int
|
||||
lw_dist3d_pt_pt(POINT3DZ *thep1, POINT3DZ *thep2,DISTPTS3D *dl)
|
||||
{
|
||||
LWDEBUGF(2, "lw_dist3d_pt_pt called (with points: p1.x=%f, p1.y=%f,p1.z=%f,p2.x=%f, p2.y=%f,p2.z=%f)",thep1->x,thep1->y,thep1->z,thep2->x,thep2->y,thep2->z );
|
||||
double dx = thep2->x - thep1->x;
|
||||
double dy = thep2->y - thep1->y;
|
||||
double dz = thep2->z - thep1->z;
|
||||
double dist = sqrt ( dx*dx + dy*dy + dz*dz);
|
||||
LWDEBUGF(2, "lw_dist3d_pt_pt called (with points: p1.x=%f, p1.y=%f,p1.z=%f,p2.x=%f, p2.y=%f,p2.z=%f)",thep1->x,thep1->y,thep1->z,thep2->x,thep2->y,thep2->z );
|
||||
|
||||
if (((dl->distance - dist)*(dl->mode))>0) /*multiplication with mode to handle mindistance (mode=1) and maxdistance (mode = (-1)*/
|
||||
{
|
||||
|
@ -629,11 +629,11 @@ Finds all combinationes of segments between two pointarrays
|
|||
int
|
||||
lw_dist3d_ptarray_ptarray(POINTARRAY *l1, POINTARRAY *l2,DISTPTS3D *dl)
|
||||
{
|
||||
LWDEBUGF(2, "lw_dist3d_ptarray_ptarray called (points: %d-%d)",l1->npoints, l2->npoints);
|
||||
int t,u;
|
||||
POINT3DZ start, end;
|
||||
POINT3DZ start2, end2;
|
||||
int twist = dl->twisted;
|
||||
LWDEBUGF(2, "lw_dist3d_ptarray_ptarray called (points: %d-%d)",l1->npoints, l2->npoints);
|
||||
|
||||
|
||||
|
||||
|
@ -683,6 +683,11 @@ Finds the two closest points on two linesegments
|
|||
int
|
||||
lw_dist3d_seg_seg(POINT3DZ *s1p1, POINT3DZ *s1p2, POINT3DZ *s2p1, POINT3DZ *s2p2, DISTPTS3D *dl)
|
||||
{
|
||||
VECTOR3D v1, v2, vl;
|
||||
double s1k, s2k; /*two variables representing where on Line 1 (s1k) and where on Line 2 (s2k) a connecting line between the two lines is perpendicular to both lines*/
|
||||
POINT3DZ p1, p2;
|
||||
double a, b, c, d, e, D;
|
||||
|
||||
/*s1p1 and s1p2 are the same point */
|
||||
if ( ( s1p1->x == s1p2->x) && (s1p1->y == s1p2->y) && (s1p1->z == s1p2->y) )
|
||||
{
|
||||
|
@ -694,19 +699,13 @@ lw_dist3d_seg_seg(POINT3DZ *s1p1, POINT3DZ *s1p2, POINT3DZ *s2p1, POINT3DZ *s2p2
|
|||
dl->twisted= ((dl->twisted) * (-1));
|
||||
return lw_dist3d_pt_seg(s2p1,s1p1,s1p2,dl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Here we use algorithm from softsurfer.com
|
||||
that can be found here
|
||||
http://softsurfer.com/Archive/algorithm_0106/algorithm_0106.htm
|
||||
*/
|
||||
|
||||
|
||||
VECTOR3D v1, v2, vl;
|
||||
double s1k, s2k; /*two variables representing where on Line 1 (s1k) and where on Line 2 (s2k) a connecting line between the two lines is perpendicular to both lines*/
|
||||
POINT3DZ p1, p2;
|
||||
|
||||
if (!get_3dvector_from_points(s1p1, s1p2, &v1))
|
||||
return LW_FALSE;
|
||||
|
||||
|
@ -716,12 +715,12 @@ lw_dist3d_seg_seg(POINT3DZ *s1p1, POINT3DZ *s1p2, POINT3DZ *s2p1, POINT3DZ *s2p2
|
|||
if (!get_3dvector_from_points(s2p1, s1p1, &vl))
|
||||
return LW_FALSE;
|
||||
|
||||
double a = DOT(v1,v1);
|
||||
double b = DOT(v1,v2);
|
||||
double c = DOT(v2,v2);
|
||||
double d = DOT(v1,vl);
|
||||
double e = DOT(v2,vl);
|
||||
double D = a*c - b*b;
|
||||
a = DOT(v1,v1);
|
||||
b = DOT(v1,v2);
|
||||
c = DOT(v2,v2);
|
||||
d = DOT(v1,vl);
|
||||
e = DOT(v2,vl);
|
||||
D = a*c - b*b;
|
||||
|
||||
|
||||
if (D <0.000000001)
|
||||
|
@ -854,6 +853,7 @@ int lw_dist3d_ptarray_poly(POINTARRAY *pa, LWPOLY *poly,PLANE3D *plane, DISTPTS3
|
|||
|
||||
for (i=1;i<pa->npoints;i++)
|
||||
{
|
||||
int intersects;
|
||||
getPoint3dz_p(pa, i, &p2);
|
||||
s2=project_point_on_plane(&p2, plane, &projp2);
|
||||
lw_dist3d_pt_poly(&p2, poly, plane,&projp2, dl);
|
||||
|
@ -870,7 +870,7 @@ int lw_dist3d_ptarray_poly(POINTARRAY *pa, LWPOLY *poly,PLANE3D *plane, DISTPTS3
|
|||
intersectionp.y=projp1.y+f*projp1_projp2.y;
|
||||
intersectionp.z=projp1.z+f*projp1_projp2.z;
|
||||
|
||||
int intersects = LW_TRUE; /*We set intersects to true until the opposite is proved*/
|
||||
intersects = LW_TRUE; /*We set intersects to true until the opposite is proved*/
|
||||
|
||||
if(pt_in_ring_3d(&intersectionp, poly->rings[0], plane)) /*Inside outer ring*/
|
||||
{
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
* this entire file is in the public domain
|
||||
*/
|
||||
|
||||
Datum LWGEOM_dumppoints(PG_FUNCTION_ARGS);
|
||||
|
||||
struct dumpnode {
|
||||
LWGEOM *geom;
|
||||
int idx; /* which member geom we're working on */
|
||||
|
@ -40,7 +42,6 @@ struct dumpstate {
|
|||
};
|
||||
|
||||
PG_FUNCTION_INFO_V1(LWGEOM_dumppoints);
|
||||
|
||||
Datum LWGEOM_dumppoints(PG_FUNCTION_ARGS) {
|
||||
FuncCallContext *funcctx;
|
||||
MemoryContext oldcontext, newcontext;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "liblwgeom.h"
|
||||
|
||||
Datum geom_from_geojson(PG_FUNCTION_ARGS);
|
||||
|
||||
Datum postgis_libjson_version(PG_FUNCTION_ARGS);
|
||||
|
||||
static void geojson_lwerror(char *msg, int error_code)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue