PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ parse_gml_linearring()

static LWGEOM* parse_gml_linearring ( xmlNodePtr  xnode,
bool *  hasz,
int *  root_srid 
)
static

Parse GML LinearRing (3.1.1)

Definition at line 1244 of file lwgeom_in_gml.c.

1245 {
1246  gmlSrs srs;
1247  LWGEOM *geom;
1248  POINTARRAY **ppa = NULL;
1249 
1250  if (is_xlink(xnode)) xnode = get_xlink_node(xnode);
1251  if (xnode == NULL)
1252  gml_lwpgerror("invalid GML representation", 30);
1253  parse_gml_srs(xnode, &srs);
1254 
1255  ppa = (POINTARRAY**) lwalloc(sizeof(POINTARRAY*));
1256  ppa[0] = parse_gml_data(xnode->children, hasz, root_srid);
1257 
1258  if (ppa[0]->npoints < 4
1259  || (!*hasz && !ptarray_is_closed_2d(ppa[0]))
1260  || (*hasz && !ptarray_is_closed_3d(ppa[0])))
1261  gml_lwpgerror("invalid GML representation", 42);
1262 
1263  if (srs.reverse_axis)
1264  ppa[0] = ptarray_flip_coordinates(ppa[0]);
1265 
1266  if (srs.srid != *root_srid && *root_srid != SRID_UNKNOWN)
1267  gml_reproject_pa(ppa[0], srs.srid, *root_srid);
1268 
1269  geom = (LWGEOM *) lwpoly_construct(*root_srid, NULL, 1, ppa);
1270 
1271  return geom;
1272 }
int ptarray_is_closed_3d(const POINTARRAY *pa)
Definition: ptarray.c:714
void * lwalloc(size_t size)
Definition: lwutil.c:227
int ptarray_is_closed_2d(const POINTARRAY *pa)
Definition: ptarray.c:701
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:230
LWPOLY * lwpoly_construct(int32_t srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
Definition: lwpoly.c:43
POINTARRAY * ptarray_flip_coordinates(POINTARRAY *pa)
Reverse X and Y axis on a given POINTARRAY.
Definition: ptarray.c:368
static xmlNodePtr get_xlink_node(xmlNodePtr xnode)
Return a xmlNodePtr on a node referenced by a XLink or NULL otherwise.
static bool is_xlink(xmlNodePtr node)
Return true if current node contains a simple XLink Return false otherwise.
static POINTARRAY * gml_reproject_pa(POINTARRAY *pa, int32_t epsg_in, int32_t epsg_out)
Use Proj to reproject a given POINTARRAY.
static void parse_gml_srs(xmlNodePtr xnode, gmlSrs *srs)
Parse gml srsName attribute.
static POINTARRAY * parse_gml_data(xmlNodePtr xnode, bool *hasz, int *root_srid)
Parse data coordinates.
static void gml_lwpgerror(char *msg, __attribute__((__unused__)) int error_code)
Definition: lwgeom_in_gml.c:81

References get_xlink_node(), gml_lwpgerror(), gml_reproject_pa(), is_xlink(), lwalloc(), lwpoly_construct(), parse_gml_data(), parse_gml_srs(), ptarray_flip_coordinates(), ptarray_is_closed_2d(), ptarray_is_closed_3d(), struct_gmlSrs::reverse_axis, struct_gmlSrs::srid, and SRID_UNKNOWN.

Referenced by parse_gml().

Here is the call graph for this function:
Here is the caller graph for this function: