[fdo-commits] r154 - branches/3.2.x/Providers/WMS/Src/Provider

svn_fdo at osgeo.org svn_fdo at osgeo.org
Thu Mar 22 22:41:25 EDT 2007


Author: gregboone
Date: 2007-03-22 22:41:24 -0400 (Thu, 22 Mar 2007)
New Revision: 154

Modified:
   branches/3.2.x/Providers/WMS/Src/Provider/FdoWmsConnection.cpp
Log:
Ticket #50: WMS: Failure connecting to http://www.premis.cz/atlaszp/isapi.dll

Modified: branches/3.2.x/Providers/WMS/Src/Provider/FdoWmsConnection.cpp
===================================================================
--- branches/3.2.x/Providers/WMS/Src/Provider/FdoWmsConnection.cpp	2007-03-19 21:30:43 UTC (rev 153)
+++ branches/3.2.x/Providers/WMS/Src/Provider/FdoWmsConnection.cpp	2007-03-23 02:41:24 UTC (rev 154)
@@ -56,17 +56,17 @@
 class GDALRegister
 {
 public:
-	// Default constructor registers all drivers to initialize GDAL.
-	GDALRegister ()
-	{
-		GDALAllRegister();
-	}
+    // Default constructor registers all drivers to initialize GDAL.
+    GDALRegister ()
+    {
+        GDALAllRegister();
+    }
 
-	// Destructor to unregister all drivers of GDAL.
-	~GDALRegister ()
-	{
-		GDALDestroyDriverManager();
-	}
+    // Destructor to unregister all drivers of GDAL.
+    ~GDALRegister ()
+    {
+        GDALDestroyDriverManager();
+    }
 };
 
 // The only instance to register GDAL.
@@ -76,7 +76,7 @@
 // external access to connection for client services
 extern "C" FDOWMS_API FdoIConnection* CreateConnection ()
 {
-	return (new FdoWmsConnection ());
+    return (new FdoWmsConnection ());
 }
 
 FdoWmsConnection::FdoWmsConnection (void)
@@ -197,7 +197,7 @@
 /// <returns>Returns the current state of the connection</returns> 
 FdoConnectionState FdoWmsConnection::GetConnectionState ()
 {
-	return mState;
+    return mState;
 }
 
 /// <summary>Gets the number of milliseconds to wait while trying to establish a
@@ -265,7 +265,7 @@
     FdoPtr<FdoWmsCapabilities> capa = static_cast<FdoWmsCapabilities *> (metadata->GetCapabilities ());
     if (capa)
         capa->FillUpGeographicDataLayers();
-	if (mConfigured)
+    if (mConfigured)
     {
         // Some layer names may contain ":" or "." characters which are not allowed
         // in FDO class name, so the layer names will be mangled to replace
@@ -280,13 +280,13 @@
         }
     }
     else
-	{
-		_buildUpDefaultSchemaMappings ();
+    {
+        _buildUpDefaultSchemaMappings ();
         _buildUpDefaultPhysicalSchemaMappings ();
-	}
+    }
 
-	mServer = location;
-	mState = FdoConnectionState_Open;
+    mServer = location;
+    mState = FdoConnectionState_Open;
 
     return mState;
 }
@@ -304,15 +304,15 @@
     mConfigLogicalSchemas = NULL;
     mConfigSchemaMappings = NULL;
     mLayerMappings = NULL;
-	
+    
     // mark the connection as not configured
     mConfigured = false;
 
-	// Clear the cached schemas
-	mSchemas = NULL;
+    // Clear the cached schemas
+    mSchemas = NULL;
 
-	// change the state to FdoConnectionState_Closed
-	mState = FdoConnectionState_Closed;
+    // change the state to FdoConnectionState_Closed
+    mState = FdoConnectionState_Closed;
 }
 
 /// <summary>Begins a transaction and returns an object that realizes
@@ -339,15 +339,15 @@
         case FdoCommandType_DescribeSchema:
             ret = new FdoWmsDescribeSchemaCommand (this);
             break;
-		case FdoCommandType_DescribeSchemaMapping:
-			ret = new FdoWmsDescribeSchemaMappingCommand (this);
-			break;
-		case FdoCommandType_GetSpatialContexts:
-			ret = new FdoWmsGetSpatialContextsCommand (this);
-			break;
-		case FdoCommandType_ActivateSpatialContext:
-			ret = new FdoWmsActivateSpatialContextCommand (this);
-			break;
+        case FdoCommandType_DescribeSchemaMapping:
+            ret = new FdoWmsDescribeSchemaMappingCommand (this);
+            break;
+        case FdoCommandType_GetSpatialContexts:
+            ret = new FdoWmsGetSpatialContextsCommand (this);
+            break;
+        case FdoCommandType_ActivateSpatialContext:
+            ret = new FdoWmsActivateSpatialContextCommand (this);
+            break;
         case FdoCommandType_SelectAggregates:
             ret = new FdoWmsSelectAggregatesCommand(this);
             break;
@@ -364,7 +364,7 @@
 /// <returns>Returns FdoPhysicalSchemaMapping</returns> 
 FdoPhysicalSchemaMapping* FdoWmsConnection::CreateSchemaMapping()
 {
-	return FdoWmsOvPhysicalSchemaMapping::Create();
+    return FdoWmsOvPhysicalSchemaMapping::Create();
 }
 
 /// <summary>Sets the XML configuration stream used to configure the Data Store. 
@@ -386,46 +386,46 @@
     // Read logical FDO schemas from XML stream:
     //////////////////////////////////////////////////////////////////////////
 
-	configStream->Reset();
+    configStream->Reset();
     FdoXmlReaderP reader = FdoXmlReader::Create(configStream);
-	mConfigLogicalSchemas = FdoFeatureSchemaCollection::Create(NULL);
+    mConfigLogicalSchemas = FdoFeatureSchemaCollection::Create(NULL);
 
     try 
     {
-		mConfigLogicalSchemas->ReadXml(reader);
-	} 
+        mConfigLogicalSchemas->ReadXml(reader);
+    } 
     catch (FdoException* e) 
     {
-		FdoSchemaExceptionP schemaException = 
+        FdoSchemaExceptionP schemaException = 
             FdoSchemaException::Create(
                 NlsMsgGet(FDOWMS_SCHEMA_FAIL_READ_FEATURE_SCHEMAS, "Failed to de-serialize the feature schemas from the configuration."),
                 e);
         e->Release();
         throw schemaException;
-	}
+    }
 
 
     //////////////////////////////////////////////////////////////////////////
     // Read FDO schema mappings from XML stream:
     //////////////////////////////////////////////////////////////////////////
 
-	configStream->Reset();
-	reader = FdoXmlReader::Create(configStream);
+    configStream->Reset();
+    reader = FdoXmlReader::Create(configStream);
     FdoSchemaMappingsP localSchemaMappings = FdoPhysicalSchemaMappingCollection::Create();
