ftp.nice.ch/pub/next/developer/resources/classes/misckit/MiscKit.1.10.0.s.gnutar.gz#/MiscKit/Source/MiscGISKit/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 <misckit/miscgiskit.h>

@implementation MiscZoneUTMCoord

static id gridZones[60];

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

+ initialize {[MiscZoneUTMCoord setVersion:MISC_ZONE_COORD_VERSION_ID]; return self;}


/*===========================================================================*/
/* 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 allocFromZone: [self zone]]
		       initGridName: 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: (char *) 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: (char *) txt constants: anObject
 {	[self error:"  %s class should not be sent '%s' messages\n",
            [[self class] name], sel_getName(_cmd)];
	return self;
 }


/*===========================================================================*/
/* Archive methods */
/*===========================================================================*/
- write: (NXTypedStream *) stream
  {	[super write: stream];
	NXWriteType(stream, "i",(int*)&zoneNumber);
	return self;
  }

/*---------------------------------------------------------------------------*/
- read: (NXTypedStream *) stream
  {	[super read: stream];
	NXReadType(stream, "i",(int*)&zoneNumber);
	return self;
  }


/*---------------------------------------------------------------------------*/
- awake
{	[super awake];
	[constants setUnprotected];
	[constants free];
	[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.