[mapguide-users] RenderMap and map state as regards current extent

Chris Claydon chris.claydon at autodesk.com
Wed Mar 18 10:26:37 EDT 2009


When you call MgEnvelope env = Map.GetDataExtent() at the end of this code, do you get the extent you're looking for? If so, you may be able to call Save() on the MgMap object to store the extents in the map resource for the session.

-----Original Message-----
From: mapguide-users-bounces at lists.osgeo.org [mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of TravisBrannon
Sent: Wednesday, March 18, 2009 6:45 AM
To: mapguide-users at lists.osgeo.org
Subject: [mapguide-users] RenderMap and map state as regards current extent


Hi folks,

I am using the RenderingService to generate a map based upon a center point
and a scale, yada yada yada.  I am wondering if after I call RenderMap,
passing in all required parameters (map object included), when I call
GetDataExtent on the Map will the returned extent reflect the extent of the
generated raster map image?   In other words is the state of the current
extent preserved for the life of the Map object after a call to RenderMap or
is it simply a one off?

Code is below (and thanks in advance):

public static MgByteReader GenerateMapByteReader(MgRenderingService
RenderingService, MgMap Map, MgEnvelope Envelope, int Width, int Height,
Color BaseColor, string ImageFormat)
        {
            MgGeometryFactory factory = new MgGeometryFactory();
            double upperRightX = Envelope.UpperRightCoordinate.GetX();
            double lowerLeftX = Envelope.LowerLeftCoordinate.GetX();
            double upperRightY = Envelope.UpperRightCoordinate.GetY();
            double lowerLeftY = Envelope.LowerLeftCoordinate.GetY();
            double x = lowerLeftX + (Math.Abs(upperRightX - lowerLeftX) /
2);
            double y = upperRightY - (Math.Abs(upperRightY - lowerLeftY) /
2);
            MgCoordinate center = factory.CreateCoordinateXY(x, y);
            MgCoordinateSystemFactory csFactory = new
MgCoordinateSystemFactory();
            MgCoordinateSystem cs = csFactory.Create(Map.GetMapSRS());
            double metersPerUnit =
cs.ConvertCoordinateSystemUnitsToMeters(1.0);
            double metersPerPixel = 0.0254 / 96;
            double scale = 0.0;
            if (Height * (upperRightX - lowerLeftX) > Width * (upperRightY -
lowerLeftY))
            {
                scale = ((upperRightX - lowerLeftX)) * metersPerUnit / Width
* metersPerPixel;
            }
            else
            {
                scale = ((upperRightY - lowerLeftY) * metersPerUnit) /
(Height * metersPerPixel);
            }
            MgByteReader mapReader = RenderingService.RenderMap(Map, null,
center, scale, Width, Height, BaseColor, ImageFormat);
            /* Question relates to this line */
            MgEnvelope env = Map.GetDataExtent();
           
            return mapReader;
}



-- 
View this message in context: http://n2.nabble.com/RenderMap-and-map-state-as-regards-current-extent-tp2496957p2496957.html
Sent from the MapGuide Users mailing list archive at Nabble.com.

_______________________________________________
mapguide-users mailing list
mapguide-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapguide-users


More information about the mapguide-users mailing list