Guest User

Untitled

a guest
Jul 16th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 KB | None | 0 0
  1. (void) PlotMap
  2. {
  3.  
  4.  
  5. NSAutoreleasePool *poolPlotMap = [[NSAutoreleasePool alloc] init];
  6.  
  7. NSGraphicsContext* gc = [NSGraphicsContext currentContext];
  8.  
  9. // Save the current graphics context settings
  10. [gc saveGraphicsState];
  11.  
  12. // Set the color in the current graphics context for future draw operations
  13. [[NSColor whiteColor] setStroke];
  14. [[NSColor greenColor] setFill];
  15.  
  16. NSBezierPath* bPath = [NSBezierPath bezierPath];
  17.  
  18. // Object Creation for Lambert
  19. CLambertConformalConicProjection *lLambert = [CLambertConformalConicProjection new];
  20. [lLambert CLambertConformalConicProjection];
  21.  
  22. int First_Index = 0;
  23. double lslat,lslong;
  24. bool binvalid_point = TRUE;
  25. double PixX, PixY,OldX, OldY;
  26. float fPakMapLineStyle[2] = {1,0};
  27. float fTempMapLineStyle[2] = {2,1};
  28.  
  29. FIRST_POINT:
  30. if (First_Index == [MapLatValues count])
  31. {
  32.  
  33.  
  34. // Exit from Method if NO Lat Long Available
  35. return ;
  36. }
  37.  
  38. // Extract Point
  39. lslat = [ [MapLatValues objectAtIndex:First_Index] doubleValue];
  40. lslong = [ [MapLongValues objectAtIndex:First_Index] doubleValue];
  41.  
  42. /* Is this point in zoom area
  43. if ( ( lslat >= GStartLat || lslat <= GEndLat ) || ( lslong <= GStartLong || lslong >= GEndLong ) )
  44. {
  45.  
  46. First_Index++;
  47. goto FIRST_POINT;
  48. }*/
  49.  
  50.  
  51.  
  52. // Convert to pixel
  53.  
  54. [lLambert getDisplayXYFromLatLong:lslat :lslong :&OldX :&OldY];
  55. //printf("nOldX : %f", lslong);
  56. // Run through the map coord array
  57.  
  58. /********************************************************************/
  59.  
  60. int mapLatLongCount = 0;
  61. int mapLatLongTotalCount = [MapLatValues count];
  62. NSPoint PakMapPointArray[mapLatLongTotalCount];
  63.  
  64. int Coord_Index;
  65. for (Coord_Index = First_Index; Coord_Index< [MapLatValues count]; Coord_Index++)
  66. {
  67.  
  68.  
  69. // Start of FOR LOOP
  70. // Extract Point
  71. lslat = [ [MapLatValues objectAtIndex:Coord_Index] doubleValue];
  72. lslong = [ [MapLongValues objectAtIndex:Coord_Index] doubleValue];
  73. //Is this point in zoom area
  74. if ( ( lslat >= GStartLat || lslat <= GEndLat ) || ( lslong <= GStartLong || lslong >= GEndLong ) )
  75. {
  76. lslat = 0;
  77. lslong = 9999;
  78. }
  79.  
  80.  
  81.  
  82. // Convert to pixel
  83. [lLambert getDisplayXYFromLatLong:lslat :lslong :&PixX :&PixY];
  84.  
  85. if ( ( floor(lslat) != 0 ) && ( floor(lslong) != 9999) )
  86. {
  87. if (binvalid_point)
  88. {
  89. PakMapPointArray[mapLatLongCount] = NSMakePoint(PixX, iMainDisplayY - PixY);
  90. binvalid_point = FALSE;
  91. mapLatLongCount++;
  92. }
  93. else
  94. {
  95.  
  96. PakMapPointArray[mapLatLongCount] = NSMakePoint(OldX, iMainDisplayY - OldY);
  97. mapLatLongCount++;
  98.  
  99. }
  100. }
  101. else
  102. {
  103. binvalid_point = TRUE;
  104. }
  105. // Make New Pixel Points the last point
  106. OldX = PixX;
  107. OldY = PixY;
  108.  
  109. //[bPath closePath];
  110. }// END of FOR LOOP
  111.  
  112.  
  113. //
  114. [bPath appendBezierPathWithPoints:PakMapPointArray count:mapLatLongCount];
  115. [bPath stroke];
  116. [bPath fill];
  117.  
  118. // Restore the context to what it was before we messed with it
  119. [gc restoreGraphicsState];
  120.  
  121. [lLambert release];
  122.  
  123.  
  124.  
  125.  
  126. [poolPlotMap release];
  127.  
  128.  
  129.  
  130. }
Add Comment
Please, Sign In to add comment