ftp.nice.ch/Attic/openStep/developer/resources/MiscKit.2.0.5.s.gnutar.gz#/MiscKit2/Frameworks/MiscFoundation/MiscGIS.subproj/MiscZoneUTMCoord.m

This is MiscZoneUTMCoord.m in view mode; [Download] [Up]

/*=========================== MiscZoneUTMCoord.m ============================*/
/* MiscZoneUTMCoord class contains and supports values representing locations
   in any zone of the world wide Universal Transverse Mercator coordinate
   system. Constants are from:

	Ordinance Survey Information
	Transverse Mercator Projection
	Constants, Formulae and Methods
	March 1983

  Zones are 6 degrees apart starting at 3 degrees east of Longitude 180 and
  proceeding East. Greenwich is bracketed by Zone 30 and 31.
  Zone Numbering starts from 1 and ends at 60.

   DMA Release 0.8, Copyright @1993 by Genesis Project, Ltd. All Rights
   Reserved. For further information on terms and conditions see:
		Documentation/GISKit/Agreements-Legal-README

HISTORY
26-Mar-93  Dale Amon at GPL
	   Created.
*/

#import <MiscFoundation/MiscZoneUTMCoord.h>
#import "_MiscError.h"

@implementation MiscZoneUTMCoord

static id gridZones[60];

/*===========================================================================*/
/* Class methods */
/*===========================================================================*/
/* Initialize the class */

+ (void)initialize {[MiscZoneUTMCoord setVersion:MISC_ZONE_COORD_VERSION_ID]; return;}


/*===========================================================================*/
/* Initialization methods. If we don't already have a UTM constants object
   for the specified zone, create one instance that all will share and that
   cannot be deleted.

   Zone's are 1-60. Zone 0 will be treated as Zone 1. A zone greater than
   60 will be set to Zone 60.
*/
/*===========================================================================*/
/* internal method for setting up the constants from the zone */

+ (unsigned int) makeZone: (unsigned int) utmzone
  {  double	longitude;
     char	buf[20];

     if (utmzone == 0) utmzone++;
     else if (utmzone > 60) utmzone = 60;

     if (!gridZones[utmzone])
	{
	 longitude = 6.0 * (double) utmzone - 3.0 - 180.0;
	 sprintf(buf,"UTM Zone %2u",utmzone);
	 gridZones[utmzone] = [[MiscUTMConstants allocWithZone:[self zone]]
		       initGridName: [NSString stringWithCString:buf]
			 trueOrigin: 0.0 : longitude
			     inGrid: 500000.0    : 0.0
			   onSphere: 6378388.000 : 6356911.946
	     centralMeridianScaling: 0.9996];
	 [gridZones[utmzone] setProtected];
	}

     return utmzone;
  }


/*---------------------------------------------------------------------------*/
/* DESIGNATED INITIALIZER */

-initDescription: (NSString *) txt zone: (unsigned int) utmzone
 {
	zoneNumber = [MiscZoneUTMCoord makeZone: utmzone];
	return [super initDescription: txt constants: gridZones[utmzone]];
 }


/*---------------------------------------------------------------------------*/
/* Block the designated initializer of our parent class */

-initDescription: (NSString *) txt constants: anObject
{	MISC_ERROR_BAIL;
	return self;
 }


/*===========================================================================*/
/* Archive methods */
/*===========================================================================*/
- (void)encodeWithCoder:(NSCoder *)aCoder
  {	[super encodeWithCoder:aCoder];
	[aCoder encodeValueOfObjCType:"i" at:(int*)&zoneNumber];
}

/*---------------------------------------------------------------------------*/
- (id)initWithCoder:(NSCoder *)aDecoder
{	self = [super initWithCoder:aDecoder];
	[aDecoder decodeValueOfObjCType:"i" at:(int*)&zoneNumber];
        [constants setUnprotected];
        [constants release];
        [MiscZoneUTMCoord makeZone: zoneNumber];
	return self;
  }

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.