PostGIS  2.1.10dev-r@@SVN_REVISION@@
static LWGEOM* parse_gml_line ( xmlNodePtr  xnode,
bool *  hasz,
int *  root_srid 
)
static

Parse GML lineString (2.1.2, 3.1.1)

Definition at line 950 of file lwgeom_in_gml.c.

References get_xlink_node(), gml_lwerror(), gml_reproject_pa(), is_xlink(), lwline_as_lwgeom(), lwline_construct(), lwline_construct_empty(), POINTARRAY::npoints, parse_gml_data(), parse_gml_srs(), ptarray_flip_coordinates(), struct_gmlSrs::reverse_axis, struct_gmlSrs::srid, and SRID_UNKNOWN.

Referenced by parse_gml().

951 {
952  gmlSrs srs;
953  LWGEOM *geom;
954  POINTARRAY *pa;
955 
956  if (is_xlink(xnode)) xnode = get_xlink_node(xnode);
957 
958  if (xnode->children == NULL)
959  return lwline_as_lwgeom(lwline_construct_empty(*root_srid, 0, 0));
960 
961  pa = parse_gml_data(xnode->children, hasz, root_srid);
962  if (pa->npoints < 2) gml_lwerror("invalid GML representation", 36);
963 
964  parse_gml_srs(xnode, &srs);
965  if (srs.reverse_axis) pa = ptarray_flip_coordinates(pa);
966  if (!*root_srid)
967  {
968  *root_srid = srs.srid;
969  geom = (LWGEOM *) lwline_construct(*root_srid, NULL, pa);
970  }
971  else
972  {
973  if (srs.srid != *root_srid)
974  gml_reproject_pa(pa, srs.srid, *root_srid);
975  geom = (LWGEOM *) lwline_construct(SRID_UNKNOWN, NULL, pa);
976  }
977 
978  return geom;
979 }
LWLINE * lwline_construct_empty(int srid, char hasz, char hasm)
Definition: lwline.c:51
int npoints
Definition: liblwgeom.h:327
static void parse_gml_srs(xmlNodePtr xnode, gmlSrs *srs)
Parse gml srsName attribute.
static POINTARRAY * gml_reproject_pa(POINTARRAY *pa, int srid_in, int srid_out)
Use Proj4 to reproject a given POINTARRAY.
POINTARRAY * ptarray_flip_coordinates(POINTARRAY *pa)
Reverse X and Y axis on a given POINTARRAY.
Definition: ptarray.c:354
static xmlNodePtr get_xlink_node(xmlNodePtr xnode)
Return a xmlNodePtr on a node referenced by a XLink or NULL otherwise.
LWGEOM * geom
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:249
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:29
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:154
static bool is_xlink(xmlNodePtr node)
Return true if current node contains a simple XLink Return false otherwise.
static POINTARRAY * parse_gml_data(xmlNodePtr xnode, bool *hasz, int *root_srid)
Parse data coordinates.
static void gml_lwerror(char *msg, int error_code)
Definition: lwgeom_in_gml.c:68

Here is the call graph for this function:

Here is the caller graph for this function: