[mapguide-trac] #1109: MgLayerBase bypass its subclasses

MapGuide Open Source trac_mapguide at osgeo.org
Sun Sep 27 02:44:03 EDT 2009


#1109: MgLayerBase bypass its subclasses
----------------------------+-----------------------------------------------
   Reporter:  christinebao  |       Owner:  Christine Bao
       Type:  defect        |      Status:  new          
   Priority:  medium        |   Milestone:               
  Component:  General       |     Version:  2.0.2        
   Severity:  trivial       |    Keywords:               
External_id:                |  
----------------------------+-----------------------------------------------
 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.

-- 
Ticket URL: <https://trac.osgeo.org/mapguide/ticket/1109>
MapGuide Open Source <http://mapguide.osgeo.org/>
MapGuide Open Source Internals


More information about the mapguide-trac mailing list