MapGuide Open Source:  Home |  Download |  Internals

Ticket #173 (new defect)

Opened 1 year ago

Last modified 4 months ago

.Net API for MapGuide 1.2 Beta2 cannot access layers

Reported by: ksgeograf Assigned to: trevorwekel
Priority: medium Milestone:
Component: General Version: 1.2.0
Severity: minor Keywords: API layers GetLayers Unpack
Cc: External ID: 939563

Description

using the following code:

        MgSiteConnection con = new MgSiteConnection();
        con.Open(new MgUserInformation(sessionID));

        //get the map
        MgSite site = con.GetSite();
        MgResourceService rs = (MgResourceService)con.CreateService(MgServiceType.ResourceService);
        MgResourceIdentifier mapID = new MgResourceIdentifier("Session:" + sessionID + "//" + mapName + "." + MgResourceType.Map);
        MgMap map = new MgMap();
        map.Open(rs, mapID);

        //get a feature service
        MgFeatureService ftr = (MgFeatureService)con.CreateService(MgServiceType.FeatureService);

        MgLayerCollection colLayers = map.GetLayers();

The last line gives the following exception:

OSGeo.MapGuide.MgInvalidOperationException: The requested operation is invalid. 
- MgMapBase.GetLayers line 117 file 
c:\build_bond_area\mapguide_open_source_v1.2\build_13.7\mgdev\common\platformbase\MapLayer/MapBase.cpp 
- MgMap.UnpackLayersAndGroups line 640 file 
c:\build_bond_area\mapguide_open_source_v1.2\build_13.7\mgdev\common\mapguidecommon\MapLayer/Map.cpp 
--- End of inner exception stack trace ---

Change History

05/25/07 08:49:59 changed by ksgeograf

  • severity changed from major to minor.

changing a few lines fixes the problem:

from

MgResourceIdentifier mapID = new MgResourceIdentifier("Session:" + sessionID + "//" + mapName + "." + MgResourceType.Map);
MgMap map = new MgMap();
map.Open(rs, mapID);

to

MgMap map = new MgMap(con);
map.Open(mapName);

Perhaps the "old" way of opening a runtime map should just be removed?

05/28/07 12:59:51 changed by trevorwekel

It's good that a workaround is available but the "old" way of opening a map should still work. The intent was to leave the existing API intact and deprecate it in the next release. This bug breaks existing scripts and should be investigated and fixed it possible.

05/29/07 09:48:37 changed by ksgeograf

I tested some more, and it seems that opening the map with the following code:

MgMap map = new MgMap();
map.Open(rs, new ResourceIdentifier(...));

will cause the mentioned exception, when calling GetLayers?()

Using this code instead:

MgMap map = new MgMap();
map.Open(rs, "Map1");

Will not cause the exception. This is the reason everything works fine with the .Net viewer. So, some problem exists in reading/unpacking layers from a map that was opened, using a resource identifier.

05/29/07 11:19:01 changed by ksgeograf

It appears that the exception is caused by the map not having the associated ResourceService?, even though the map was opened with that.

As far as I can see, the call bypasses the MgMap::Open, and calls MgResource::Open directly. This makes the the map miss the call to InitializeResourceService?(resourceService). Not sure how to fix it though. Would it be sufficient to add the method to MgMap?? Would that be picked up by SWIG?

05/29/07 17:41:20 changed by rexszeto

  • external_id set to 939563.

05/31/07 23:35:51 changed by tomfukushima

  • milestone changed from 1.2 to 1.3.

02/28/08 23:00:22 changed by tomfukushima

  • milestone deleted.

03/20/08 16:52:18 changed by tomfukushima

  • owner set to trevorwekel.