-	
+    
     try 
     {
-		localSchemaMappings->ReadXml(reader);
-	} 
+        localSchemaMappings->ReadXml(reader);
+    } 
     catch (FdoException* e) 
     {
-		FdoSchemaExceptionP schemaException = 
+        FdoSchemaExceptionP schemaException = 
             FdoSchemaException::Create(
                 NlsMsgGet(FDOWMS_SCHEMA_FAIL_READ_SCHEMA_MAPPINGS, "Failed to de-serialize the schema mappings from the configuration."),
                 e);
         e->Release();
         throw schemaException;
-	}
+    }
 
     mConfigSchemaMappings = FdoPhysicalSchemaMappingCollection::Create();
     for (FdoInt32 i=0; i<localSchemaMappings->GetCount(); i++) {
@@ -436,80 +436,80 @@
         }
     }
 
-	// verify that each logical shema/class has its associated physical schema/class mapping
-	for (FdoInt32 i=0; i<mConfigLogicalSchemas->GetCount(); i++)
-	{
-		FdoPtr<FdoFeatureSchema> logicalSchema = mConfigLogicalSchemas->GetItem (i);
-		FdoString* schemaName = logicalSchema->GetName ();
-		FdoPtr<FdoPhysicalSchemaMapping> schemaMapping = mConfigSchemaMappings->GetItem (this, schemaName);
-		if (schemaMapping == NULL)
-			throw FdoSchemaException::Create (NlsMsgGet (FDOWMS_SCHEMA_MAPPING_NOT_FOUND, "Physical schema mapping '%1$ls' was not found.", schemaName));
+    // verify that each logical shema/class has its associated physical schema/class mapping
+    for (FdoInt32 i=0; i<mConfigLogicalSchemas->GetCount(); i++)
+    {
+        FdoPtr<FdoFeatureSchema> logicalSchema = mConfigLogicalSchemas->GetItem (i);
+        FdoString* schemaName = logicalSchema->GetName ();
+        FdoPtr<FdoPhysicalSchemaMapping> schemaMapping = mConfigSchemaMappings->GetItem (this, schemaName);
+        if (schemaMapping == NULL)
+            throw FdoSchemaException::Create (NlsMsgGet (FDOWMS_SCHEMA_MAPPING_NOT_FOUND, "Physical schema mapping '%1$ls' was not found.", schemaName));
 
-		FdoWmsOvPhysicalSchemaMapping* wmsSchemaMapping = static_cast<FdoWmsOvPhysicalSchemaMapping *> (schemaMapping.p);
-		FdoWmsOvClassesP physicalClasses = wmsSchemaMapping->GetClasses ();
+        FdoWmsOvPhysicalSchemaMapping* wmsSchemaMapping = static_cast<FdoWmsOvPhysicalSchemaMapping *> (schemaMapping.p);
+        FdoWmsOvClassesP physicalClasses = wmsSchemaMapping->GetClasses ();
 
-		FdoPtr<FdoClassCollection> logicalClasses = logicalSchema->GetClasses ();
-		for (FdoInt32 j=0; j<logicalClasses->GetCount(); j++)
-		{
-			FdoPtr<FdoClassDefinition> logicalClass = logicalClasses->GetItem (j);
-			FdoString* className = logicalClass->GetName ();
-			FdoWmsOvClassDefinitionP physicalClass = physicalClasses->FindItem (className);
-			if (physicalClass == NULL)
-				throw FdoSchemaException::Create (NlsMsgGet (FDOWMS_PHYSICAL_CLASS_NOT_FOUND, "Physical class definition '%1$ls' was not found.", className));
-		}
-	}
+        FdoPtr<FdoClassCollection> logicalClasses = logicalSchema->GetClasses ();
+        for (FdoInt32 j=0; j<logicalClasses->GetCount(); j++)
+        {
+            FdoPtr<FdoClassDefinition> logicalClass = logicalClasses->GetItem (j);
+            FdoString* className = logicalClass->GetName ();
+            FdoWmsOvClassDefinitionP physicalClass = physicalClasses->FindItem (className);
+            if (physicalClass == NULL)
+                throw FdoSchemaException::Create (NlsMsgGet (FDOWMS_PHYSICAL_CLASS_NOT_FOUND, "Physical class definition '%1$ls' was not found.", className));
+        }
+    }
 
-	// verify that each physical schema/class has its associated logical schema/class
-	for (FdoInt32 i=0; i<mConfigSchemaMappings->GetCount(); i++)
-	{
-		FdoPtr<FdoPhysicalSchemaMapping> schemaMapping = mConfigSchemaMappings->GetItem (i);
-		FdoWmsOvPhysicalSchemaMapping* physicalSchema = static_cast<FdoWmsOvPhysicalSchemaMapping *> (schemaMapping.p);
-		FdoString* schemaName = physicalSchema->GetName ();
-		FdoPtr<FdoFeatureSchema> logicalSchema = mConfigLogicalSchemas->FindItem (schemaName);
-		if (logicalSchema == NULL)
-			throw FdoSchemaException::Create (NlsMsgGet (FDOWMS_LOGICAL_SCHEMA_NOT_FOUND, "Physical schema mapping '%1$ls' has no associated logical schema.", schemaName));
+    // verify that each physical schema/class has its associated logical schema/class
+    for (FdoInt32 i=0; i<mConfigSchemaMappings->GetCount(); i++)
+    {
+        FdoPtr<FdoPhysicalSchemaMapping> schemaMapping = mConfigSchemaMappings->GetItem (i);
+        FdoWmsOvPhysicalSchemaMapping* physicalSchema = static_cast<FdoWmsOvPhysicalSchemaMapping *> (schemaMapping.p);
+        FdoString* schemaName = physicalSchema->GetName ();
+        FdoPtr<FdoFeatureSchema> logicalSchema = mConfigLogicalSchemas->FindItem (schemaName);
+        if (logicalSchema == NULL)
+            throw FdoSchemaException::Create (NlsMsgGet (FDOWMS_LOGICAL_SCHEMA_NOT_FOUND, "Physical schema mapping '%1$ls' has no associated logical schema.", schemaName));
 
-		FdoPtr<FdoClassCollection> logicalClasses = logicalSchema->GetClasses ();
-		FdoWmsOvClassesP physicalClasses = physicalSchema->GetClasses ();
-		for (FdoInt32 j=0; j<physicalClasses->GetCount(); j++)
-		{
-			FdoWmsOvClassDefinitionP physicalClass = physicalClasses->GetItem (j);
-			FdoString* className = physicalClass->GetName ();
-			FdoPtr<FdoClassDefinition> logicalClass = logicalClasses->FindItem (className);
-			if (logicalClass == NULL)
-				throw FdoSchemaException::Create (NlsMsgGet (FDOWMS_LOGICAL_CLASS_NOT_FOUND, "Physical class '%1$ls' has no associated logical class definition.", className));
-		}
-	}
+        FdoPtr<FdoClassCollection> logicalClasses = logicalSchema->GetClasses ();
+        FdoWmsOvClassesP physicalClasses = physicalSchema->GetClasses ();
+        for (FdoInt32 j=0; j<physicalClasses->GetCount(); j++)
+        {
+            FdoWmsOvClassDefinitionP physicalClass = physicalClasses->GetItem (j);
+            FdoString* className = physicalClass->GetName ();
+            FdoPtr<FdoClassDefinition> logicalClass = logicalClasses->FindItem (className);
+            if (logicalClass == NULL)
+                throw FdoSchemaException::Create (NlsMsgGet (FDOWMS_LOGICAL_CLASS_NOT_FOUND, "Physical class '%1$ls' has no associated logical class definition.", className));
+        }
+    }
 
