Ver Fonte

fixed the_geom type linestring for table test_geom_linestring

Piotr Labudda há 9 anos atrás
pai
commit
e283504aa7

+ 10 - 0
SE/schema/gui/core/default_db.test_geom_linestring.php

@@ -0,0 +1,10 @@
+<?php
+
+class Schema__Core__default_db__test_geom_linestring extends Schema_TableBase {
+
+	public function initTypes() {
+		parent::initTypes();
+		$this->_types['the_geom'] = 'gml:LineStringPropertyType';
+	}
+
+}

+ 1 - 0
SE/se-lib/Data_Source.php

@@ -81,6 +81,7 @@ class Data_Source {
 			$fieldType = $h[1];
 			$fieldTypes[$fieldName] = array('type'=>$h[1], 'null'=>('YES' == $h[2]), 'default'=>$h[4]);
 		}
+		DBG::_('DBG_DS', '>4', "types({$tblName})", $fieldTypes, __CLASS__, __FUNCTION__, __LINE__);
 		return $fieldTypes;
 	}
 

+ 26 - 20
SE/se-lib/TableAcl.php

@@ -966,6 +966,7 @@ class TableAcl extends Core_AclBase {
 		uasort($this->_fields, array($this, 'sortFieldsCallback'));
 
 		$this->_fixTypes();
+		DBG::_('DBG_SCH', '>1', "INIT::after fixTypes({$this->_zasobID})", $this->_types, __CLASS__, __FUNCTION__, __LINE__ );
 
 		$this->save();
 	}
@@ -978,6 +979,20 @@ class TableAcl extends Core_AclBase {
 		if ($this->_schemaClass) $this->_types = $this->_schemaClass->fixTypes($this->_types);
 		//DBG::_(true, true, "this->_types", $this->_types, __CLASS__, __FUNCTION__, __LINE__);
 
+		// fixGeomTypesFromSimpleType
+		foreach ($this->_types as $fieldName => $field) {
+			// [the_geom] => Array(
+			//             [type] => geometry
+			//             [null] => 1
+			//             [default] =>
+			//             [simpleType] => linestring
+			if ('geometry' == $field['type'] && !empty($field['simpleType'])) {
+				switch ($field['simpleType']) {
+					case 'gml:LineStringPropertyType': $this->_types[ $fieldName ][ 'type' ] = 'linestring'; break;
+				}
+			}
+		}
+
 		$fieldIds = array_keys($this->_fields);
 		Lib::loadClass('Typespecial');
 		$vColsIdList = Typespecial::initFields($fieldIds);
@@ -1133,28 +1148,19 @@ class TableAcl extends Core_AclBase {
 	}
 
 	public function getFieldTypeById($fieldID) {
-		if (!array_key_exists($fieldID, $this->_fields)) {
-			return null;
-		}
-		$colName = $this->_fields[$fieldID]['name'];
-		if (!array_key_exists($colName, $this->_types)) {
-			return null;
-		}
-		return $this->_types[$colName];
+		if (!array_key_exists($fieldID, $this->_fields)) return null;
+		$fieldName = $this->_fields[$fieldID]['name'];
+		if (!array_key_exists($fieldName, $this->_types)) return null;
+		return $this->_types[$fieldName];
 	}
 
-	public function getFieldType($colName) {
-		if (!array_key_exists($colName, $this->_types)) {
-			return null;
-		}
-		return $this->_types[$colName];
+	public function getFieldType($fieldName) {
+		if (!array_key_exists($fieldName, $this->_types)) return null;
+		return $this->_types[$fieldName];
 	}
 
-	public function hasFieldType($colName) {
-		if (array_key_exists($colName, $this->_types)) {
-			return true;
-		}
-		return false;
+	public function hasFieldType($fieldName) {
+		return (array_key_exists($fieldName, $this->_types));
 	}
 
 	public function getVisibleFieldList() { return $this->getVisibleFieldListByIdZasob(); }
@@ -1386,8 +1392,8 @@ class TableAcl extends Core_AclBase {
 		return $ds->isGeomField($fldName);
 	}
 
-	public function getGeomFieldType($fldName) {
-		$dbGeomType = $this->getFieldType($fldName);
+	public function getGeomFieldType($fieldName) {
+		$dbGeomType = $this->getFieldType($fieldName);
 		$dbGeomType = (!empty($dbGeomType['type']))? $dbGeomType['type'] : '';
 		$geomType = strtolower($dbGeomType);
 		return $geomType;