If the coordinates are given in terms of a center point rather than outside limits, the longitude and latitude which form the central axis are recorded twice (in subfields $d and $e and in $f and $g, respectively).
368 xmlNodePtr datafield;
372 uint8_t geometry_type;
377 POSTGIS_DEBUGF(2,
"parse_marc21 called: root '<%s>'", xnode->name);
384 if (xmlStrcmp(xnode->name, (xmlChar*)
"record")) lwpgerror(
"invalid MARC21/XML document. Root element <record> expected but <%s> found.",xnode->name);
389 for (datafield = xnode->children; datafield != NULL; datafield = datafield->next) {
396 if (datafield->type != XML_ELEMENT_NODE)
continue;
398 if (xmlStrcmp(datafield->name, (xmlChar*)
"datafield") != 0 || xmlStrcmp(xmlGetProp(datafield, (xmlChar*)
"tag"),(xmlChar*)
"034") != 0)
continue;
400 POSTGIS_DEBUG(3,
" datafield found");
402 for (subfield = datafield->children; subfield != NULL; subfield = subfield->next) {
404 if (subfield->type != XML_ELEMENT_NODE)
continue;
405 if (xmlStrcmp(subfield->name, (xmlChar*)
"subfield") != 0)
continue;
407 code = (
char*) xmlGetProp(subfield, (xmlChar*)
"code");
409 if ((strcmp(code,
"d") != 0 && strcmp(code,
"e") != 0 && strcmp(code,
"f") != 0 && strcmp(code,
"g")) != 0)
continue;
411 literal = (
char*) xmlNodeGetContent(subfield);
413 POSTGIS_DEBUGF(3,
" subfield code '%s': %s", code, literal);
417 if (strcmp(code,
"d") == 0) lw = literal;
418 else if (strcmp(code,
"e") == 0) le = literal;
419 else if (strcmp(code,
"f") == 0) ln = literal;
420 else if (strcmp(code,
"g") == 0) ls = literal;
424 lwpgerror(
"parse error - invalid literal at 034$%s: \"%s\"", code, literal);
430 xmlFreeNode(subfield);
432 if (lw && le && ln && ls) {
442 if (fabs(
w - e) < 0.0000001f && fabs(n -
s) < 0.0000001f) {
460 if (ngeoms && result_type != geometry_type) {
463 result_type = geometry_type;
470 if (lw || le || ln || ls) {
472 lwpgerror(
"parse error - the Coded Cartographic Mathematical Data (datafield:034) in the given MARC21/XML is incomplete. Coordinates for subfields \"$d\",\"$e\",\"$f\" and \"$g\" are expected.");
479 POSTGIS_DEBUG(5,
" xmlFreeNode(datafield)");
480 xmlFreeNode(datafield);
488 }
else if (ngeoms > 1) {
492 for (i = 0; i < ngeoms; i++) {
508 POSTGIS_DEBUG(2,
"=> parse_marc21 returns NULL");
char result[OUT_DOUBLE_BUFFER_SIZE]
LWPOINT * lwpoint_make2d(int32_t srid, double x, double y)
LWPOLY * lwpoly_construct_envelope(int32_t srid, double x1, double y1, double x2, double y2)
void * lwrealloc(void *mem, size_t size)
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
void lwgeom_force_clockwise(LWGEOM *lwgeom)
Force Right-hand-rule on LWGEOM polygons.
LWCOLLECTION * lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
Appends geom to the collection managed by col.
void * lwalloc(size_t size)
#define LW_TRUE
Return types for functions with status returns.
#define SRID_UNKNOWN
Unknown SRID value.
static double parse_geo_literal(char *literal)
static int is_literal_valid(const char *literal)
static uint32_t lwgeom_get_type(const LWGEOM *geom)
Return LWTYPE number.