[mapguide-users]TileService problem

Áron Deák deakaron at gmail.com
Tue Jul 1 07:41:09 EDT 2008


Hello everybody,

I am trying to query tiles from the sample Sheboygan map in java, at the
following line:

tileService.GetTile(mapDefid, "Tiled Layers", 1, 1, 1);

i get a org.osgeo.mapguide.MgIndexOutOfRangeException: Index is out of
range. exception.

I tend to think that the second parameter is wrong, however i cannot figure
out what to put here.

The complete code:

try {
            MgResourceIdentifier mapDefid = new MgResourceIdentifier(

"Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition");
            try {
                MapGuideJavaApi.MgInitializeWebTier("C:\\webconfig.ini");
            } catch (Exception ex) {
                ex.printStackTrace();
            }
            MgUserInformation userInfo = new MgUserInformation("Anonymous",
"");
            MgSite site = new MgSite();
            site.Open(userInfo);
            String sessionId = site.CreateSession();
            log.info(String.format("Session id: " + sessionId));
            site.Close();
            MgSiteConnection siteConnection = new MgSiteConnection();
            //MgUserInformation mgUserInformation = new
MgUserInformation(this.sessionId);
            siteConnection.Open(userInfo);
            MgResourceService service = (MgResourceService) siteConnection
                    .CreateService(MgServiceType.ResourceService);
            List<MgMap> maps = new ArrayList<MgMap>();
            MgMap map;
            maps.add(map = new MgMap());
            map.Create(service, mapDefid, "MyMap");
            MgRenderingService renderingService = (MgRenderingService)
siteConnection
                    .CreateService(MgServiceType.RenderingService);
            MgFeatureService featureService = (MgFeatureService)
siteConnection
                    .CreateService(MgServiceType.FeatureService);
            MgTileService tileService = (MgTileService) siteConnection
                    .CreateService(MgServiceType.TileService);
            int x = tileService.GetDefaultTileSizeX();
            int y = tileService.GetDefaultTileSizeY();
            log.debug(String.format("Tile size; width: %d height: %d", x,
y));
        //    this.tileService.GetTile(map, "LayersDrawn", 0, 0);
            tileService.GetTile(mapDefid, "Tiled Layers", 1, 1, 1);
            /**
             * Make all layers visible
             */
            for (int i = 0; i < map.GetLayers().GetCount(); i++) {
                MgLayerBase layer = map.GetLayers().GetItem(i);
                layer.SetVisible(true);
                log.info("Layer name: " + layer.GetName() + " was made
visible");
            }
        } catch (MgException ex) {
            log.info(ex);
        }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20080701/87490368/attachment.html


More information about the mapguide-users mailing list