-	// Set spatial context association for raster properties
-	for (FdoInt32 i=0; i<mConfigLogicalSchemas->GetCount (); i++)
-	{
-		FdoFeatureSchemaP featSchema = mConfigLogicalSchemas->GetItem (i);
-		FdoWmsOvPhysicalSchemaMappingP schemaMapping = static_cast<FdoWmsOvPhysicalSchemaMapping *> (mConfigSchemaMappings->GetItem (this, featSchema->GetName ()));
-		FdoPtr<FdoClassCollection> featClasses = featSchema->GetClasses ();
-		FdoPtr<FdoWmsOvClassCollection> classMappings = schemaMapping->GetClasses ();
-		for (FdoInt32 j=0; j<featClasses->GetCount(); j++)
-		{
-			FdoPtr<FdoClassDefinition> featClass = featClasses->GetItem (j);
-			FdoPtr<FdoWmsOvClassDefinition> classMapping = classMappings->GetItem (featClass->GetName ());
-			FdoPtr<FdoWmsOvRasterDefinition> rasterDefinition = classMapping->GetRasterDefinition ();
-			FdoString* spatialContext = rasterDefinition->GetSpatialContextName ();
-			VALIDATE_ARGUMENT (spatialContext);
+    // Set spatial context association for raster properties
+    for (FdoInt32 i=0; i<mConfigLogicalSchemas->GetCount (); i++)
+    {
+        FdoFeatureSchemaP featSchema = mConfigLogicalSchemas->GetItem (i);
+        FdoWmsOvPhysicalSchemaMappingP schemaMapping = static_cast<FdoWmsOvPhysicalSchemaMapping *> (mConfigSchemaMappings->GetItem (this, featSchema->GetName ()));
+        FdoPtr<FdoClassCollection> featClasses = featSchema->GetClasses ();
+        FdoPtr<FdoWmsOvClassCollection> classMappings = schemaMapping->GetClasses ();
+        for (FdoInt32 j=0; j<featClasses->GetCount(); j++)
+        {
+            FdoPtr<FdoClassDefinition> featClass = featClasses->GetItem (j);
+            FdoPtr<FdoWmsOvClassDefinition> classMapping = classMappings->GetItem (featClass->GetName ());
+            FdoPtr<FdoWmsOvRasterDefinition> rasterDefinition = classMapping->GetRasterDefinition ();
+            FdoString* spatialContext = rasterDefinition->GetSpatialContextName ();
+            VALIDATE_ARGUMENT (spatialContext);
 
-			// Get the raster property of the class
-			FdoPtr<FdoPropertyDefinitionCollection> props = featClass->GetProperties ();
-			FdoString* rasterPropName = rasterDefinition->GetName ();
-			FdoPtr<FdoPropertyDefinition> prop = props->FindItem (rasterPropName);
-			if (prop == NULL)
-				throw FdoSchemaException::Create (NlsMsgGet (FDOWMS_PHYSICAL_RASTER_PROPERTY_NOT_FOUND, "Logical raster property '%1$ls' was not mapped to a physical property.", rasterPropName));
+            // Get the raster property of the class
+            FdoPtr<FdoPropertyDefinitionCollection> props = featClass->GetProperties ();
+            FdoString* rasterPropName = rasterDefinition->GetName ();
+            FdoPtr<FdoPropertyDefinition> prop = props->FindItem (rasterPropName);
+            if (prop == NULL)
+                throw FdoSchemaException::Create (NlsMsgGet (FDOWMS_PHYSICAL_RASTER_PROPERTY_NOT_FOUND, "Logical raster property '%1$ls' was not mapped to a physical property.", rasterPropName));
 
-			if (prop->GetPropertyType () != FdoPropertyType_RasterProperty)
-				throw FdoSchemaException::Create (NlsMsgGet (FDOWMS_PROPERTY_NOT_RASTER_PROPERTY, "Property '%1ls' is not a raster property.", rasterPropName));
+            if (prop->GetPropertyType () != FdoPropertyType_RasterProperty)
+                throw FdoSchemaException::Create (NlsMsgGet (FDOWMS_PROPERTY_NOT_RASTER_PROPERTY, "Property '%1ls' is not a raster property.", rasterPropName));
 
-			FdoRasterPropertyDefinition* rasterProp = static_cast<FdoRasterPropertyDefinition *> (prop.p);
-			rasterProp->SetSpatialContextAssociation (spatialContext);			
-		}
-	}
+            FdoRasterPropertyDefinition* rasterProp = static_cast<FdoRasterPropertyDefinition *> (prop.p);
+            rasterProp->SetSpatialContextAssociation (spatialContext);            
+        }
+    }
 
     mConfigured = true;
 }
@@ -539,7 +539,7 @@
 /// <returns>Returns nothing.</returns>
 void FdoWmsConnection::SetActiveSpatialContext (FdoString* value)
 {
-	mActiveSpatialContext = value;
+    mActiveSpatialContext = value;
     mActiveSpatialContext = mActiveSpatialContext.Upper();
 }
 
@@ -547,17 +547,17 @@
 /// <returns>Returns the name of the active spatial context.</returns>
 FdoString* FdoWmsConnection::GetActiveSpatialContext ()
 {
-	return mActiveSpatialContext;
+    return mActiveSpatialContext;
 }
 
 /// <summary>Get the feature schemas of the connection.</summary>
 /// <returns>Returns the feature shcema collection.</returns>
 FdoFeatureSchemaCollection* FdoWmsConnection::GetSchemas ()
 {
-	if (mConfigured)
-		return FDO_SAFE_ADDREF (mConfigLogicalSchemas.p);
-	else
-		return FDO_SAFE_ADDREF (mSchemas.p);
+    if (mConfigured)
+        return FDO_SAFE_ADDREF (mConfigLogicalSchemas.p);
+    else
+        return FDO_SAFE_ADDREF (mSchemas.p);
 }
 
 /// <summary>Gets the physical schema mappings.</summary>
