Opened 15 years ago

Closed 15 years ago

#1109 closed defect (fixed)

MgLayerBase bypass its subclasses

Reported by: christinebao Owned by: Christine Bao
Priority: medium Milestone:
Component: General Version: 2.0.2
Severity: trivial Keywords:
Cc: External ID:

Description

The inheritance hierarchy of MgLayerBase and its subclasses is:

   ---------------------------------------------------------------
  |      ------------------------------------------------         |
  |     |         MgLayerBase                            |        |
  |     |------------------------------------------------|        |
  |     |SetLayerDefinition(resourceId, resourceService) |        | 
  |     |SetLayerResourceContent(resourceContent)        |        |
  |     |GetLayerInfoFromDefinition(resourceService)     |        |
  |      ------------------------------------------------         |
  |                                       |                       | 
  |        MapGuide                     --|-----------------------              
  |                                    |  |
  |                      ----------------------------
  |                     |              |             |
  |                    \|/             |            \|/
  |   -------------------------------  |      -------------------------------
  |  |           MgLayer             | |     |          AcMapLayer           |
  |  |-------------------------------| |     |-------------------------------|
  |  |GetLayerInfoFromDefinition(...)| |     |GetLayerInfoFromDefinition(...)|
  |   -------------------------------  |      -------------------------------
  |                                    |
   ------------------------------------ 

MgLayerBase and MgLayer are in MapGuide, and AcMapLayer is in Map 3D.

Although MgLayerBase and MgLayer have GetLayerInfoFromDefinition(resourceService), they are for different purpose. MgLayerBase::GetLayerInfoFromDefinition(resourceService) is to read layer definition from resource service, and build up a runtime layer definition model. MgLayer::GetLayerInfoFromDefinition(resourceService) is to initialize identity property of this layer.

What's the problem:

During Trevor's fixing of ticket: http://trac.osgeo.org/mapguide/ticket/1002 (Batch Processing for Get Identity Properties), a flag is added to MgLayer's constructor "initIdProps" -- if initIdProps == true, MgLayer will initialize identity properties by calling its GetLayerInfoFromDefinition(resourceService); if initIdProps == false, MgLayer will ignore initialize identity property, instead a batch process will do this.

MapGuide uses the second scenario (initIdProps==false) after Trevor's fixing, a simple code snippet is:

Ptr<MgLayerBase> layer = new MgLayer(layerDefinition, resourceService, false/*initIdProps*/, false/*initLayerDefinition*/);
layer->SetLayerDefinition(newLayerDefinition, newResourceService);
or
layer->SetLayerResourceContent(layerDefinitionContent);
//batch process identity properties

In function SetLayerDefinition(resourceId, resourceService) and SetLayerResourceContent(resourceContent) a new layer definition model should be set up to replace the previous one, so MgLayerBase::GetLayerInfoFromDefinition(resourceService) should be used. Thus it force used MgLayerBase to do this. Take SetLayerResourceContent(resourceContent) for example:

SetLayerDefinition(resourceId, resourceService)
{
    //reset data members: m_definition, m_name etc
    MgLayerBase::GetLayerInfoFromDefinition(resourceService);
    //trigger events of OnLayerDefinitionChanged
}

It works for MapGuide and all test case passes. However a defect happens in Map 3D. AcMapLayer overrides GetLayerInfoFromDefinition(resourceService); and it should be used when calling SetLayerDefinition(resourceId, resourceService). But it's bypass and not get triggered.

How to fix:

Both the subclasses should trigger MgLayerBase's function to re-setup layer definition model, while do the override of itself. In code aspect:

  1. MgLayerBase::SetLayerDefinition(resourceId, resourceService) should call GetLayerInfoFromDefinition(resourceService) without class name prefix. If the subclass has override, it will be triggered.
  2. Subclass should re-setup layer definition model, and for MgLayer it should consider initIdProps before re-initialize identity properties.

Lessen from this case:

As GisPlatform is shared between MapGuide and Map 3D, more cases should be considered when API changes.

Related RFC: http://trac.osgeo.org/mapguide/wiki/MapGuideRfc73.

Attachments (1)

FixTicket#1109.patch (6.3 KB ) - added by christinebao 15 years ago.

Download all attachments as: .zip

Change History (3)

by christinebao, 15 years ago

Attachment: FixTicket#1109.patch added

comment:2 by christinebao, 15 years ago

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