[fdo-commits] r718 - branches/3.2.x/Fdo/Unmanaged/Src/Fdo/Xml
svn_fdo at osgeo.org
svn_fdo at osgeo.org
Fri Feb 2 12:09:25 EST 2007
Author: romicadascalescu
Date: 2007-02-02 12:09:25 -0500 (Fri, 02 Feb 2007)
New Revision: 718
Modified:
branches/3.2.x/Fdo/Unmanaged/Src/Fdo/Xml/FeaturePropertyReaderImpl.cpp
branches/3.2.x/Fdo/Unmanaged/Src/Fdo/Xml/FeaturePropertyReaderImpl.h
branches/3.2.x/Fdo/Unmanaged/Src/Fdo/Xml/GeometryHandler.cpp
branches/3.2.x/Fdo/Unmanaged/Src/Fdo/Xml/GeometryHandler.h
branches/3.2.x/Fdo/Unmanaged/Src/Fdo/Xml/LpClassDefinition.cpp
branches/3.2.x/Fdo/Unmanaged/Src/Fdo/Xml/LpClassDefinition.h
Log:
Fixed WFS: Loading WFS layer does not get the geometry
Modified: branches/3.2.x/Fdo/Unmanaged/Src/Fdo/Xml/FeaturePropertyReaderImpl.cpp
===================================================================
--- branches/3.2.x/Fdo/Unmanaged/Src/Fdo/Xml/FeaturePropertyReaderImpl.cpp 2007-02-02 16:05:28 UTC (rev 717)
+++ branches/3.2.x/Fdo/Unmanaged/Src/Fdo/Xml/FeaturePropertyReaderImpl.cpp 2007-02-02 17:09:25 UTC (rev 718)
@@ -234,6 +234,17 @@
break;
}
+ //direct gml geometry association
+ case GmlBaseType_GmlDirectGeometry:
+ m_parsingStateStack.push_back(ParsingState_GmlDirectGeometry);
+
+ m_geometryHandler = FdoXmlGeometryHandler::Create();
+ m_geometryHandler->SetExpectedGmlGeometry((FdoXmlGeometryHandler::GmlGeometryType)m_activeGmlGeometryType);
+ nextSaxHandler = m_geometryHandler->SkipFirstParseStep();
+ if (nextSaxHandler == NULL)
+ nextSaxHandler = m_geometryHandler;
+ break;
+
//gml geometry association
case GmlBaseType_GmlGeometryAssociation:
m_parsingStateStack.push_back(ParsingState_GmlGeometryAssociation);
@@ -395,111 +406,66 @@
case ParsingState_BoundingShape:
//"Bounds" is FDO property for gml:boundedBy
- try
- {
- tempGeometry = m_geometryHandler->GetGeometry();
- if (tempGeometry)
- {
- tempByteArray = tempGeometry->GetFgf();
-
- isPauseParsing = curFeatureHandler->FeatureGeometricProperty(m_featureContext,
- L"Bounds",
- tempByteArray->GetData(),
- tempByteArray->GetCount());
- }
- }
- catch(FdoException* ex)
- {ex->Release();}
- catch(...)
- {}
+ tempGeometry = m_geometryHandler->GetGeometry();
+ if (tempGeometry)
+ {
+ tempByteArray = tempGeometry->GetFgf();
+ if (tempByteArray != NULL)
+ isPauseParsing = curFeatureHandler->FeatureGeometricProperty(m_featureContext,
+ L"Bounds", tempByteArray->GetData(), tempByteArray->GetCount());
+ }
+ FDO_SAFE_RELEASE(tempByteArray);
FDO_SAFE_RELEASE(tempGeometry);
- FDO_SAFE_RELEASE(tempByteArray);
break;
-
- //gml geometry association
+ //geometry association
+ case ParsingState_GmlDirectGeometry:
case ParsingState_GmlGeometryAssociation:
- try
+ case ParsingState_GeometryAssociation:
{
+ if (curState == ParsingState_GmlDirectGeometry) // run last step only in this case
+ m_geometryHandler->RunLastParseStep(name, (FdoXmlGeometryHandler::GmlGeometryType)m_activeGmlGeometryType);
tempGeometry = m_geometryHandler->GetGeometry();
- if (tempGeometry)
+ FdoStringP pPropName = name;
+ bool found = false;
+ FdoXmlLpClassDefinition* classDef = m_lpClassStack.back();
+ if (NULL != classDef)
{
- tempByteArray = tempGeometry->GetFgf();
- FdoStringP pPropName = name;
- bool found = false;
- if (NULL != m_lpClassStack.back())
+ FdoString* pBaseName = classDef->PropertyMappingNameFromGmlAlias(name);
+ if (pBaseName != NULL)
{
- FdoXmlLpClassDefinition* classDef = m_lpClassStack.back();
- FdoString* pBaseName = classDef->PropertyMappingNameFromGmlAlias(name);
- if (pBaseName != NULL)
- {
- pPropName = pBaseName;
- found = true;
- }
+ pPropName = pBaseName;
+ found = true;
}
- if (!found)
- {
- pPropName = L"gml/";
- pPropName += name;
- }
- if (tempByteArray != NULL)
- {
- isPauseParsing = curFeatureHandler->FeatureGeometricProperty(m_featureContext,
- pPropName,
- tempByteArray->GetData(),
- tempByteArray->GetCount());
- } else
- {
- isPauseParsing = curFeatureHandler->FeatureGeometricProperty(m_featureContext,
- pPropName,
- NULL,
- 0);
- }
}
- }
- catch(FdoException* ex)
- {ex->Release();}
- catch(...)
- {}
- FDO_SAFE_RELEASE(tempGeometry);
- FDO_SAFE_RELEASE(tempByteArray);
- break;
-
- //geometry association
- case ParsingState_GeometryAssociation:
- try
- {
- tempGeometry = m_geometryHandler->GetGeometry();
- if (tempGeometry)
+ // only in gml geometry association add in front gml/
+ if (!found && curState == ParsingState_GmlGeometryAssociation)
{
+ pPropName = L"gml/";
+ pPropName += name;
+ }
+ // match the names of geometry field
+ if (NULL != classDef)
+ {
+ FdoString* pMainGeomPropName = classDef->GetMainGeometryPropertyName();
+ // in case we have only one geometry and the names are different
+ if (pMainGeomPropName != NULL && pPropName != pMainGeomPropName)
+ pPropName = pMainGeomPropName;
+ }
+ FdoByte* arrayData = NULL;
+ FdoInt32 szArrayData = 0;
+ if (tempGeometry){
tempByteArray = tempGeometry->GetFgf();
- FdoStringP pPropName = name;
- if (NULL != m_lpClassStack.back())
- {
- FdoXmlLpClassDefinition* classDef = m_lpClassStack.back();
- FdoString* pBaseName = classDef->PropertyMappingNameFromGmlAlias(name);
- if (pBaseName != NULL)
- pPropName = pBaseName;
+ if (tempByteArray != NULL){
+ arrayData = tempByteArray->GetData();
+ szArrayData = tempByteArray->GetCount();
}
- if (tempByteArray != NULL) {
- isPauseParsing = curFeatureHandler->FeatureGeometricProperty(m_featureContext,
- pPropName,
- tempByteArray->GetData(),
- tempByteArray->GetCount());
- } else {
- isPauseParsing = curFeatureHandler->FeatureGeometricProperty(m_featureContext,
- pPropName,
- NULL,
- 0);
- }
}
+ isPauseParsing = curFeatureHandler->FeatureGeometricProperty(m_featureContext,
+ pPropName, arrayData, szArrayData);
}
- catch(FdoException* ex)
- {ex->Release();}
- catch(...)
- {}
+ FDO_SAFE_RELEASE(tempByteArray);
FDO_SAFE_RELEASE(tempGeometry);
- FDO_SAFE_RELEASE(tempByteArray);
break;
//Generic Complex Type
@@ -691,6 +657,54 @@
{
rv = GmlBaseType_GmlGeometryAssociation;
}
+ else if (wcscmp(elementName, L"Point") == 0)
+ {
+ m_activeGmlGeometryType = FdoXmlGeometryHandler::GmlGeometryType_Point;
+ rv = GmlBaseType_GmlDirectGeometry;
+ }
+ else if (wcscmp(elementName, L"Polygon") == 0)
+ {
+ m_activeGmlGeometryType = FdoXmlGeometryHandler::GmlGeometryType_Polygon;
+ rv = GmlBaseType_GmlDirectGeometry;
+ }
+ else if (wcscmp(elementName, L"LineString") == 0)
+ {
+ m_activeGmlGeometryType = FdoXmlGeometryHandler::GmlGeometryType_LineString;
+ rv = GmlBaseType_GmlDirectGeometry;
+ }
+ else if (wcscmp(elementName, L"LinearRing") == 0)
+ {
+ m_activeGmlGeometryType = FdoXmlGeometryHandler::GmlGeometryType_LinearRing;
+ rv = GmlBaseType_GmlDirectGeometry;
+ }
+ else if (wcscmp(elementName, L"MultiPoint") == 0)
+ {
+ m_activeGmlGeometryType = FdoXmlGeometryHandler::GmlGeometryType_MultiPoint;
+ rv = GmlBaseType_GmlDirectGeometry;
+ }
+ else if (wcscmp(elementName, L"MultiLineString") == 0)
+ {
+ m_activeGmlGeometryType = FdoXmlGeometryHandler::GmlGeometryType_MultiLineString;
+ rv = GmlBaseType_GmlDirectGeometry;
+ }
+ else if (wcscmp(elementName, L"MultiPolygon") == 0)
+ {
+ m_activeGmlGeometryType = FdoXmlGeometryHandler::GmlGeometryType_MultiPolygon;
+ rv = GmlBaseType_GmlDirectGeometry;
+ }
+ else if (wcscmp(elementName, L"MultiGeometry") == 0)
+ {
+ m_activeGmlGeometryType = FdoXmlGeometryHandler::GmlGeometryType_MultiGeometry;
+ rv = GmlBaseType_GmlDirectGeometry;
+ }
+ else if (wcscmp(elementName, L"pointMember") == 0 ||
+ wcscmp(elementName, L"lineStringMember") == 0 ||
+ wcscmp(elementName, L"polygonMember") == 0 ||
+ wcscmp(elementName, L"geometryMember") == 0)
+ {
+ m_activeGmlGeometryType = FdoXmlGeometryHandler::GmlGeometryType_GeometryAssociation;
+ rv = GmlBaseType_GmlDirectGeometry;
+ }
}
if (rv != GmlBaseType_Unknown)
break;
Modified: branches/3.2.x/Fdo/Unmanaged/Src/Fdo/Xml/FeaturePropertyReaderImpl.h
===================================================================
--- branches/3.2.x/Fdo/Unmanaged/Src/Fdo/Xml/FeaturePropertyReaderImpl.h 2007-02-02 16:05:28 UTC (rev 717)
+++ branches/3.2.x/Fdo/Unmanaged/Src/Fdo/Xml/FeaturePropertyReaderImpl.h 2007-02-02 17:09:25 UTC (rev 718)
@@ -92,7 +92,8 @@
GmlBaseType_Pending,
GmlBaseType_hexBinary,
GmlBaseType_base64Binary,
- GmlBaseType_GmlGeometryAssociation
+ GmlBaseType_GmlGeometryAssociation,
+ GmlBaseType_GmlDirectGeometry
};
enum ParsingState{
@@ -108,7 +109,8 @@
ParsingState_ElementPending,
ParsingState_hexBinary,
ParsingState_base64Binary,
- ParsingState_GmlGeometryAssociation
+ ParsingState_GmlGeometryAssociation,
+ ParsingState_GmlDirectGeometry
};
Modified: branches/3.2.x/Fdo/Unmanaged/Src/Fdo/Xml/GeometryHandler.cpp
===================================================================
--- branches/3.2.x/Fdo/Unmanaged/Src/Fdo/Xml/GeometryHandler.cpp 2007-02-02 16:05:28 UTC (rev 717)
+++ branches/3.2.x/Fdo/Unmanaged/Src/Fdo/Xml/GeometryHandler.cpp 2007-02-02 17:09:25 UTC (rev 718)
@@ -427,3 +427,130 @@
return geoType;
}
+
+FdoXmlSaxHandler* FdoXmlGeometryHandler::SkipFirstParseStep()
+{
+ FdoXmlSaxHandler* nextHandler = NULL;
+ FdoXmlGeometry* newGeometry = NULL;
+
+ GmlGeometryType curType = m_typeGeomExpected;
+ m_typeGeomExpected = GmlGeometryType_Unknown;
+
+ switch(curType)
+ {
+ //Point
+ case GmlGeometryType_Point:
+
+ m_coordinates = FdoXmlCoordinateGroup::Create();
+ newGeometry = FdoXmlPoint::Create();
+ newGeometry->SetCoordinates(m_coordinates);
+ m_geometryStack.push_back(newGeometry);
+
+ break;
+
+ //LinearRing
+ case GmlGeometryType_LinearRing:
+
+ m_coordinates = FdoXmlCoordinateGroup::Create();
+ newGeometry = FdoXmlLinearRing::Create();
+ newGeometry->SetCoordinates(m_coordinates);
+ m_geometryStack.push_back(newGeometry);
+
+ break;
+
+ //LineString
+ case GmlGeometryType_LineString:
+
+ m_coordinates = FdoXmlCoordinateGroup::Create();
+ newGeometry = FdoXmlLineString::Create();
+ newGeometry->SetCoordinates(m_coordinates);
+ m_geometryStack.push_back(newGeometry);
+
+ break;
+
+
+ //Polygon
+ case GmlGeometryType_Polygon:
+
+ //NOTE: polygon is treated as a collection of Linear rings
+ //the first is the outer boundary
+ //the rest are the inner boundary
+ m_isMultiGeometry = true;
+
+ m_coordinates = FdoXmlCoordinateGroup::Create();
+ newGeometry = FdoXmlPolygon::Create();
+ newGeometry->SetCoordinates(m_coordinates);
+ m_geometryStack.push_back(newGeometry);
+
+ break;
+
+ //MultiPoint
+ case GmlGeometryType_MultiPoint:
+ m_isMultiGeometry = true;
+
+ newGeometry = FdoXmlMultiPoint::Create();
+ m_geometryStack.push_back(newGeometry);
+
+ break;
+
+ //MultiLineString
+ case GmlGeometryType_MultiLineString:
+ m_isMultiGeometry = true;
+
+ newGeometry = FdoXmlMultiLineString::Create();
+ m_geometryStack.push_back(newGeometry);
+
+ break;
+
+ //MultiPolygon
+ case GmlGeometryType_MultiPolygon:
+ m_isMultiGeometry = true;
+
+ newGeometry = FdoXmlMultiPolygon::Create();
+ m_geometryStack.push_back(newGeometry);
+
+ break;
+
+ //MultiGeometry
+ case GmlGeometryType_MultiGeometry:
+ m_isMultiGeometry = true;
+
+ newGeometry = FdoXmlMultiGeometry::Create();
+ m_geometryStack.push_back(newGeometry);
+
+ break;
+
+ //Geometry Association
+ case GmlGeometryType_GeometryAssociation:
+
+ m_nestedHandler = new FdoXmlGeometryHandler();
+ nextHandler = m_nestedHandler;
+ break;
+
+ default:
+ m_parsingStateStack.push_back(ParsingState_Unknown);
+ break;
+ }
+
+ return nextHandler;
+}
+
+void FdoXmlGeometryHandler::RunLastParseStep(FdoString* name, GmlGeometryType typeGeomExpected)
+{
+ FdoXmlGeometry* curGeometry = NULL;
+ FdoPtr<FdoXmlGeometry> nestedGeometry;
+ if (m_nestedHandler != NULL && typeGeomExpected == GmlGeometryType_GeometryAssociation)
+ {
+ if(!m_geometryStack.empty())
+ curGeometry = m_geometryStack.back();
+
+ nestedGeometry = m_nestedHandler->GetGeometry();
+
+ if(m_isMultiGeometry){
+ curGeometry->AddGeometryMember(nestedGeometry);
+ }
+ else{
+ curGeometry->AddGeometricProperty(name, nestedGeometry);
+ }
+ }
+}
Modified: branches/3.2.x/Fdo/Unmanaged/Src/Fdo/Xml/GeometryHandler.h
===================================================================
--- branches/3.2.x/Fdo/Unmanaged/Src/Fdo/Xml/GeometryHandler.h 2007-02-02 16:05:28 UTC (rev 717)
+++ branches/3.2.x/Fdo/Unmanaged/Src/Fdo/Xml/GeometryHandler.h 2007-02-02 17:09:25 UTC (rev 718)
@@ -116,6 +116,8 @@
void SetExpectedGmlGeometry(GmlGeometryType typeGeomExpected){m_typeGeomExpected = typeGeomExpected;};
GmlGeometryType m_typeGeomExpected;
+ FdoXmlSaxHandler* SkipFirstParseStep();
+ void RunLastParseStep(FdoString* name, GmlGeometryType typeGeomExpected);
};
typedef FdoPtr<FdoXmlGeometryHandler> FdoXmlGeometryHandlerP;
Modified: branches/3.2.x/Fdo/Unmanaged/Src/Fdo/Xml/LpClassDefinition.cpp
===================================================================
--- branches/3.2.x/Fdo/Unmanaged/Src/Fdo/Xml/LpClassDefinition.cpp 2007-02-02 16:05:28 UTC (rev 717)
+++ branches/3.2.x/Fdo/Unmanaged/Src/Fdo/Xml/LpClassDefinition.cpp 2007-02-02 17:09:25 UTC (rev 718)
@@ -24,6 +24,7 @@
m_class(classDefinition), m_mapping(classMapping) {
FDO_SAFE_ADDREF(m_class.p);
FDO_SAFE_ADDREF(m_mapping.p);
+ m_mainGeometryPropertyName = NULL;
}
FdoXmlLpClassDefinition::~FdoXmlLpClassDefinition() {
@@ -194,3 +195,29 @@
}
return NULL;
}
+
+FdoString* FdoXmlLpClassDefinition::GetMainGeometryPropertyName()
+{
+ if (m_mainGeometryPropertyName == NULL)
+ {
+ FdoPtr<FdoXmlLpPropertyCollection> props = GetProperties();
+ FdoInt32 count = props->GetCount();
+ for (int i = 0; i < count; i++)
+ {
+ FdoPtr<FdoXmlLpPropertyDefinition> prop = props->GetItem(i);
+ FdoPtr<FdoPropertyDefinition> propDef = prop->GetPropertyDefinition();
+ if (propDef != NULL && FdoPropertyType_GeometricProperty == propDef->GetPropertyType())
+ {
+ if (m_mainGeometryPropertyName == NULL)
+ m_mainGeometryPropertyName = propDef->GetName();
+ else
+ {
+ // if there is more than one geometry prop return NULL
+ m_mainGeometryPropertyName = NULL;
+ break;
+ }
+ }
+ }
+ }
+ return m_mainGeometryPropertyName;
+}
\ No newline at end of file
Modified: branches/3.2.x/Fdo/Unmanaged/Src/Fdo/Xml/LpClassDefinition.h
===================================================================
--- branches/3.2.x/Fdo/Unmanaged/Src/Fdo/Xml/LpClassDefinition.h 2007-02-02 16:05:28 UTC (rev 717)
+++ branches/3.2.x/Fdo/Unmanaged/Src/Fdo/Xml/LpClassDefinition.h 2007-02-02 17:09:25 UTC (rev 718)
@@ -73,6 +73,9 @@
// get a mapping property name using an gml alias name if exist
FdoString* PropertyMappingNameFromGmlAlias(FdoString* gmlName);
+ // get main geometry property name. If there are more than one geometry prop NULL will be returned
+ FdoString* GetMainGeometryPropertyName();
+
protected:
FdoXmlLpClassDefinition();
FdoXmlLpClassDefinition( FdoClassDefinition* classDefinition, FdoXmlClassMapping* classMapping );
@@ -85,6 +88,7 @@
FdoPtr<FdoXmlClassMapping> m_mapping;
FdoPtr<FdoXmlLpClassDefinition> m_baseClass;
FdoPtr<FdoXmlLpPropertyCollection> m_properties;
+ FdoString* m_mainGeometryPropertyName;
// helper
private:
More information about the fdo-commits
mailing list