Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. public static void SetAOI(IMxDocument mxd, double latitude, double longitude)
  2. {
  3. UTM = SetUTMProjection(longitude);
  4. IPoint centerpoint = new PointClass();
  5. centerpoint.SpatialReference = NAD83;
  6. centerpoint.PutCoords(longitude, latitude);
  7.  
  8. IEnvelope targetActiveViewEnv;
  9. targetActiveViewEnv = (mxd.FocusMap as IActiveView).Extent;
  10. targetActiveViewEnv.Project(NAD83);
  11. targetActiveViewEnv.CenterAt(centerpoint);
  12. (mxd.FocusMap as IActiveView).Extent = targetActiveViewEnv;
  13. mxd.FocusMap.SpatialReference = UTM;
  14. }
  15.  
  16. public static void ExportMapPage(IMxDocument mxd, MapPage mapPage, string outputPath)
  17. {
  18. IActiveView activeView = mxd.PageLayout as IActiveView;
  19. activeView.FocusMap.MapScale = mapPage.Scale; //6000
  20. mxd.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, null, activeView.Extent);
  21. string output = String.Format("{0}\{1}{2}", outputPath, "test", GetFileExtension(mapPage.FileFormat)); //PDF
  22.  
  23. IExport exporter;
  24. switch (mapPage.FileFormat) {
  25. case FileFormatEnum.JPG:
  26. exporter = new ExportJPEGClass();
  27. break;
  28. default:
  29. exporter = new ExportPDFClass();
  30. break;
  31. }
  32. exporter.ExportFileName = output;
  33. exporter.Resolution = mapPage.DPI; //300
  34.  
  35. IEnvelope pixelBox = new EnvelopeClass();
  36. double ratio = mapPage.Ratio;
  37. pixelBox.XMin = activeView.ExportFrame.left * ratio;
  38. pixelBox.XMax = activeView.ExportFrame.right * ratio;
  39. pixelBox.YMin = activeView.ExportFrame.top * ratio;
  40. pixelBox.YMax = activeView.ExportFrame.bottom * ratio;
  41.  
  42. tagRECT exporterRectangle;
  43. exporterRectangle.left = activeView.ExportFrame.left * (int)ratio;
  44. exporterRectangle.right = activeView.ExportFrame.right * (int)ratio;
  45. exporterRectangle.top = activeView.ExportFrame.top * (int)ratio;
  46. exporterRectangle.bottom = activeView.ExportFrame.bottom * (int)ratio;
  47.  
  48. exporter.PixelBounds = pixelBox;
  49. int hdc = exporter.StartExporting();
  50. activeView.Output(hdc, (int)exporter.Resolution, ref exporterRectangle, null, null);
  51. exporter.FinishExporting();
  52. exporter.Cleanup();
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement