Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (void) PlotMap
- {
- NSAutoreleasePool *poolPlotMap = [[NSAutoreleasePool alloc] init];
- NSGraphicsContext* gc = [NSGraphicsContext currentContext];
- // Save the current graphics context settings
- [gc saveGraphicsState];
- // Set the color in the current graphics context for future draw operations
- [[NSColor whiteColor] setStroke];
- [[NSColor greenColor] setFill];
- NSBezierPath* bPath = [NSBezierPath bezierPath];
- // Object Creation for Lambert
- CLambertConformalConicProjection *lLambert = [CLambertConformalConicProjection new];
- [lLambert CLambertConformalConicProjection];
- int First_Index = 0;
- double lslat,lslong;
- bool binvalid_point = TRUE;
- double PixX, PixY,OldX, OldY;
- float fPakMapLineStyle[2] = {1,0};
- float fTempMapLineStyle[2] = {2,1};
- FIRST_POINT:
- if (First_Index == [MapLatValues count])
- {
- // Exit from Method if NO Lat Long Available
- return ;
- }
- // Extract Point
- lslat = [ [MapLatValues objectAtIndex:First_Index] doubleValue];
- lslong = [ [MapLongValues objectAtIndex:First_Index] doubleValue];
- /* Is this point in zoom area
- if ( ( lslat >= GStartLat || lslat <= GEndLat ) || ( lslong <= GStartLong || lslong >= GEndLong ) )
- {
- First_Index++;
- goto FIRST_POINT;
- }*/
- // Convert to pixel
- [lLambert getDisplayXYFromLatLong:lslat :lslong :&OldX :&OldY];
- //printf("nOldX : %f", lslong);
- // Run through the map coord array
- /********************************************************************/
- int mapLatLongCount = 0;
- int mapLatLongTotalCount = [MapLatValues count];
- NSPoint PakMapPointArray[mapLatLongTotalCount];
- int Coord_Index;
- for (Coord_Index = First_Index; Coord_Index< [MapLatValues count]; Coord_Index++)
- {
- // Start of FOR LOOP
- // Extract Point
- lslat = [ [MapLatValues objectAtIndex:Coord_Index] doubleValue];
- lslong = [ [MapLongValues objectAtIndex:Coord_Index] doubleValue];
- //Is this point in zoom area
- if ( ( lslat >= GStartLat || lslat <= GEndLat ) || ( lslong <= GStartLong || lslong >= GEndLong ) )
- {
- lslat = 0;
- lslong = 9999;
- }
- // Convert to pixel
- [lLambert getDisplayXYFromLatLong:lslat :lslong :&PixX :&PixY];
- if ( ( floor(lslat) != 0 ) && ( floor(lslong) != 9999) )
- {
- if (binvalid_point)
- {
- PakMapPointArray[mapLatLongCount] = NSMakePoint(PixX, iMainDisplayY - PixY);
- binvalid_point = FALSE;
- mapLatLongCount++;
- }
- else
- {
- PakMapPointArray[mapLatLongCount] = NSMakePoint(OldX, iMainDisplayY - OldY);
- mapLatLongCount++;
- }
- }
- else
- {
- binvalid_point = TRUE;
- }
- // Make New Pixel Points the last point
- OldX = PixX;
- OldY = PixY;
- //[bPath closePath];
- }// END of FOR LOOP
- //
- [bPath appendBezierPathWithPoints:PakMapPointArray count:mapLatLongCount];
- [bPath stroke];
- [bPath fill];
- // Restore the context to what it was before we messed with it
- [gc restoreGraphicsState];
- [lLambert release];
- [poolPlotMap release];
- }
Add Comment
Please, Sign In to add comment