private MgByteReader Plot(MapGuideViewerInputModel input, bool useLayout, double?scale) { MgSiteConnection conn = CreateConnection(input); MgMap map = new MgMap(conn); map.Open(input.MapName); MgPoint center = map.ViewCenter; MgCoordinate coord = center.Coordinate; MgMappingService mappingService = (MgMappingService)conn.CreateService(MgServiceType.MappingService); MgDwfVersion dwfVersion = new MgDwfVersion("6.01", "1.2"); MgPlotSpecification plotSpec = new MgPlotSpecification(8.5f, 11f, MgPageUnitsType.Inches, 0f, 0f, 0f, 0f); plotSpec.SetMargins(0.5f, 0.5f, 0.5f, 0.5f); MgLayout layout = null; if (useLayout) { MgResourceIdentifier layoutRes = new MgResourceIdentifier("Library://Samples/Sheboygan/Layouts/SheboyganMap.PrintLayout"); layout = new MgLayout(layoutRes, "City of Sheboygan", MgPageUnitsType.Inches); } if (!scale.HasValue) { return(mappingService.GeneratePlot(map, plotSpec, layout, dwfVersion)); } else { MgCoordinate mapCenter = map.GetViewCenter().GetCoordinate(); return(mappingService.GeneratePlot(map, mapCenter, scale.Value, plotSpec, layout, dwfVersion)); } }
private MgByteReader Plot(MapGuideViewerInputModel input, bool useLayout, double? scale) { MgSiteConnection conn = CreateConnection(input); MgMap map = new MgMap(conn); map.Open(input.MapName); MgPoint center = map.ViewCenter; MgCoordinate coord = center.Coordinate; MgMappingService mappingService = (MgMappingService)conn.CreateService(MgServiceType.MappingService); MgDwfVersion dwfVersion = new MgDwfVersion("6.01", "1.2"); MgPlotSpecification plotSpec = new MgPlotSpecification(8.5f, 11f, MgPageUnitsType.Inches, 0f, 0f, 0f, 0f); plotSpec.SetMargins(0.5f, 0.5f, 0.5f, 0.5f); MgLayout layout = null; if (useLayout) { MgResourceIdentifier layoutRes = new MgResourceIdentifier("Library://Samples/Sheboygan/Layouts/SheboyganMap.PrintLayout"); layout = new MgLayout(layoutRes, "City of Sheboygan", MgPageUnitsType.Inches); } if (!scale.HasValue) { return mappingService.GeneratePlot(map, plotSpec, layout, dwfVersion); } else { MgCoordinate mapCenter = map.GetViewCenter().GetCoordinate(); return mappingService.GeneratePlot(map, mapCenter, scale.Value, plotSpec, layout, dwfVersion); } }
public void Execute(IPlatformFactory factory, ITestLogger logger) { string coordsys = "GEOGCS[\"LL84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]"; MgEnvelope env = new MgEnvelope(10, 10, 20, 20); MgMap map1 = (MgMap)factory.CreateMap(coordsys, env, "map1"); MgMap map2 = (MgMap)factory.CreateMap(coordsys, env, "map2"); MgMap map3 = (MgMap)factory.CreateMap(coordsys, env, "map3"); MgPlotSpecification spec = new MgPlotSpecification((float)8.0, (float)11.0, "in", (float)0.0, (float)0.0, (float)5.0, (float)5.0); MgResourceIdentifier resId = new MgResourceIdentifier("Library://test.WebLayout"); MgLayout layout1 = new MgLayout(resId, "Title1", "in"); MgMapPlot plot1 = new MgMapPlot(map1, spec, layout1); MgLayout layout2 = new MgLayout(resId, "Title2", "in"); MgMapPlot plot2 = new MgMapPlot(map2, spec, layout2); MgLayout layout3 = new MgLayout(resId, "Title3", "in"); MgMapPlot plot3 = new MgMapPlot(map3, spec, layout3); MgMapPlotCollection coll = new MgMapPlotCollection(); coll.Add(plot1); coll.Add(plot2); coll.Remove(plot1); Assert.AreEqual(1, coll.Count); coll.Insert(0, plot1); coll.Insert(2, plot3); MgMapPlot tmp = coll[2]; coll[2] = tmp; Assert.AreEqual(3, coll.Count); string txt = ""; foreach (MgMapPlot plot in coll) { txt += "[" + plot.GetLayout().GetTitle() + "]"; } Assert.AreEqual("[Title1][Title2][Title3]", txt); }
//---------------------------------------------------------------------------------------- // �� �ܣ� ����ͼ���ΪDWF�ļ� // // �� �ߣ� // // // �� �ڣ�2007.05.# // //----------------------------------------------------------------------------------------- public bool PlotMap() { // ��ȡ��Դ����͵�ͼ������� MgResourceService resourceService = (MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService); MgMappingService mappingService = (MgMappingService)siteConnection.CreateService(MgServiceType.MappingService); // ��ͼ MgMap map = new MgMap(); map.Open(resourceService, "Sheboygan"); // ����DWF��������Ϣ MgDwfVersion dwfVer = new MgDwfVersion("6.01", "1.2"); MgPlotSpecification plotSpec = new MgPlotSpecification(8.5f, 11.0f, MgPageUnitsType.Inches, 0f, 0f, 0f, 0f); plotSpec.SetMargins(0.5f, 0.5f, 0.5f, 0.5f); // ���DWF�ļ� MgResourceIdentifier layoutRes = new MgResourceIdentifier("Library://MgTutorial/Layouts/SheboyganMap.PrintLayout"); MgLayout layout = new MgLayout(layoutRes, " DWF�ļ�����ʾ��", MgPageUnitsType.Inches); MgByteReader byteReader = mappingService.GeneratePlot(map, plotSpec, layout, dwfVer); //�����ļ� MgByteSink byteSink = new MgByteSink(byteReader); string filePath = "C:\\Temp\\Map.DWF"; byteSink.ToFile(filePath); return true; }
public void MapPlotCollection() { string coordsys = "GEOGCS[\"LL84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]],AXIS[\"Lat\",NORTH],AXIS[\"Long\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]"; MgEnvelope env = new MgEnvelope(10,10,20,20); MgMap map1 = new MgMap(); map1.Create(coordsys, env, "map1"); MgMap map2 = new MgMap(); map2.Create(coordsys, env, "map2"); MgMap map3 = new MgMap(); map3.Create(coordsys, env, "map3"); MgPlotSpecification spec = new MgPlotSpecification((float)8.0, (float)11.0, "in", (float)0.0, (float)0.0, (float)5.0, (float)5.0); MgResourceIdentifier resId = new MgResourceIdentifier("Library://test.WebLayout"); MgLayout layout1 = new MgLayout(resId, "Title1", "in"); MgMapPlot plot1 = new MgMapPlot(map1, spec, layout1); MgLayout layout2 = new MgLayout(resId, "Title2", "in"); MgMapPlot plot2 = new MgMapPlot(map2, spec, layout2); MgLayout layout3 = new MgLayout(resId, "Title3", "in"); MgMapPlot plot3 = new MgMapPlot(map3, spec, layout3); MgMapPlotCollection coll = new MgMapPlotCollection(); coll.Add(plot1); coll.Add(plot2); coll.Remove(plot1); Assert.AreEqual(1, coll.Count); coll.Insert(0, plot1); coll.Insert(2, plot3); MgMapPlot tmp = coll[2]; coll[2] = tmp; Assert.AreEqual(3, coll.Count); string txt = ""; foreach (MgMapPlot plot in coll) { txt += "[" + plot.GetLayout().GetTitle() + "]"; } Assert.AreEqual("[Title1][Title2][Title3]", txt); }