/* * Retrieve an ows_version, related to current PostGIS version. */ ows_version * ows_psql_postgis_version(ows *o) { list *l; PGresult * res; ows_version * v = NULL; res = ows_psql_exec(o, "SELECT substr(postgis_full_version(), 10, 5)"); if (PQresultStatus(res) != PGRES_TUPLES_OK || PQntuples(res) != 1) { PQclear(res); return NULL; } l = list_explode_str('.', (char *) PQgetvalue(res, 0, 0)); if ( l->size == 3 && check_regexp(l->first->value->buf, "^[0-9]+$") && check_regexp(l->first->next->value->buf, "^[0-9]+$") && check_regexp(l->last->value->buf, "^[0-9]+$") ) { v = ows_version_init(); v->major = atoi(l->first->value->buf); v->minor = atoi(l->first->next->value->buf); v->release = atoi(l->last->value->buf); } list_free(l); PQclear(res); return v; }
/* * Parse the configuration file's metadata element */ static void ows_parse_config_metadata(ows * o, xmlTextReaderPtr r) { xmlChar *a; assert(o); assert(r); o->metadata = ows_metadata_init(); a = xmlTextReaderGetAttribute(r, (xmlChar *) "name"); if (a) { o->metadata->name = buffer_init(); buffer_add_str(o->metadata->name, (char *) a); xmlFree(a); } a = xmlTextReaderGetAttribute(r, (xmlChar *) "title"); if (a) { o->metadata->title = buffer_init(); buffer_add_str(o->metadata->title, (char *) a); xmlFree(a); } a = xmlTextReaderGetAttribute(r, (xmlChar *) "keywords"); if (a) { o->metadata->keywords = list_explode_str(',', (char *) a); xmlFree(a); } a = xmlTextReaderGetAttribute(r, (xmlChar *) "fees"); if (a) { o->metadata->fees = buffer_init(); buffer_add_str(o->metadata->fees, (char *) a); xmlFree(a); } a = xmlTextReaderGetAttribute(r, (xmlChar *) "access_constraints"); if (a) { o->metadata->access_constraints = buffer_init(); buffer_add_str(o->metadata->access_constraints, (char *) a); xmlFree(a); } }
/* * Parse the configuration file's layer element and all child layers */ static void ows_parse_config_layer(ows * o, xmlTextReaderPtr r) { ows_layer *layer; xmlChar *a; list *l; assert(o); assert(r); layer = ows_layer_init(); layer->depth = xmlTextReaderDepth(r); layer->parent = ows_parse_config_layer_get_parent(o, layer->depth); a = xmlTextReaderGetAttribute(r, (xmlChar *) "table"); if (a) { buffer_add_str(layer->storage->table, (char *) a); xmlFree(a); } a = xmlTextReaderGetAttribute(r, (xmlChar *) "name"); if (a) { layer->name = buffer_init(); buffer_add_str(layer->name, (char *) a); if (!layer->storage->table->use) buffer_add_str(layer->storage->table, (char *) a); xmlFree(a); } a = xmlTextReaderGetAttribute(r, (xmlChar *) "title"); if (a) { layer->title = buffer_init(); buffer_add_str(layer->title, (char *) a); xmlFree(a); } a = xmlTextReaderGetAttribute(r, (xmlChar *) "abstract"); if (a) { layer->abstract = buffer_init(); buffer_add_str(layer->abstract, (char *) a); xmlFree(a); } a = xmlTextReaderGetAttribute(r, (xmlChar *) "keywords"); if (a) { layer->keywords = list_explode_str(',', (char *) a); xmlFree(a); } a = xmlTextReaderGetAttribute(r, (xmlChar *) "gml_ns"); if (a) { layer->gml_ns = list_explode_str(',', (char *) a); xmlFree(a); } a = xmlTextReaderGetAttribute(r, (xmlChar *) "schema"); if (a) { buffer_add_str(layer->storage->schema, (char *) a); xmlFree(a); } else buffer_add_str(layer->storage->schema, "public"); /* inherits from layer parent and replaces with specified value if defined */ a = xmlTextReaderGetAttribute(r, (xmlChar *) "retrievable"); if (a && atoi((char *) a) == 1) { layer->retrievable = true; xmlFree(a); } else if (!a && layer->parent && layer->parent->retrievable) layer->retrievable = true; else xmlFree(a); /* inherits from layer parent and replaces with specified value if defined */ a = xmlTextReaderGetAttribute(r, (xmlChar *) "writable"); if (a && atoi((char *) a) == 1) { layer->writable = true; xmlFree(a); } else if (!a && layer->parent && layer->parent->writable) layer->writable = true; else xmlFree(a); /* inherits from layer parent and adds specified value */ if (layer->parent && layer->parent->srid) { layer->srid = list_init(); list_add_list(layer->srid, layer->parent->srid); } a = xmlTextReaderGetAttribute(r, (xmlChar *) "srid"); if (a) { if (!layer->srid) layer->srid = list_explode_str(',', (char *) a); else { l = list_explode_str(',', (char *) a); list_add_list(layer->srid, l); list_free(l); } xmlFree(a); } /* Inherits from layer parent and replaces with specified value if defined */ a = xmlTextReaderGetAttribute(r, (xmlChar *) "geobbox"); if (a) { layer->geobbox = ows_geobbox_init(); ows_geobbox_set_from_str(o, layer->geobbox, (char *) a); xmlFree(a); } else if (!a && layer->parent && layer->parent->geobbox) { layer->geobbox = ows_geobbox_copy(layer->parent->geobbox); } else xmlFree(a); /* Inherits from layer parent and replaces with specified value if defined */ a = xmlTextReaderGetAttribute(r, (xmlChar *) "ns_prefix"); if (a) { buffer_add_str(layer->ns_prefix, (char *) a); xmlFree(a); } else if (!a && layer->parent && layer->parent->ns_prefix) { buffer_copy(layer->ns_prefix, layer->parent->ns_prefix); } else xmlFree(a); /* Inherits from layer parent and replaces with specified value if defined */ a = xmlTextReaderGetAttribute(r, (xmlChar *) "ns_uri"); if (a) { buffer_add_str(layer->ns_uri, (char *) a); xmlFree(a); } else if (!a && layer->parent && layer->parent->ns_uri) { buffer_copy(layer->ns_uri, layer->parent->ns_uri); } else xmlFree(a); a = xmlTextReaderGetAttribute(r, (xmlChar *) "exclude_items"); if (a) { layer->exclude_items = list_explode_str_trim(',', (char *) a); xmlFree(a); } a = xmlTextReaderGetAttribute(r, (xmlChar *) "include_items"); if (a) { layer->include_items = list_explode_str_trim(',', (char *) a); xmlFree(a); } a = xmlTextReaderGetAttribute(r, (xmlChar *) "pkey"); if (a) { layer->pkey = buffer_init(); buffer_add_str(layer->pkey, (char *) a); xmlFree(a); } ows_layer_list_add(o->layers, layer); }