[OSGeo-Discuss] [mapserver-dev] [discuss] featurereader, tileservice, map.open() problem

Áron Deák deakaron at gmail.com
Tue Mar 11 09:20:14 PDT 2008


Hello everybody,

I am new to mapguide. I am writing a java thick client map application using
MapGuide Open Source as map server. I query images from the map server, this
part works pretty well, not  fast enought tough.

My problem is that I also need to be able to read the feature data in order
to be able to provide some simplified geocoding service as well, but I can't
get the feature reader to work, I also need the tile service because
rendering images takes a lot of time and even implementing tile caching in
the program is not enough, so I would like to use MapGuide's tile service as
well reading tile data through  MgByteReader in a similar way as reading
arbitrary sized images.

I have problem running even the simplest sample codes, eg. map.Open()
function throws an exception so I have to use map.Create() to open a map and
I am thinking that this might be the root of my problems.

Here is how my code works: (simplified) I have followed instruction from the
GettingStartedGuide.pdf to the letter when installing the MapGuide server

try {
            MapGuideJavaApi.MgInitializeWebTier("C:\\webconfig.ini");
            MgUserInformation userInfo = new MgUserInformation("Anonymous",
"");
            mapDefid = new MgResourceIdentifier(
            "Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition");
            MgSite site = new MgSite();
            site.Open(userInfo);
            String sessionId = site.CreateSession();
            site.Close();
            MgSiteConnection siteConnection = new MgSiteConnection();
            siteConnection.Open(userInfo);
            MgResourceService service = (MgResourceService) siteConnection
                    .CreateService(MgServiceType.ResourceService);
            MgMap map;
            map = new MgMap();
            MgRenderingService renderingService = (MgRenderingService)
siteConnection
                    .CreateService(MgServiceType.RenderingService);
            MgFeatureService featureService = (MgFeatureService)
siteConnection
                    .CreateService(MgServiceType.FeatureService);
            MgTileService tileService = (MgTileService) siteConnection
                    .CreateService(MgServiceType.TileService);
            MgResourceService resourceService = (MgResourceService)
siteConnection
                    .CreateService(MgServiceType.ResourceService);
            map.Create(resourceService, mapDefid, "MyMap");
            /**
             * Opening map throws exception
             */
    //        map.Open(resourceService, "Sheboygan");
            MgResourceIdentifier districtsId = new MgResourceIdentifier(

"Library://Samples/Sheboygan/Data/VotingDistricts.FeatureSource");
            /**
             * Selecting features throws exception
             */
//            featureService.SelectFeatures(districtsId, "VotingDistricts",
//                     new MgFeatureQueryOptions(), "Sheboygan");
            /**
             * Reading a certain area of the map as an image file stream
works fine
             */
            MgByteReader reader = this.mapGuideResourceManager
            .getRenderingService().RenderMap(map,
                    this.mapGuideResourceManager.getSelection(), env,
                    (int) renderSpec.getImageSize().getWidth(),
                    (int) renderSpec.getImageSize().getHeight(),
                    new MgColor((short) 0, (short) 0, (short) 0xff),
                    "JPG");
        } catch (MgException ex) {
            ex.printStackTrace();
        }

Any help or ideas would be appreciated, now I am stuck with the development
because of these problems.

Thanks,

aron deak
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/discuss/attachments/20080311/419c62e3/attachment-0002.html>


More information about the Discuss mailing list