[Mapbender-commits] r9678 - trunk/mapbender/http/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon Feb 6 00:50:05 PST 2017
Author: armin11
Date: 2017-02-06 00:50:05 -0800 (Mon, 06 Feb 2017)
New Revision: 9678
Modified:
trunk/mapbender/http/classes/class_wfsToDb.php
trunk/mapbender/http/classes/class_wfs_1_0_factory.php
trunk/mapbender/http/classes/class_wfs_1_1_factory.php
trunk/mapbender/http/classes/class_wfs_2_0_factory.php
trunk/mapbender/http/classes/class_wfs_featuretype.php
Log:
Fix problem when mapbender try to parse complex featuretype schemata (e.g. inpsire).
Modified: trunk/mapbender/http/classes/class_wfsToDb.php
===================================================================
--- trunk/mapbender/http/classes/class_wfsToDb.php 2017-02-06 08:40:09 UTC (rev 9677)
+++ trunk/mapbender/http/classes/class_wfsToDb.php 2017-02-06 08:50:05 UTC (rev 9678)
@@ -326,7 +326,7 @@
$v = array($aWfs->id);
$t = array('i');
$c = 2;
- $sql = "SELECT featuretype_id, featuretype_name, featuretype_title, featuretype_abstract, inspire_download FROM wfs_featuretype WHERE fkey_wfs_id = $1 AND NOT featuretype_name IN(";
+ $sql = "SELECT featuretype_id, featuretype_name, featuretype_title, featuretype_abstract, inspire_download, featuretype_schema, featuretype_schema_problem FROM wfs_featuretype WHERE fkey_wfs_id = $1 AND NOT featuretype_name IN(";
$e = new mb_notice("class_wfsToDb.php: WFS_UPDATE: count featuretypeArray: ".count($aWfs->featureTypeArray));
for($i=0; $i<count($aWfs->featureTypeArray); $i++){
@@ -1163,8 +1163,8 @@
private static function insertFeatureType ($aWfsFeatureType) {
$uuid = new Uuid();
$sql = "INSERT INTO wfs_featuretype (fkey_wfs_id, featuretype_name, " .
- "featuretype_title, featuretype_abstract, featuretype_searchable, featuretype_srs, featuretype_latlon_bbox, uuid, inspire_download) " .
- "VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9)";
+ "featuretype_title, featuretype_abstract, featuretype_searchable, featuretype_srs, featuretype_latlon_bbox, uuid, inspire_download, featuretype_schema, featuretype_schema_problem) " .
+ "VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)";
$v = array(
$aWfsFeatureType->wfs->id,
@@ -1175,9 +1175,11 @@
$aWfsFeatureType->srs,
$aWfsFeatureType->latLonBboxArray['minx'].','.$aWfsFeatureType->latLonBboxArray['miny'].','.$aWfsFeatureType->latLonBboxArray['maxx'].','.$aWfsFeatureType->latLonBboxArray['maxy'],
$uuid,
- 0 //default not generate a INSPIRE Download Feed
+ 0, //default not generate a INSPIRE Download Feed
+ $aWfsFeatureType->schema,
+ $aWfsFeatureType->schema_problem
);
- $t = array('i','s','s','s','i','s','s','s','i');
+ $t = array('i','s','s','s','i','s','s','s','i','s','b');
#$e = new mb_notice("class_wfsToDb.php: INSERTING Featuretype (FT: $aWfsFeatureType->name)");
$res = db_prep_query($sql,$v,$t);
@@ -1259,9 +1261,12 @@
$sql .= "featuretype_searchable = $1,";
$sql .= "featuretype_srs = $2, ";
$sql .= "featuretype_latlon_bbox = $3, ";
- $sql .= "inspire_download = $4 ";
+ $sql .= "inspire_download = $4, ";
+ $sql .= "featuretype_schema = $6, ";
+ $sql .= "featuretype_schema_problem = $7 ";
$sql .= "WHERE featuretype_id = $5";
+
if (!$updateMetadataOnly) {
//read inspire_download and featuretype_searchable from database if update from capabilities
$aWfsFeatureType->inspire_download = $row["inspire_download"];
@@ -1280,9 +1285,11 @@
$aWfsFeatureType->srs,
$aWfsFeatureType->latLonBboxArray['minx'].','.$aWfsFeatureType->latLonBboxArray['miny'].','.$aWfsFeatureType->latLonBboxArray['maxx'].','.$aWfsFeatureType->latLonBboxArray['maxy'],
$aWfsFeatureType->inspire_download,
- $aWfsFeatureType->id
+ $aWfsFeatureType->id,
+ $aWfsFeatureType->schema,
+ $aWfsFeatureType->schema_problem
);
- $t = array('s','s','s','i','i');
+ $t = array('s','s','s','i','i','s','b');
$e = new mb_notice("class_wfsToDb.php: UPDATING Featuretype (FT: $aWfsFeatureType->id)");
$e = new mb_notice("class_wfsToDb.php: UPDATING Featuretype (FT searchable: $aWfsFeatureType->searchable)");
Modified: trunk/mapbender/http/classes/class_wfs_1_0_factory.php
===================================================================
--- trunk/mapbender/http/classes/class_wfs_1_0_factory.php 2017-02-06 08:40:09 UTC (rev 9677)
+++ trunk/mapbender/http/classes/class_wfs_1_0_factory.php 2017-02-06 08:50:05 UTC (rev 9678)
@@ -72,7 +72,9 @@
// for the sake of simplicity we only care about top level elements. Seems to have worked so far
$query = sprintf("/xs:schema/xs:element[@name='%s']",$ftLocalname);
$elementList = $xpath->query($query);
-
+ //parse single elements - if the schema is complex, store only the DescribeFeaturetype response
+ $newFeatureType->schema_problem = 'f';
+ $newFeatureType->schema = $xml;
foreach ($elementList as $elementNode){
$elementName = $elementNode->getAttribute("name");
$elementType = $elementNode->getAttribute("type");
@@ -115,7 +117,13 @@
</xs:element>*/
$query = "xs:simpleType/xs:restriction";
$restriction = $xpath->query($query,$subElement);
- $type = $restriction->item(0)->getAttribute('base');
+
+ if (gettype($restriction->item(0)) == 'object') {
+ $type = $restriction->item(0)->getAttribute('base');
+ } else {
+ $e = new mb_exception("classes/class_wfs_1_0_factory.php: Problem while parsing schema for featuretype ".$featureTypeName);
+ $newFeatureType->schema_problem = 't';
+ }
//TODO parse further information from xsd like maxLength: <xs:maxLength value="40"/> - add further column in wfs_element!
} else {
switch (count($typeParts)) {
Modified: trunk/mapbender/http/classes/class_wfs_1_1_factory.php
===================================================================
--- trunk/mapbender/http/classes/class_wfs_1_1_factory.php 2017-02-06 08:40:09 UTC (rev 9677)
+++ trunk/mapbender/http/classes/class_wfs_1_1_factory.php 2017-02-06 08:50:05 UTC (rev 9678)
@@ -114,6 +114,9 @@
// for the sake of simplicity we only care about top level elements. Seems to have worked so far
$query = sprintf("/xs:schema/xs:element[@name='%s']",$ftLocalname);
$elementList = $xpath->query($query);
+ //parse single elements - if the schema is complex, store only the DescribeFeaturetype response
+ $newFeatureType->schema_problem = 'f';
+ $newFeatureType->schema = $xml;
foreach ($elementList as $elementNode){
$elementName = $elementNode->getAttribute("name");
$elementType = $elementNode->getAttribute("type");
@@ -156,7 +159,13 @@
</xs:element>*/
$query = "xs:simpleType/xs:restriction";
$restriction = $xpath->query($query,$subElement);
- $type = $restriction->item(0)->getAttribute('base');
+
+ if (gettype($restriction->item(0)) == 'object') {
+ $type = $restriction->item(0)->getAttribute('base');
+ } else {
+ $e = new mb_exception("classes/class_wfs_1_1_factory.php: Problem while parsing schema for featuretype ".$featureTypeName);
+ $newFeatureType->schema_problem = 't';
+ }
//TODO parse further information from xsd like maxLength: <xs:maxLength value="40"/> - add further column in wfs_element!
} else {
switch (count($typeParts)) {
Modified: trunk/mapbender/http/classes/class_wfs_2_0_factory.php
===================================================================
--- trunk/mapbender/http/classes/class_wfs_2_0_factory.php 2017-02-06 08:40:09 UTC (rev 9677)
+++ trunk/mapbender/http/classes/class_wfs_2_0_factory.php 2017-02-06 08:50:05 UTC (rev 9678)
@@ -168,7 +168,9 @@
// for the sake of simplicity we only care about top level elements. Seems to have worked so far
$query = sprintf("/xs:schema/xs:element[@name='%s']",$ftLocalname);
$elementList = $xpath->query($query);
-
+ //parse single elements - if the schema is complex, store only the DescribeFeaturetype response
+ $newFeatureType->schema_problem = 'f';
+ $newFeatureType->schema = $xml;
foreach ($elementList as $elementNode){
$elementName = $elementNode->getAttribute("name");
$elementType = $elementNode->getAttribute("type");
@@ -211,7 +213,12 @@
</xs:element>*/
$query = "xs:simpleType/xs:restriction";
$restriction = $xpath->query($query,$subElement);
- $type = $restriction->item(0)->getAttribute('base');
+ if (gettype($restriction->item(0)) == 'object') {
+ $type = $restriction->item(0)->getAttribute('base');
+ } else {
+ $e = new mb_exception("classes/class_wfs_2_0_factory.php: Problem while parsing schema for featuretype ".$featureTypeName);
+ $newFeatureType->schema_problem = 't';
+ }
//TODO parse further information from xsd like maxLength: <xs:maxLength value="40"/> - add further column in wfs_element!
} else {
switch (count($typeParts)) {
Modified: trunk/mapbender/http/classes/class_wfs_featuretype.php
===================================================================
--- trunk/mapbender/http/classes/class_wfs_featuretype.php 2017-02-06 08:40:09 UTC (rev 9677)
+++ trunk/mapbender/http/classes/class_wfs_featuretype.php 2017-02-06 08:50:05 UTC (rev 9678)
@@ -29,6 +29,8 @@
var $summary;
var $searchable;
var $inspire_download;
+ var $schema; //text
+ var $schema_problem; //boolean
var $srs; // Tag DefaultSRS in wfs 1.1.0+
var $latLonBboxArray = array();
var $crsArray = array(); //new for wfs 1.1.0+ (tag OtherSRS)
More information about the Mapbender_commits
mailing list