Opened 16 years ago

Closed 16 years ago

#276 closed defect (fixed)

Can't access WMS custom commands from managed code

Reported by: ssakharov Owned by: gregboone
Priority: major Milestone: 3.4.0
Component: FDO API Version: 3.3.0
Severity: 3 Keywords:
Cc: External ID:

Description

I seem to have hit a bug. i cant create any of the custom wms commands from c#. The enum defined in mgCommandTypes.h under the wms provider just isnt available. From the code it should be under osgeo.fdo.providers.wms, but i only get the command object interfaces, and the overrides.

I attempted to try:

CreateCommand(OSGeo.FDO.Commands.CommandType.CommandType_FirstProviderCommand
+ 1800);

hoping to get an GetImageFormats command back, but its always null.

Change History (3)

comment:1 by gregboone, 16 years ago

Status: newassigned

This submission tests and resolves issues identified when attempting to access the following WMS custom commands through the FDO API managed interface.

GetFeatureClassStyles !GetFeatureClassCRSNames GetImageFormats

Through testing, it was discovered that no mechanism existed to allow custom commands created at the provider level to be exposed through the FDO ICommand Managed interface. The reason why these commands are not supported is that the creation of the managed wrapper object around the custom command is attempted in the FDO managed API component, where the WMS specific managed interfaces are unknown. Only the published non-custom FDO commands are known at this level.

To resolve this issue, I fell back on the command pattern used to resolve a similar issue identified with the provider specific implementations of FDO PhysicalSchemaMappings. In that case, it was decided that the provider specific implementation of the PhysicalSchemaMapping interface would be exposed as a concrete class rather than a derived interface. As a part of the definition of the concrete class, a constructor would be defined that accepted the result of the call to IConnection::CreateCommand. It was then the responsibility of the managed class to construct itself correctly in a manner by which it is able to interface with the underlying unmanaged object.

For the case of the commands mentioned above, the following concrete classes would have to be defined and exposed for the WMS provider:

public __gc class GetFeatureClassStylesCommand : 
    public ICommandImp, 
    public IGetFeatureClassStyles 
{
   ...

public:
    GetFeatureClassStylesCommand(ICommand* command, Boolean autoDelete);

   ...
}

public __gc class GetImageFormatsCommand : 
    public ICommandImp, 
    public IGetFeatureClassStyles 
{
   ...

public:
    GetImageFormatsCommand(ICommand* command, Boolean autoDelete);

   ...
}

public __gc class GetFeatureClassCRSNamesCommand : 
    public ICommandImp, 
    public IGetFeatureClassStyles 
{
   ...

public:    
   GetFeatureClassCRSNamesCommand(ICommand* command, Boolean autoDelete);

   ...
}

Here is an example of how the the above wrpapper classes are to be used:

IConnectionManager connectionManager = FeatureAccessManager.GetConnectionManager();
IConnection mConnection = connectionManager.CreateConnection("OSGeo.WMS.3.3");
mConnection.ConnectionString = @"FeatureServer=http://www2.dmsolutions.ca/cgi-bin/mswms_gmap";

ConnectionState state = mConnection.Open();
ICommand command = mConnection.CreateCommand(CommandType_GetImageFormats);
GetImageFormatsCommand formatsCmd = new GetImageFormatsCommand(command, false);
StringCollection strColl = formatsCmd.Execute();
for (int i = 0; i < strColl.Count; i++) {
    StringElement strElem = strColl.get_Item(i);
    string strVal = strElem.String;
    Console.WriteLine(strVal);
}

mConnection.Close();

During the implementation of this change, it was discoverd that there was no means of retrieving the actual string value attached to the FDO StringElement interface using the managed FDO API. It looks as if the unmanaged 'FdoString* GetString()' method was never exposed in the managed API. To resolve this issue, a new interface method will need to be added to StringElement as follows:

public __sealed __gc class StringElement : public Disposable
{
   ...

public:
   __property System::String* get_String ();

   ...
}

The following Files were modified:

*
******Fdocore******
Modified : Fdo/Managed\Src\OSGeo\Common\mgStringElement.cpp
Modified : Fdo/Managed\Src\OSGeo\Common\mgStringElement.h
Modified : Fdo/Managed\Src\OSGeo\FDO\Commands\mgICommandImp.cpp
Modified : Fdo/Managed\Src\OSGeo\FDO\Commands\mgICommandImp.h
Modified : Fdo/Managed\Src\OSGeo\FDO\mgObjectFactory.cpp
*
******WMS******
Modified : Providers/WMS/Src\UnitTest\WmsTestCustomCommands.cpp
Modified : Providers/WMS/Docs\doc_src\Doxyfile_WMS_managed
Modified : Providers/WMS/Managed\Src\OSGeo\FDO\Providers\WMS\Override\stdafx.h
Modified : Providers/WMS/Managed\Src\OSGeo\FDO\Providers\WMS\Override\AssemblyVersion.cpp
Modified : Providers/WMS/Managed\Src\OSGeo\FDO\Providers\WMS\mgIGetFeatureClassCRSNames.h
Modified : Providers/WMS/Managed\Src\OSGeo\FDO\Providers\WMS\mgIGetFeatureClassCRSNamesImp.cpp
Modified : Providers/WMS/Managed\Src\OSGeo\FDO\Providers\WMS\mgIGetImageFormats.h
Modified : Providers/WMS/Managed\Src\OSGeo\FDO\Providers\WMS\mgIGetImageFormatsImp.cpp
Modified : Providers/WMS/Managed\Src\OSGeo\FDO\Providers\WMS\mgIGetFeatureClassCRSNamesImp.h
Modified : Providers/WMS/Managed\Src\OSGeo\FDO\Providers\WMS\mgIGetImageFormatsImp.h
Modified : Providers/WMS/Managed\Src\OSGeo\FDO\Providers\WMS\mgIGetFeatureClassStyles.h
Modified : Providers/WMS/Managed\Src\OSGeo\FDO\Providers\WMS\mgIGetFeatureClassStylesImp.cpp
Modified : Providers/WMS/Managed\Src\OSGeo\FDO\Providers\WMS\mgCommandType.h
Modified : Providers/WMS/Managed\Src\OSGeo\FDO\Providers\WMS\mgIGetFeatureClassStylesImp.h
*

comment:2 by gregboone, 16 years ago

Milestone: 3.3.13.4.0

comment:3 by gregboone, 16 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.