Opened 17 years ago

Closed 15 years ago

#173 closed defect (wontfix)

.Net API for MapGuide 1.2 Beta2 cannot access layers

Reported by: ksgeograf Owned by: 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 (10)

comment:1 by ksgeograf, 17 years ago

Severity: majorminor

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?

comment:2 by trevorwekel, 17 years ago

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.

comment:3 by ksgeograf, 17 years ago

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.

comment:4 by ksgeograf, 17 years ago

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?

comment:5 by rexszeto, 17 years ago

External ID: 939563

comment:6 by tomfukushima, 17 years ago

Milestone: 1.21.3

comment:7 by tomfukushima, 17 years ago

Milestone: 2.0

comment:8 by tomfukushima, 17 years ago

Owner: set to trevorwekel

comment:9 by jbirch, 16 years ago

Has this been addressed? If not, is it worth addressing a deprecated method that does not work?

comment:10 by jbirch, 15 years ago

Resolution: wontfix
Status: newclosed

Old ticket; closing. If still a concern, please retest at version 2.1 and re-open.

Note: See TracTickets for help on using tickets.