@@ -592,7 +592,7 @@
                 configClassDefn->SetName(featureClassDefn->GetName());
 
                 FdoWmsOvRasterDefinitionP configRasterDefn = FdoWmsOvRasterDefinition::Create();
-        	    FdoRasterPropertyP featureRasterDefn = FindRasterProperty(featureClassDefn);
+                FdoRasterPropertyP featureRasterDefn = FindRasterProperty(featureClassDefn);
 
                 configRasterDefn->SetName(featureRasterDefn->GetName());
                 configRasterDefn->SetFormatType(GetImageFormatType(GetDefaultImageFormat())); 
@@ -604,8 +604,8 @@
                 FdoWmsOvLayersP configLayersCollection = configRasterDefn->GetLayers();
                 FdoWmsOvLayerDefinitionP configLayerDefn = FdoWmsOvLayerDefinition::Create();
 
-	            FdoPtr<FdoDictionaryElement> nameElement = mLayerMappings->GetItem (configClassDefn->GetName());
-	            FdoString* layerName = nameElement->GetValue ();
+                FdoPtr<FdoDictionaryElement> nameElement = mLayerMappings->GetItem (configClassDefn->GetName());
+                FdoString* layerName = nameElement->GetValue ();
                 configLayerDefn->SetName(layerName);
 
                 configLayerDefn->SetStyle(NULL);
