[fdo-commits] r2505 - in trunk/Providers/WMS/Src: Provider UnitTest
svn_fdo at osgeo.org
svn_fdo at osgeo.org
Mon Feb 12 18:38:11 EST 2007
Author: gregboone
Date: 2007-02-12 18:38:11 -0500 (Mon, 12 Feb 2007)
New Revision: 2505
Modified:
trunk/Providers/WMS/Src/Provider/FdoWmsConnection.cpp
trunk/Providers/WMS/Src/UnitTest/CubeServer_WMS_Config.xml
trunk/Providers/WMS/Src/UnitTest/WmsTestDescribeSchema.cpp
trunk/Providers/WMS/Src/UnitTest/WmsTestSelect.cpp
Log:
This submission resolves
882917 - WMS: It is not appropriate to use the first CRS as default SC when multiple CRS codes are provided.
When a WMS layer is available in several coordinate reference systems, the first one listed in the capability document has been used as the default spatial context for that layer. A more appropriate way to deal with such situation is trying to use the most universal one, or non-distortion one, e.g., geographic coordinate systems is preferable to projected CRS.
Here is an example, http://www.datadoors.net/$_streaminguid.258b2328-80bc-426a-a0a1-fc2023dbb333/wms.ashx?
All layers served in this server are available in many CRSs and EPSG:4267(LL27) is listed first. As a result, LL27 is the default spatial context for all layers. However, when layers are requested via LL27, the areas outside NA can't be rendered properly by the server. When switching to another available CRS EPSG:4326 (LL84), all the layers will work properly.
Since we don't allow specifying CRS for layers via UI in both Map and MapGuide, choosing a more appropriate CRS for a layer becomes more important for rendering a layer properly.
Modified: trunk/Providers/WMS/Src/Provider/FdoWmsConnection.cpp
===================================================================
--- trunk/Providers/WMS/Src/Provider/FdoWmsConnection.cpp 2007-02-12 22:39:30 UTC (rev 2504)
+++ trunk/Providers/WMS/Src/Provider/FdoWmsConnection.cpp 2007-02-12 23:38:11 UTC (rev 2505)
@@ -894,25 +894,47 @@
FdoString* className = featClass->GetName ();
FdoPtr<FdoDictionaryElement> element = mLayerMappings->GetItem (className);
FdoString* layerName = element->GetValue ();
- FdoString* crsName = NULL;
+ FdoString* crsName = NULL;
FdoWmsLayerP layer;
- // search the layer in the layers
+ // If a layer name is associated to the class definition find the associated layer
if (layerName != NULL)
{
- FdoPtr<FdoWmsCapabilities> capa = dynamic_cast<FdoWmsCapabilities *>(mWmsServiceMetadata->GetCapabilities ());
+ // Retrieve the WMS capabilities returned by the WMS server
+ FdoPtr<FdoWmsCapabilities> capa = dynamic_cast<FdoWmsCapabilities *>(mWmsServiceMetadata->GetCapabilities ());
FdoPtr<FdoWmsLayerCollection> layers = capa->GetLayers ();
- layer = FindLayer (layers, layerName);
+ // 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)
{
- FdoStringsP crsNames = layer->GetCoordinateReferenceSystems ();
+ // 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)
{
- // Get the first spatial context found in the list of the spatial contexts
+ // 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);
+ if (indexDefaultCRS == -1)
+ {
+ indexDefaultCRS = crsNames->IndexOf(FdoWmsGlobals::DefaultEPSGCode2);
+ }
+
+ // If the index of the default CRS was found, use it to retrieve the CRS name
+ if (indexDefaultCRS != -1)
+ {
+ crsName = crsNames->GetString (indexDefaultCRS);
+ }
+ // Otherwise, get the first spatial context found in the list of the spatial contexts
// associated to the WMS layer
- crsName = crsNames->GetString (0);
- break;
+ else
+ {
+ crsName = crsNames->GetString (0);
+ }
+
+ // Stop processing layers
+ break;
}
else
{
@@ -922,9 +944,10 @@
}
}
- if (crsName != NULL)
+ // If a CRS name is associated to the layer, use it to set the classes spatial context association
+ if (crsName != NULL)
{
- // firstly we search the raster property in the BaseProperties
+ // First we search the raster property in the BaseProperties
FdoPtr<FdoReadOnlyPropertyDefinitionCollection> baseProps = featClass->GetBaseProperties ();
for (FdoInt32 i=0; i<baseProps->GetCount (); i++)
{
@@ -932,13 +955,17 @@
FdoRasterPropertyDefinition* rasterProp = dynamic_cast<FdoRasterPropertyDefinition *> (baseProp.p);
if (rasterProp != NULL)
{
- if (rasterProp->GetSpatialContextAssociation() == NULL ||
- (rasterProp->GetSpatialContextAssociation(), L"") == 0)
- rasterProp->SetSpatialContextAssociation (crsName);
+ FdoString* scName = rasterProp->GetSpatialContextAssociation();
+ if (scName == NULL || wcslen(scName) == 0)
+ {
+ rasterProp->SetSpatialContextAssociation (crsName);
+ }
+
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++)
{
@@ -946,10 +973,20 @@
FdoRasterPropertyDefinition* rasterProp = dynamic_cast<FdoRasterPropertyDefinition *> (prop.p);
if (rasterProp != NULL)
{
- rasterProp->SetSpatialContextAssociation (crsName);
+ FdoString* scName = rasterProp->GetSpatialContextAssociation();
+ if (scName == NULL || wcslen(scName) == 0)
+ {
+ rasterProp->SetSpatialContextAssociation (crsName);
+ }
+
return;
}
}
+
+ // 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
{
@@ -960,7 +997,8 @@
}
else
{
- throw FdoException::Create (NlsMsgGet (FDOWMS_12001_LAYER_NOT_EXIST, "The WMS layer '%1$ls' does not exist.", className));
+ // 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));
}
}
Modified: trunk/Providers/WMS/Src/UnitTest/CubeServer_WMS_Config.xml
===================================================================
--- trunk/Providers/WMS/Src/UnitTest/CubeServer_WMS_Config.xml 2007-02-12 22:39:30 UTC (rev 2504)
+++ trunk/Providers/WMS/Src/UnitTest/CubeServer_WMS_Config.xml 2007-02-12 23:38:11 UTC (rev 2505)
@@ -17,13 +17,13 @@
elementFormDefault="qualified"
attributeFormDefault="unqualified"
>
- <xs:element name="TopographyDemisWorldMap" type="Itasca_Demo:TopographyDemisWorldMapType" abstract="false" substitutionGroup="gml:_Feature">
- <xs:key name="TopographyDemisWorldMapKey">
- <xs:selector xpath=".//TopographyDemisWorldMap"/>
+ <xs:element name="WorldFaultLines" type="Itasca_Demo:WorldFaultLinesType" abstract="false" substitutionGroup="gml:_Feature">
+ <xs:key name="WorldFaultLinesKey">
+ <xs:selector xpath=".//WorldFaultLines"/>
<xs:field xpath="Id"/>
</xs:key>
</xs:element>
- <xs:complexType name="TopographyDemisWorldMapType" abstract="false">
+ <xs:complexType name="WorldFaultLinesType" abstract="false">
<xs:complexContent>
<xs:extension base="gml:AbstractFeatureType">
<xs:sequence>
@@ -47,7 +47,7 @@
</xs:complexType>
</xs:schema>
<SchemaMapping provider="OSGeo.WMS.3.3" name="Itasca_Demo" xmlns="http://www.autodesk.com/isd/fdo/WmsProvider">
- <complexType name="TopographyDemisWorldMapType">
+ <complexType name="WorldFaultLinesType">
<RasterDefinition name="Image">
<Format>PNG</Format>
<Transparent>true</Transparent>
@@ -55,7 +55,7 @@
<Time>current</Time>
<Elevation>100</Elevation>
<SpatialContext>EPSG:4326</SpatialContext>
- <Layer name="WMSLayers:Topography DEMIS World Map">
+ <Layer name="FAULTS:GSC">
</Layer>
</RasterDefinition>
</complexType>
Modified: trunk/Providers/WMS/Src/UnitTest/WmsTestDescribeSchema.cpp
===================================================================
--- trunk/Providers/WMS/Src/UnitTest/WmsTestDescribeSchema.cpp 2007-02-12 22:39:30 UTC (rev 2504)
+++ trunk/Providers/WMS/Src/UnitTest/WmsTestDescribeSchema.cpp 2007-02-12 23:38:11 UTC (rev 2505)
@@ -87,7 +87,7 @@
{
try
{
- TestServer(L"http://fbinter.stadt-berlin.de/fb/wms/oma_ogc_capabilitiesrequest.jsp", 373);
+ TestServer(L"http://fbinter.stadt-berlin.de/fb/wms/oma_ogc_capabilitiesrequest.jsp", 395);
}
catch (FdoException* e)
{
Modified: trunk/Providers/WMS/Src/UnitTest/WmsTestSelect.cpp
===================================================================
--- trunk/Providers/WMS/Src/UnitTest/WmsTestSelect.cpp 2007-02-12 22:39:30 UTC (rev 2504)
+++ trunk/Providers/WMS/Src/UnitTest/WmsTestSelect.cpp 2007-02-12 23:38:11 UTC (rev 2505)
@@ -788,7 +788,7 @@
#endif//_DEBUG
FdoPtr<FdoISelect> cmdSelect = static_cast<FdoISelect*>(conn->CreateCommand(FdoCommandType_Select));
- cmdSelect->SetFeatureClassName(L"Trails DEMIS World Map");
+ cmdSelect->SetFeatureClassName(L"LANDICEA_1M Foundation");
FdoPtr<FdoIFeatureReader> featureReader = cmdSelect->Execute();
FdoPtr<FdoClassDefinition> classDef2 = featureReader->GetClassDefinition();
@@ -823,7 +823,7 @@
CPPUNIT_ASSERT (FdoConnectionState_Open == conn->Open ());
cmdSelect = static_cast<FdoISelect*>(conn->CreateCommand(FdoCommandType_Select));
- cmdSelect->SetFeatureClassName(L"TopographyDemisWorldMap");
+ cmdSelect->SetFeatureClassName(L"WorldFaultLines");
featureReader = cmdSelect->Execute();
while (featureReader->ReadNext ())
{
@@ -1643,7 +1643,7 @@
FdoPtr<FdoPropertyDefinition> prop = props->GetItem (L"Raster");
FdoRasterPropertyDefinition* rasterProp = (FdoRasterPropertyDefinition*)(prop.p);
FdoStringP rasterAssoc = rasterProp->GetSpatialContextAssociation();
- CPPUNIT_ASSERT (rasterAssoc == L"EPSG:102190");
+ CPPUNIT_ASSERT (rasterAssoc == L"EPSG:4326");
FdoPtr<FdoISelect> cmdSelect = static_cast<FdoISelect*> (connection->CreateCommand (FdoCommandType_Select));
cmdSelect->SetFeatureClassName (L"DBM_7H_MIL_BOUNDARIES_LINE");
@@ -1759,7 +1759,7 @@
FdoPtr<FdoPropertyDefinition> prop = props->GetItem (L"Raster");
FdoRasterPropertyDefinition* rasterProp = (FdoRasterPropertyDefinition*)(prop.p);
FdoStringP rasterAssoc = rasterProp->GetSpatialContextAssociation();
- CPPUNIT_ASSERT (rasterAssoc == L"EPSG:42304");
+ CPPUNIT_ASSERT (rasterAssoc == L"EPSG:4326");
FdoPtr<FdoISelect> cmdSelect = static_cast<FdoISelect*> (connection->CreateCommand (FdoCommandType_Select));
cmdSelect->SetFeatureClassName (L"ecodistricts");
More information about the fdo-commits
mailing list