[fdo-users] RE: [mapguide-users] Advanced WMSproviderconfiguration

Greg Boone greg.boone at autodesk.com
Fri Apr 13 12:33:02 EDT 2007


Hi All.

 

Here is a pure FDO example on how to use the FDO API and FDO WMS
Override API classes to:

 

1)    Create an FDO logical class definition

2)    Create an FDO WMS physical override definition

a.    Set the WMS specific override GetMap request properties

3)    Write the configuration file to disk

4)    Read the configuration file from disk

5)    Make a direct connection to the FDO WMS Provider

6)    Open the connection and iterate over the logical and physical
schema

 

 

All these steps are not needed to allow you to programmatically generate
the configuration file. Steps 1-3 are sufficient. The result of 3 can be
passed to MapGuide.

 

 

void OverridesTest::TestNoDefaultDataModel()

{

    try

    {  

        // Create the Logical Schema Definition

        FdoFeatureSchemasP schemas = FdoFeatureSchemaCollection::Create(
NULL );

        FdoFeatureSchemaP schema = FdoFeatureSchema::Create( L"NASA",
L"" );

        FdoClassesP classes = schema->GetClasses();

 

        FdoFeatureClassP classDef = FdoFeatureClass::Create(
L"GlobalMosaic", L"" );

        classDef->SetIsAbstract(false);

        FdoPropertiesP properties = classDef->GetProperties();

        FdoDataPropertiesP IdProperties =
classDef->GetIdentityProperties();

 

        FdoDataPropertyP prop = FdoDataPropertyDefinition::Create(
L"FeatId", L"" );

        prop->SetDataType( FdoDataType_String );

        prop->SetLength(255);

        prop->SetNullable(false);

        prop->SetReadOnly(false);

 

        properties->Add( prop );

        IdProperties->Add( prop );

 

        FdoRasterPropertyP rasterProp =
FdoRasterPropertyDefinition::Create( L"Image", L"" );

        rasterProp->SetNullable(true);

        rasterProp->SetReadOnly(false);

        rasterProp->SetDefaultImageXSize(0);

        rasterProp->SetDefaultImageYSize(0);

        rasterProp->SetSpatialContextAssociation(L"");

        rasterProp->SetDefaultDataModel(NULL);

 

        properties->Add( rasterProp );

 

        classes->Add( classDef );

        schema->AcceptChanges();

        schemas->Add( schema );

 

        // Create the Pysical Override Schema Mapping Definition

        FdoSchemaMappingsP mappings =
FdoPhysicalSchemaMappingCollection::Create();

        FdoWmsOvPhysicalSchemaMappingP config =
FdoWmsOvPhysicalSchemaMapping::Create();

        config->SetName(L"NASA");

 

        FdoWmsOvClassesP ovClasses = config->GetClasses();

        FdoWmsOvClassDefinitionP classDefn =
FdoWmsOvClassDefinition::Create();

        classDefn->SetName(L"GlobalMosaic");

 

        FdoWmsOvRasterDefinitionP rasterDefn =
FdoWmsOvRasterDefinition::Create();

        rasterDefn->SetName(L"Image");

 

        // Set the WMS GetMap request properties

        rasterDefn->SetFormatType(FdoWmsOvFormatType_Png);

        rasterDefn->SetTransparent(true);

        rasterDefn->SetBackgroundColor(L"0xFFFFFF");

        rasterDefn->SetTimeDimension(L"TIME=current");

        rasterDefn->SetElevationDimension(L"ELEVATION=0");

        rasterDefn->SetSpatialContextName(L"EPSG:4326");

 

        FdoWmsOvLayersP layers = rasterDefn->GetLayers();

        FdoWmsOvLayerDefinitionP layerDefn =
FdoWmsOvLayerDefinition::Create();

        layerDefn->SetName(L"global_mosaic");

        layers->Add(layerDefn);

 

        FdoWmsOvStyleDefinitionP styleDefn =
FdoWmsOvStyleDefinition::Create();

        styleDefn->SetName(L"pseudo");

 

        layerDefn->SetStyle(styleDefn);

 

        // Finalize the mapping definition

        classDefn->SetRasterDefinition(rasterDefn);

        ovClasses->Add(classDefn);

        mappings->Add(config);

 

        // Write the logical schema and overrides to a configuration
file

        std::remove("NASA.xml");

        FdoXmlWriterP writer = FdoXmlWriter::Create( L"NASA.xml", true,
FdoXmlWriter::LineFormat_Indent, 50);

        schemas->WriteXml(writer);

        mappings->WriteXml(writer);

        writer = NULL;

 

        // Read in the file contents and use them to connect to the WMS
server

        FdoPtr<FdoIoStream> fileStream =
FdoIoFileStream::Create(L"NASA.xml", L"r+");

 

        // Connect to the WMS Provider

        FdoPtr<IConnectionManager> manager =
FdoFeatureAccessManager::GetConnectionManager ();

        FdoPtr<FdoIConnection> conn = manager->CreateConnection
(L"OSGeo.WMS.3.2");

 

        // Set the configuration file

 
conn->SetConnectionString(L"FeatureServer=http://wms.jpl.nasa.gov/wms.cg
i");

        conn->SetConfiguration(fileStream);

 

        // Open the connection to the Server

        CPPUNIT_ASSERT (FdoConnectionState_Open == conn->Open ());

 

        // Test the schema and overrides we just created

        TestSchema(conn);

    }

    catch (FdoException* e) 

    {

        fail(e);

    }

}

 

void OverridesTest::TestSchema(FdoIConnection* conn)

{

    // Validate the connection

    FdoPtr<FdoIDescribeSchema> cmdDS = 

        static_cast<FdoIDescribeSchema *> (conn->CreateCommand
(FdoCommandType_DescribeSchema));

    FdoPtr<FdoFeatureSchemaCollection> schemas = cmdDS->Execute ();

    FdoInt32 cntSchemas = schemas->GetCount ();

    CPPUNIT_ASSERT (cntSchemas == 1);

 

    FdoPtr<FdoFeatureSchema> schema = schemas->GetItem (0);

    FdoPtr<FdoClassCollection> classes = schema->GetClasses ();

    FdoInt32 cntClasses = classes->GetCount ();

    CPPUNIT_ASSERT (cntClasses == 1);

 

    // test the inheritance realationship

    for (FdoInt32 j=0; j<cntClasses; j++)

    {

        FdoPtr<FdoClassDefinition> clsDef = classes->GetItem (j);

        FdoStringP clsName = clsDef->GetName ();

        FdoFeatureClass* featClsDef = static_cast<FdoFeatureClass *>
(clsDef.p);

 

        FdoFeatureClass* base = static_cast<FdoFeatureClass *>
(featClsDef->GetBaseClass ());            

        FdoPtr<FdoPropertyDefinitionCollection> props =
clsDef->GetProperties ();

        FdoInt32 cntProps = props->GetCount ();

        for (FdoInt32 k=0; k<cntProps; k++)

        {

            FdoPtr<FdoPropertyDefinition> prop = props->GetItem (k);

            FdoStringP propName = prop->GetName ();

            FdoPropertyType propType = prop->GetPropertyType ();

        }         

    }

 

    FdoPtr<FdoIDescribeSchemaMapping> cmd = 

       static_cast<FdoIDescribeSchemaMapping *> (conn->CreateCommand
(FdoCommandType_DescribeSchemaMapping));

    FdoPtr<FdoPhysicalSchemaMappingCollection> physicalMappings =
cmd->Execute ();

 

    for (FdoInt32 i=0; i<physicalMappings->GetCount(); i++)

    {

        FdoPtr<FdoPhysicalSchemaMapping> mapping =
physicalMappings->GetItem (i);

        FdoString* mappingName = mapping->GetName ();

        FdoString* providerName = mapping->GetProvider ();

    }

}

 

 

 

-----Original Message-----
From: fdo-users-bounces at lists.osgeo.org
[mailto:fdo-users-bounces at lists.osgeo.org] On Behalf Of Greg Boone
Sent: Friday, April 13, 2007 10:15 AM
To: MapGuide Users Mail List; Jason Birch
Cc: fdo-users at lists.osgeo.org
Subject: RE: [fdo-users] RE: [mapguide-users] Advanced
WMSproviderconfiguration

 

I doubt my code sample would illustrate how MapGuide uses the

configuration document. My sample will only provide a programmatic

illustration on how to dynamically generate the configuration document.

 

Greg

 

-----Original Message-----

From: mapguide-users-bounces at lists.osgeo.org

[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Chris

Tweedie

Sent: Friday, April 13, 2007 1:04 AM

To: Jason Birch

Cc: fdo-users at lists.osgeo.org; MapGuide Users Mail List

Subject: RE: [fdo-users] RE: [mapguide-users] Advanced WMS

providerconfiguration

 

ResourceContent? Still getting used to mapguide terminology :-)

 

I was thinking that if this ever is solved that it should really be on

the wiki. It certainly isnt a simple process.

 

Perhaps if you just use the NASA sample XML file Jason, let me know if

you have any luck? Once i have something working i can easily port it

back to my services

 

Maybe Greg's code might be handy?

 

Thanks for your help.

 

Chris

 

On Thu, 12 Apr 2007 20:31:48 -0700, "Jason Birch"

<Jason.Birch at nanaimo.ca> wrote:

> Hmm.  Maybe uploading the configuration document doesn't automatically

set

> up the relationship between the feature source and the config

document.

>  

> What does the ResourceContent (not header) for your WMS source look

like

> after uploading the content?

>  

> Jason

> 

>  

> ________________________________

> 

> From: Chris Tweedie

> Subject: [fdo-users] RE: [mapguide-users] Advanced WMS provider

> configuration

> 

> 

> 

> Hi Jason, thanks for the additional info.

> 

> I'm still a little confused on the relationship between the config

file

> attached to the data connection and the mapguide layer. I used the

> multi-layer XML example to define multiple layers, however how do i

then

> create a new mapguide layer based on the custom commands? If i try to

> create a layer based off the connection, it simply queries the WMS

> featureserver again and gives me a list of the featuretypes as usual?

> 

> <Layer name="srtm_mag">

>  <Style name="default"/>

> </Layer>

> <Layer name="global_mosaic">

>  <Style name="pseudo"/>

> </Layer>

> 

> If i can finish this last step it certainly will solve my problems

> 

> Chris

--

Chris Tweedie

 

_______________________________________________

mapguide-users mailing list

mapguide-users at lists.osgeo.org

http://lists.osgeo.org/mailman/listinfo/mapguide-users

 

_______________________________________________

fdo-users mailing list

fdo-users at lists.osgeo.org

http://lists.osgeo.org/mailman/listinfo/fdo-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/fdo-users/attachments/20070413/dda5ac75/attachment-0001.html


More information about the fdo-users mailing list