@@ -623,28 +623,28 @@
 /// <summary>Get the default image format. The prefered image format can be specified in configuration XML file</summary>
 FdoString* FdoWmsConnection::GetImageFormat (FdoWmsOvFormatType formatType)
 {
-	switch (formatType)
-	{
-	case FdoWmsOvFormatType_Tif:
-		return FdoWmsGlobals::RasterMIMEFormat_TIFF;
-	case FdoWmsOvFormatType_Jpg:
-		return FdoWmsGlobals::RasterMIMEFormat_JPEG;
-	case FdoWmsOvFormatType_Gif:
-		return FdoWmsGlobals::RasterMIMEFormat_GIF;	
-	case FdoWmsOvFormatType_Png:
+    switch (formatType)
+    {
+    case FdoWmsOvFormatType_Tif:
+        return FdoWmsGlobals::RasterMIMEFormat_TIFF;
+    case FdoWmsOvFormatType_Jpg:
+        return FdoWmsGlobals::RasterMIMEFormat_JPEG;
+    case FdoWmsOvFormatType_Gif:
+        return FdoWmsGlobals::RasterMIMEFormat_GIF;    
+    case FdoWmsOvFormatType_Png:
     default:
-		return FdoWmsGlobals::RasterMIMEFormat_PNG;
-	}
+        return FdoWmsGlobals::RasterMIMEFormat_PNG;
+    }
 }
 
 /// <summary>Get the default image format type that is used in the FDO WMS Configuration file. </summary>
 FdoWmsOvFormatType FdoWmsConnection::GetImageFormatType (FdoString* imageFormat)
 {
-	if (imageFormat == FdoWmsGlobals::RasterMIMEFormat_TIFF)
+    if (imageFormat == FdoWmsGlobals::RasterMIMEFormat_TIFF)
         return FdoWmsOvFormatType_Tif;
-	else if (imageFormat == FdoWmsGlobals::RasterMIMEFormat_JPEG)
+    else if (imageFormat == FdoWmsGlobals::RasterMIMEFormat_JPEG)
         return FdoWmsOvFormatType_Jpg;
-	else if (imageFormat == FdoWmsGlobals::RasterMIMEFormat_GIF)
+    else if (imageFormat == FdoWmsGlobals::RasterMIMEFormat_GIF)
         return FdoWmsOvFormatType_Gif;
     else
         return FdoWmsOvFormatType_Png;
@@ -654,10 +654,10 @@
 /// will be determined in the following order if the server supports: PNG, JPEG, TIFF and GIF. </summary>
 FdoString* FdoWmsConnection::GetDefaultImageFormat()
 {
-	FdoString* imageFormat = FdoWmsGlobals::RasterMIMEFormat_PNG;
+    FdoString* imageFormat = FdoWmsGlobals::RasterMIMEFormat_PNG;
 
-	FdoWmsServiceMetadataP metadata = GetWmsServiceMetadata ();
-	FdoPtr<FdoWmsCapabilities> capa = static_cast<FdoWmsCapabilities *> (metadata->GetCapabilities ());
+    FdoWmsServiceMetadataP metadata = GetWmsServiceMetadata ();
+    FdoPtr<FdoWmsCapabilities> capa = static_cast<FdoWmsCapabilities *> (metadata->GetCapabilities ());
     FdoPtr<FdoOwsRequestMetadataCollection> reqMetadatas = capa->GetRequestMetadatas ();
 
     FdoPtr<FdoOwsRequestMetadata> reqMetadata = reqMetadatas->FindItem (FdoWmsXmlGlobals::WmsGetMapRequest);
@@ -665,174 +665,161 @@
         reqMetadata = reqMetadatas->FindItem (FdoWmsXmlGlobals::WmsGetMapRequest2);
     }
     if (reqMetadata == NULL) {
-		throw FdoCommandException::Create (NlsMsgGet (FDOWMS_12005_GETMAP_NOT_SUPPORTED, "The WMS GetMap request is not supported."));
+        throw FdoCommandException::Create (NlsMsgGet (FDOWMS_12005_GETMAP_NOT_SUPPORTED, "The WMS GetMap request is not supported."));
     }
 
     FdoWmsRequestMetadata* getMapMetadata = static_cast<FdoWmsRequestMetadata*>(reqMetadata.p);
     FdoStringsP imageFormats = getMapMetadata->GetFormats ();
 
-	// Find the most suitable image format which the server supports. If the user doesn't use
-	// configuration file, the image format will be determined as following:
-	//	"PNG" is prefered is it's supported; Otherwise "TIFF"; Otherwise "JPEG"; Otherwise "GIF"	    
+    // Find the most suitable image format which the server supports. If the user doesn't use
+    // configuration file, the image format will be determined as following:
+    //    "PNG" is prefered is it's supported; Otherwise "TIFF"; Otherwise "JPEG"; Otherwise "GIF"        
 
-	if (imageFormats->IndexOf (FdoWmsGlobals::RasterMIMEFormat_PNG) != -1)
-		imageFormat = FdoWmsGlobals::RasterMIMEFormat_PNG;
-	else if (imageFormats->IndexOf (FdoWmsGlobals::RasterMIMEFormat_TIFF) != -1)
-		imageFormat = FdoWmsGlobals::RasterMIMEFormat_TIFF;
-	else if (imageFormats->IndexOf (FdoWmsGlobals::RasterMIMEFormat_JPEG) != -1)
-		imageFormat = FdoWmsGlobals::RasterMIMEFormat_JPEG;
-	else if (imageFormats->IndexOf (FdoWmsGlobals::RasterMIMEFormat_GIF) != -1)
-		imageFormat = FdoWmsGlobals::RasterMIMEFormat_GIF;
+    if (imageFormats->IndexOf (FdoWmsGlobals::RasterMIMEFormat_PNG) != -1)
+        imageFormat = FdoWmsGlobals::RasterMIMEFormat_PNG;
+    else if (imageFormats->IndexOf (FdoWmsGlobals::RasterMIMEFormat_TIFF) != -1)
+        imageFormat = FdoWmsGlobals::RasterMIMEFormat_TIFF;
+    else if (imageFormats->IndexOf (FdoWmsGlobals::RasterMIMEFormat_JPEG) != -1)
+        imageFormat = FdoWmsGlobals::RasterMIMEFormat_JPEG;
+    else if (imageFormats->IndexOf (FdoWmsGlobals::RasterMIMEFormat_GIF) != -1)
+        imageFormat = FdoWmsGlobals::RasterMIMEFormat_GIF;
 
-	return imageFormat;
+    return imageFormat;
 }
 
 // build up the feature schemas
 void FdoWmsConnection::_buildUpDefaultSchemaMappings ()
 {
     //
-	// This method builds up the default WMS schema that is used when no WMS configuration file is present.
+    // This method builds up the default WMS schema that is used when no WMS configuration file is present.
     //
-	if (!mSchemas)
-	{
-		FdoPtr<FdoWmsCapabilities> capa = static_cast<FdoWmsCapabilities *>(mWmsServiceMetadata->GetCapabilities ());
-		mSchemas = FdoFeatureSchemaCollection::Create (NULL);
+    if (!mSchemas)
+    {
+        FdoPtr<FdoWmsCapabilities> capa = static_cast<FdoWmsCapabilities *>(mWmsServiceMetadata->GetCapabilities ());
+        mSchemas = FdoFeatureSchemaCollection::Create (NULL);
 
         //
-		// For Default Schemas the Schema name is WMS_Schema
+        // For Default Schemas the Schema name is WMS_Schema
         //
-		FdoPtr<FdoFeatureSchema> schema = FdoFeatureSchema::Create (FdoWmsGlobals::DefaultSchemaName, FdoWmsGlobals::DefaultSchemaDescription);
+        FdoPtr<FdoFeatureSchema> schema = FdoFeatureSchema::Create (FdoWmsGlobals::DefaultSchemaName, FdoWmsGlobals::DefaultSchemaDescription);
 
         //
-		// Add the newly created schema to the schema collection
+        // Add the newly created schema to the schema collection
         //
         mSchemas->Add (schema);
         FdoPtr<FdoClassCollection> featClasses = schema->GetClasses ();
 
         //
-		// Retrieve the WMS layer definitons retrieved from the WMS capabilities document.
-		// Recursively create feature class(es) from the WMS layer and it's children and add the class(es) to the class collection.
+        // Retrieve the WMS layer definitons retrieved from the WMS capabilities document.
+        // Recursively create feature class(es) from the WMS layer and it's children and add the class(es) to the class collection.
         //
         FdoWmsLayerCollectionP layers = capa->GetLayers();
         for (int k = 0; k < layers->GetCount(); k++) {
-		    FdoPtr<FdoWmsLayer> layer = layers->GetItem (k);
-		    _addFeatureClass (featClasses, layer, NULL);
+            FdoPtr<FdoWmsLayer> layer = layers->GetItem (k);
+            _addFeatureClass (featClasses, layer, NULL);
         }
 
         //
         // Accept the changes made to the schema
         //
         schema->AcceptChanges();
-	}
+    }
 }
 
 // helper function to create a feature class from a WMS layer and add the class into the collection
 void FdoWmsConnection::_addFeatureClass (FdoClassCollection* featClasses, FdoWmsLayer* layer, FdoClassDefinition* parent)
 {
-	FdoBoolean bAbstract = false;
+    FdoBoolean bAbstract = false;
 
-    //
     // If the layer name is empty this means the WMS layer is abstract and cannot be
     // queried from. Use the layer Title and the class name
-    //
     FdoStringP layerName = layer->GetName ();
-	if (layerName.GetLength() == 0) {
-		bAbstract = true;
-		layerName = layer->GetTitle ();
-        if (layerName.GetLength() == 0) {
-            throw FdoSchemaException::Create(NlsMsgGet(FDOWMS_SCHEMA_LAYER_NO_TITLE, "A WMS layer has no name or title."));
-        }
-	}
+    if (layerName.GetLength() == 0) {
+        bAbstract = true;
+        layerName = layer->GetTitle ();
+    }
 
-    //
     // If these characters are in the layer name, adding the class to the schema will fail
     // FOR NOW... Remove these characters and substitute with empty spaces 
-    //
     FdoStringP tmpLayerName = layerName.Replace( L".", L" " );
     FdoStringP modLayerName = tmpLayerName.Replace( L":", L" " );
 
-	if (!featClasses->FindItem (modLayerName))
-	{
-        //
-        // Map the modofoed FDO class name to the WMS layer name so that the layer name can be used 
-        // in the FdoISelect command to return 
-        //
-        FdoDictionaryElementP dictElement = FdoDictionaryElement::Create(modLayerName, layerName);
-        mLayerMappings->Add(dictElement);
+    // If the layer name is valid, we can try and add the layer
+    FdoClassDefinition* classDef = NULL;
+    if (layerName.GetLength() != 0) 
+    {
+        // If the FDO Feature class exists, we cannot add it
+        classDef = featClasses->FindItem (modLayerName);
+        if (NULL == classDef)
+        {
+            // Map the modofoed FDO class name to the WMS layer name so that the layer name can be used 
+            // in the FdoISelect command to return 
+            FdoDictionaryElementP dictElement = FdoDictionaryElement::Create(modLayerName, layerName);
+            mLayerMappings->Add(dictElement);
 
-        //
-        // Create the FDO Feature class and set it's properties
-        //
-		FdoPtr<FdoFeatureClass> featClass = FdoFeatureClass::Create ();		
+            // Create the FDO Feature class and set it's properties
+            FdoPtr<FdoFeatureClass> featClass = FdoFeatureClass::Create ();        
 
-        // Set the unique layer name
-        featClass->SetName (modLayerName);
+            // Set the unique layer name
+            featClass->SetName (modLayerName);
 
-        // Set the layer title
-        FdoString* title = layer->GetTitle ();
-        if (FdoCommonStringUtil::StringCompare(title, L"") != 0) {
-            featClass->SetDescription (title);
-        }
-        else {
-            featClass->SetDescription (layer->GetAbstract ());
-        }
+            // Set the layer description
+            FdoString* title = layer->GetTitle ();
+            if (FdoCommonStringUtil::StringCompare(title, L"") != 0) {
+                featClass->SetDescription (title);
+            }
+            else {
+                featClass->SetDescription (layer->GetAbstract ());
+            }
 
-        // Flag the class as Abstract
-		if (bAbstract)
-		{
-			featClass->SetIsAbstract (true);
-		}
+            // Flag the class as Abstract
+            if (bAbstract)
+            {
+                featClass->SetIsAbstract (true);
+            }
 
-        //
-        // Used the parent FdoClassDefinition passed to this method as the parent class
-        //
-		featClass->SetBaseClass (parent);
+            // Used the parent FdoClassDefinition passed to this method as the parent class
+            featClass->SetBaseClass (parent);
 
-        //
-        // If this is a top level class, add the FeatId and Raster properties to the class definition
-        //
-		if (parent == NULL)
-		{
-			_setProperties (featClass);
-		}
-		else
-		{
-			_setBaseProperties (featClass, parent);
-		}
+            // If this is a top level class, add the FeatId and Raster properties to the class definition
+            if (parent == NULL)
+            {
+                _setProperties (featClass);
+            }
+            else
+            {
+                _setBaseProperties (featClass, parent);
+            }
 
-        //
-        // Create ans set the Feature classes capabilities
-        //
-        FdoClassCapabilitiesP classCapabilities = FdoClassCapabilities::Create(*featClass.p);
-        classCapabilities->SetSupportsLocking(false);
-        classCapabilities->SetSupportsLongTransactions(false);
-        classCapabilities->SetSupportsWrite(false);
-        featClass->SetCapabilities(classCapabilities);
+            // Create ans set the Feature classes capabilities
+            FdoClassCapabilitiesP classCapabilities = FdoClassCapabilities::Create(*featClass.p);
+            classCapabilities->SetSupportsLocking(false);
+            classCapabilities->SetSupportsLongTransactions(false);
+            classCapabilities->SetSupportsWrite(false);
+            featClass->SetCapabilities(classCapabilities);
 
-		//
-		// Associate the spatial context with the feature class' raster property
-		//
-		_setDefaultSpatialContextAssociation (featClass);
-		
-        //
-        // Add the newly defined feature class to the schema
-        //
-		featClasses->Add (featClass);
+            // Associate the spatial context with the feature class' raster property
+            _setDefaultSpatialContextAssociation (featClass);
+            
+            // Add the newly defined feature class to the schema
+            featClasses->Add (featClass);
 
-        //
-        // Recursively iterate through the child layers, adding feature classes for each child layer
-        //
-		FdoWmsLayerCollectionP childLayers = layer->GetLayers ();
-		if (childLayers)
-		{
-			FdoInt32 cntChildLayers = childLayers->GetCount ();
-			for (FdoInt32 i=0; i<cntChildLayers; i++)
-			{
-				FdoWmsLayerP childLayer = childLayers->GetItem (i);
-				_addFeatureClass (featClasses, childLayer, featClass);
-			}
-		}
-	}
+            // Set the outer class definition object
+            classDef = featClass.p;
+        }
+    }
+
+    // Recursively iterate through the child layers, adding feature classes for each child layer
+    FdoWmsLayerCollectionP childLayers = layer->GetLayers ();
+    if (NULL != childLayers)
+    {
+        FdoInt32 cntChildLayers = childLayers->GetCount ();
+        for (FdoInt32 i=0; i<cntChildLayers; i++)
+        {
+            FdoWmsLayerP childLayer = childLayers->GetItem (i);
+            _addFeatureClass (featClasses, childLayer, classDef != NULL ? classDef : parent);
+        }
+    }
 }
 
 // add properties "FeatId" and "Raster" to the class. Since "FeatId"
@@ -841,46 +828,46 @@
 // as "FeatId", so it will be added to m_baseProperties as well.
 void FdoWmsConnection::_setProperties (FdoFeatureClass* featClass)
 {
-	FdoPtr<FdoPropertyDefinitionCollection> props = featClass->GetProperties ();
-	FdoPtr<FdoDataPropertyDefinitionCollection> idProps = featClass->GetIdentityProperties ();
+    FdoPtr<FdoPropertyDefinitionCollection> props = featClass->GetProperties ();
+    FdoPtr<FdoDataPropertyDefinitionCollection> idProps = featClass->GetIdentityProperties ();
 
-	FdoPtr<FdoDataPropertyDefinition> propFeatId = FdoDataPropertyDefinition::Create (FdoWmsGlobals::PropertyFeatId, FdoWmsGlobals::PropertyFeatIdDescription);
-	FdoPtr<FdoRasterPropertyDefinition> propRaster = FdoRasterPropertyDefinition::Create (FdoWmsGlobals::PropertyRaster, FdoWmsGlobals::PropertyRasterDescription);
+    FdoPtr<FdoDataPropertyDefinition> propFeatId = FdoDataPropertyDefinition::Create (FdoWmsGlobals::PropertyFeatId, FdoWmsGlobals::PropertyFeatIdDescription);
+    FdoPtr<FdoRasterPropertyDefinition> propRaster = FdoRasterPropertyDefinition::Create (FdoWmsGlobals::PropertyRaster, FdoWmsGlobals::PropertyRasterDescription);
 
-	FdoPtr<FdoRasterDataModel> dataModel = FdoRasterDataModel::Create ();
-	propRaster->SetDefaultDataModel (dataModel);
+    FdoPtr<FdoRasterDataModel> dataModel = FdoRasterDataModel::Create ();
+    propRaster->SetDefaultDataModel (dataModel);
 
-	props->Add (propFeatId);
-	props->Add (propRaster);
+    props->Add (propFeatId);
+    props->Add (propRaster);
 
-	idProps->Add (propFeatId);	
+    idProps->Add (propFeatId);    
 }
 
 // add base properties to the feature class explicitly.
 void FdoWmsConnection::_setBaseProperties (FdoFeatureClass* featClass, FdoClassDefinition* parent)
 {
-	if (parent == NULL)
-		throw FdoException::Create (FdoException::NLSGetMessage(FDO_NLSID(FDOWMS_COPY_BASE_PROPERTIES_PARENT),
+    if (parent == NULL)
+        throw FdoException::Create (FdoException::NLSGetMessage(FDO_NLSID(FDOWMS_COPY_BASE_PROPERTIES_PARENT),
                                                                 L"FdoWmsConnection::_setBaseProperties"));
 
-	FdoPtr<FdoPropertyDefinitionCollection> parentProps = parent->GetProperties ();
-	if (parentProps->GetCount () > 0)
-	{
-		featClass->SetBaseProperties (parentProps);	
-	}
-	else
-	{
-		FdoPtr<FdoReadOnlyPropertyDefinitionCollection> parentBaseProps = parent->GetBaseProperties ();
-		FdoInt32 cntBaseProps = parentBaseProps->GetCount ();
-		FdoPtr<FdoPropertyDefinitionCollection> baseProps = FdoPropertyDefinitionCollection::Create (NULL);
-		for (FdoInt32 i=0; i<cntBaseProps; i++)
-		{
-			FdoPtr<FdoPropertyDefinition> prop = parentBaseProps->GetItem (i);
-			baseProps->Add (prop);
-		}
+    FdoPtr<FdoPropertyDefinitionCollection> parentProps = parent->GetProperties ();
+    if (parentProps->GetCount () > 0)
+    {
+        featClass->SetBaseProperties (parentProps);    
+    }
+    else
+    {
+        FdoPtr<FdoReadOnlyPropertyDefinitionCollection> parentBaseProps = parent->GetBaseProperties ();
+        FdoInt32 cntBaseProps = parentBaseProps->GetCount ();
+        FdoPtr<FdoPropertyDefinitionCollection> baseProps = FdoPropertyDefinitionCollection::Create (NULL);
+        for (FdoInt32 i=0; i<cntBaseProps; i++)
+        {
+            FdoPtr<FdoPropertyDefinition> prop = parentBaseProps->GetItem (i);
+            baseProps->Add (prop);
+        }
 
-		featClass->SetBaseProperties (baseProps);
-	}
+        featClass->SetBaseProperties (baseProps);
+    }
 }
 
 /// <summary>Get the dictionary that contains the mappings between FDO applicable class names and WMS layer names.</summary>
@@ -892,31 +879,31 @@
 
 void FdoWmsConnection::_setDefaultSpatialContextAssociation (FdoClassDefinition* featClass)
 {
-	FdoString* className = featClass->GetName ();
-	FdoPtr<FdoDictionaryElement> element = mLayerMappings->GetItem (className);
-	FdoString* layerName = element->GetValue ();
-	FdoString* crsName = NULL;
-	FdoWmsLayerP layer;
+    FdoString* className = featClass->GetName ();
+    FdoPtr<FdoDictionaryElement> element = mLayerMappings->GetItem (className);
+    FdoString* layerName = element->GetValue ();
+    FdoString* crsName = NULL;
+    FdoWmsLayerP layer;
 
-	// If a layer name is associated to the class definition find the associated layer 
-	if (layerName != NULL)
-	{
-		// Retrieve the WMS capabilities returned by the WMS server
+    // If a layer name is associated to the class definition find the associated layer 
+    if (layerName != NULL)
+    {
+        // Retrieve the WMS capabilities returned by the WMS server
         FdoPtr<FdoWmsCapabilities> capa = static_cast<FdoWmsCapabilities *>(mWmsServiceMetadata->GetCapabilities ());
-		FdoPtr<FdoWmsLayerCollection> layers = capa->GetLayers ();		
+        FdoPtr<FdoWmsLayerCollection> layers = capa->GetLayers ();        
 
-		// Search for the list of layers with the specified name in all the layers and child layers
+        // Search for the list of layers with the specified name in all the layers and child layers
         // returned by the server
         layer = FindLayer (layers, layerName);
-		while (layer != NULL)
-		{
-			// Get the CRS names associated to the WMS layers, as defined by the server's capabilities response
+        while (layer != NULL)
+        {
+            // Get the CRS names associated to the WMS layers, as defined by the server's capabilities response
             FdoStringsP crsNames = layer->GetCoordinateReferenceSystems ();
-			if (crsNames->GetCount () > 0)
-			{
-				// If the layer supports the default CRS (EPSG:4326) find the index of the default CRS
+            if (crsNames->GetCount () > 0)
+            {
+                // If the layer supports the default CRS (EPSG:4326) find the index of the default CRS
                 // (Use both default CRS names in the search. A server may support one or both)
-				FdoInt32 indexDefaultCRS = crsNames->IndexOf(FdoWmsGlobals::DefaultEPSGCode);
+                FdoInt32 indexDefaultCRS = crsNames->IndexOf(FdoWmsGlobals::DefaultEPSGCode);
                 if (indexDefaultCRS == -1) 
                 {
                     indexDefaultCRS = crsNames->IndexOf(FdoWmsGlobals::DefaultEPSGCode2);
@@ -925,82 +912,82 @@
                 // If the index of the default CRS was found, use it to retrieve the CRS name
                 if (indexDefaultCRS != -1) 
                 {
-				    crsName = crsNames->GetString (indexDefaultCRS);
+                    crsName = crsNames->GetString (indexDefaultCRS);
                 }
                 // Otherwise, get the first spatial context found in the list of the spatial contexts
-				// associated to the WMS layer
+                // associated to the WMS layer
                 else
                 {
-				    crsName = crsNames->GetString (0);
+                    crsName = crsNames->GetString (0);
                 }
 
-				// Stop processing layers
+                // Stop processing layers
                 break;
-			}
-			else
-			{
-				// If the current layer has no CRS specified, then we should look into its parent layer
-				// if it has parent.
-				layer = layer->GetParent ();
-			}
-		}
+            }
+            else
+            {
+                // If the current layer has no CRS specified, then we should look into its parent layer
+                // if it has parent.
+                layer = layer->GetParent ();
+            }
+        }
 
-		// If a CRS name is associated to the layer, use it to set the classes spatial context association
+        // If a CRS name is associated to the layer, use it to set the classes spatial context association
         if (crsName != NULL)
-		{
-			// First we search the raster property in the BaseProperties
-			FdoPtr<FdoReadOnlyPropertyDefinitionCollection> baseProps = featClass->GetBaseProperties ();
-			for (FdoInt32 i=0; i<baseProps->GetCount (); i++)
-			{
-				FdoPtr<FdoPropertyDefinition> baseProp = baseProps->GetItem (i);
-				FdoRasterPropertyDefinition* rasterProp = dynamic_cast<FdoRasterPropertyDefinition *> (baseProp.p);
-				if (rasterProp != NULL)
-				{
+        {
+            // First we search the raster property in the BaseProperties
+            FdoPtr<FdoReadOnlyPropertyDefinitionCollection> baseProps = featClass->GetBaseProperties ();
+            for (FdoInt32 i=0; i<baseProps->GetCount (); i++)
+            {
+                FdoPtr<FdoPropertyDefinition> baseProp = baseProps->GetItem (i);
+                FdoRasterPropertyDefinition* rasterProp = dynamic_cast<FdoRasterPropertyDefinition *> (baseProp.p);
+                if (rasterProp != NULL)
+                {
                     FdoString* scName = rasterProp->GetSpatialContextAssociation();
                     if (scName == NULL || wcslen(scName) == 0) 
                     {
-					    rasterProp->SetSpatialContextAssociation (crsName);
+                        rasterProp->SetSpatialContextAssociation (crsName);
                     }
 
-					return;
-				}
-			}
+                    return;
+                }
+            }
 
-			// If the raster property does not exist in the base properties, check the properties list
-			FdoPtr<FdoPropertyDefinitionCollection> props = featClass->GetProperties ();
-			for (FdoInt32 i=0; i<props->GetCount (); i++)
-			{
-				FdoPtr<FdoPropertyDefinition> prop = props->GetItem (i);
-				FdoRasterPropertyDefinition* rasterProp = dynamic_cast<FdoRasterPropertyDefinition *> (prop.p);
-				if (rasterProp != NULL)
-				{
+            // If the raster property does not exist in the base properties, check the properties list
+            FdoPtr<FdoPropertyDefinitionCollection> props = featClass->GetProperties ();
+            for (FdoInt32 i=0; i<props->GetCount (); i++)
+            {
+                FdoPtr<FdoPropertyDefinition> prop = props->GetItem (i);
+                FdoRasterPropertyDefinition* rasterProp = dynamic_cast<FdoRasterPropertyDefinition *> (prop.p);
+                if (rasterProp != NULL)
+                {
                     FdoString* scName = rasterProp->GetSpatialContextAssociation();
                     if (scName == NULL || wcslen(scName) == 0) 
                     {
-					    rasterProp->SetSpatialContextAssociation (crsName);
+                        rasterProp->SetSpatialContextAssociation (crsName);
                     }
 
-					return;
-				}
-			}
+                    return;
+                }
+            }
 
-		    // The class does not have a raster property
-			if (!featClass->GetIsAbstract())
+            // The class does not have a raster property
+            if (!featClass->GetIsAbstract())
                 throw FdoException::Create (NlsMsgGet (FDOWMS_FEATURE_NO_RASTER_PROPERTY, "Class '%1$ls' does not contain a Raster property.", className));
 
-		}
-		else
-		{
-			// The layer must have CRS information except the "abstract" layers.
-			if (!featClass->GetIsAbstract())
-				throw FdoException::Create (NlsMsgGet (FDOWMS_12002_LAYER_HAS_NO_CRS, "The WMS layer or its parent layers has no CRS."));
-		}
-	}
-	else
-	{
-		// A layer was not associated to the FDO class
+        }
+        else
+        {
+            // The layer must have CRS information except the "abstract" layers.
+            if (!featClass->GetIsAbstract())
+                throw FdoException::Create (NlsMsgGet (FDOWMS_12002_LAYER_HAS_NO_CRS, "The WMS layer or its parent layers has no CRS."));
+        }
+    }
+    else
+    {
+        // A layer was not associated to the FDO class
         throw FdoException::Create (NlsMsgGet (FDOWMS_12001_LAYER_NOT_EXIST, "The WMS layer '%1$ls' does not exist.", className));
-	}
+    }
 }
 
 /// <summary>Search the class and it's parents for its raster property definition.</summary>
@@ -1038,35 +1025,35 @@
 /// <returns>Return the layer with the specified name. If not found, return NULL.</returns>
 FdoWmsLayer* FdoWmsConnection::FindLayer (FdoWmsLayerCollection* layers, FdoString* name)
 {
-	FdoWmsLayer* ret = NULL;
-	for (FdoInt32 i=0; i<layers->GetCount (); i++)
-	{
-		FdoPtr<FdoWmsLayer> layer = layers->GetItem (i);
-		FdoString* layerName = layer->GetName ();
-		if (layerName == NULL || wcslen (layerName) == 0)
-		{
-			layerName = layer->GetTitle ();
-		}
+    FdoWmsLayer* ret = NULL;
+    for (FdoInt32 i=0; i<layers->GetCount (); i++)
+    {
+        FdoPtr<FdoWmsLayer> layer = layers->GetItem (i);
+        FdoString* layerName = layer->GetName ();
+        if (layerName == NULL || wcslen (layerName) == 0)
+        {
+            layerName = layer->GetTitle ();
+        }
 
-		if (layerName == NULL)
-			throw FdoSchemaException::Create (NlsMsgGet (FDOWMS_SCHEMA_LAYER_NO_TITLE, "A WMS layer has no name or title."));
+        if (layerName == NULL)
+            throw FdoSchemaException::Create (NlsMsgGet (FDOWMS_SCHEMA_LAYER_NO_TITLE, "A WMS layer has no name or title."));
 
-		if (wcscmp (name, layerName) == 0)
-		{
-			ret = layer;
-			break;
-		}
+        if (wcscmp (name, layerName) == 0)
+        {
+            ret = layer;
+            break;
+        }
 
-		// find in the child layers
-		FdoPtr<FdoWmsLayerCollection> childLayers = layer->GetLayers ();
-		ret = FindLayer (childLayers, name);
-		if (ret)
-		{
-			return FDO_SAFE_ADDREF (ret);
-		}
-	}
+        // find in the child layers
+        FdoPtr<FdoWmsLayerCollection> childLayers = layer->GetLayers ();
+        ret = FindLayer (childLayers, name);
+        if (ret)
+        {
+            return FDO_SAFE_ADDREF (ret);
+        }
+    }
 
-	return FDO_SAFE_ADDREF (ret);
+    return FDO_SAFE_ADDREF (ret);
 }
 
 void FdoWmsConnection::_buildUpClassLayerMappings (FdoWmsLayerCollection *layers)
@@ -1083,13 +1070,16 @@
 
 void FdoWmsConnection::_buildUpClassLayerMapping (FdoWmsLayer* layer)
 {
+    //
+    // Retrieve the layer 'Name' from the WMS layer. We first try  
+    // the actual layer name. If that is not set, we use the layer 
+    // title as the name
+    //
     FdoStringP layerName = layer->GetName ();
-    if (layerName.GetLength() == 0) 
-    {
+    if (layerName.GetLength() == 0) {
         layerName = layer->GetTitle ();
-        if (layerName.GetLength() == 0) 
-        {
-            throw FdoSchemaException::Create(NlsMsgGet(FDOWMS_SCHEMA_LAYER_NO_TITLE, "A WMS layer has no name or title."));
+        if (layerName.GetLength() == 0) {
+            return;
         }
     }
 
@@ -1100,6 +1090,11 @@
     FdoStringP tmpLayerName = layerName.Replace( L".", L" " );
     FdoStringP modLayerName = tmpLayerName.Replace( L":", L" " );
 
+    //
+    // If not already in the layer collection, add it. 
+    // NOTE: Several abstract layers may have the same title.
+    // This would cause the second item to be igniored
+    //
     if (mLayerMappings->FindItem (modLayerName) == NULL)
     {
         FdoPtr<FdoDictionaryElement> pair = FdoDictionaryElement::Create (modLayerName, layerName);



More information about the fdo-commits mailing list