Example #1
0
 public static int GTIFKeyGet(GTIF gtif, geokey_t thekey, out geodeticdatum_t val, int index, int count)
 {
     // ignore count
     val = 0;
     ushort[] vals;
     if (GTIFKeyGet(gtif, thekey, out vals, index, 1) == 0)
     {
         return(0);
     }
     val = (geodeticdatum_t)vals[0];
     return(1);
 }
		//**********************************************************************
		//							GTIFGetDatumInfo()
		//
		//		Fetch the ellipsoid, and name for a datum.
		//**********************************************************************
		public static bool GTIFGetDatumInfo(geodeticdatum_t datumCode, out string name, out ellipsoid_t ellipsoid)
		{
			name=null;
			ellipsoid=(ellipsoid_t)KvUserDefined;

			// --------------------------------------------------------------------
			//		Handle a few built-in datums.
			// --------------------------------------------------------------------
			if(datumCode==geodeticdatum_t.Datum_North_American_Datum_1927)
			{
				ellipsoid=ellipsoid_t.Ellipse_Clarke_1866;
				name="North American Datum 1927";
			}
			else if(datumCode==geodeticdatum_t.Datum_North_American_Datum_1983)
			{
				ellipsoid=ellipsoid_t.Ellipse_GRS_1980;
				name="North American Datum 1983";
			}
			else if(datumCode==geodeticdatum_t.Datum_WGS84)
			{
				ellipsoid=ellipsoid_t.Ellipse_WGS_84;
				name="World Geodetic System 1984";
			}
			else if(datumCode==geodeticdatum_t.Datum_WGS72)
			{
				ellipsoid=(ellipsoid_t)7043; // WGS7
				name="World Geodetic System 1972";
			}

			if(name!=null) return true;

			string pszFilename=CSVFilename("datum.csv");

			// --------------------------------------------------------------------
			//		If we can't find datum.csv then gdal_datum.csv is an
			//		acceptable fallback. Mostly this is for GDAL.
			// --------------------------------------------------------------------
			if(!File.Exists(pszFilename))
				if(File.Exists(CSVFilename("gdal_datum.csv")))
					pszFilename=CSVFilename("gdal_datum.csv");

			// --------------------------------------------------------------------
			//		Search the database for the corresponding datum code.
			// --------------------------------------------------------------------
			ellipsoid=(ellipsoid_t)atoi(CSVGetField(pszFilename, "DATUM_CODE", ((int)datumCode).ToString(),
				CSVCompareCriteria.CC_Integer, "ELLIPSOID_CODE"));

			// --------------------------------------------------------------------
			//		Get the name
			// --------------------------------------------------------------------
			name=CSVGetField(pszFilename, "DATUM_CODE", ((int)datumCode).ToString(),
				CSVCompareCriteria.CC_Integer, "DATUM_NAME");

			return true;
		}
		//**********************************************************************
		//							GTIFGetGCSInfo()
		//
		//		Fetch the datum, and prime meridian related to a particular GCS.
		//**********************************************************************
		public static bool GTIFGetGCSInfo(geographic_t GCSCode, out string name, out geodeticdatum_t datum,
			out primemeridian_t pm, out geounits_t UOMAngle)
		{
			name=null;
			datum=(geodeticdatum_t)KvUserDefined;

			// --------------------------------------------------------------------
			//		Handle some "well known" GCS codes directly.
			// --------------------------------------------------------------------
			pm=primemeridian_t.PM_Greenwich;
			UOMAngle=geounits_t.Angular_DMS_Hemisphere;
			if(GCSCode==geographic_t.GCS_NAD27)
			{
				datum=geodeticdatum_t.Datum_North_American_Datum_1927;
				name="NAD27";
				return true;
			}
			else if(GCSCode==geographic_t.GCS_NAD83)
			{
				datum=geodeticdatum_t.Datum_North_American_Datum_1983;
				name="NAD83";
				return true;
			}
			else if(GCSCode==geographic_t.GCS_WGS_84)
			{
				datum=geodeticdatum_t.Datum_WGS84;
				name="WGS 84";
				return true;
			}
			else if(GCSCode==geographic_t.GCS_WGS_72)
			{
				datum=geodeticdatum_t.Datum_WGS72;
				name="WGS 72";
				return true;
			}
			else if(GCSCode==(geographic_t)KvUserDefined) return false;

			// --------------------------------------------------------------------
			//		Search the database for the corresponding datum code.
			// --------------------------------------------------------------------
			string filename=CSVFilename("gcs.override.csv");
			datum=(geodeticdatum_t)atoi(CSVGetField(filename, "COORD_REF_SYS_CODE", ((int)GCSCode).ToString(),
				CSVCompareCriteria.CC_Integer, "DATUM_CODE"));

			if((int)datum<1)
			{
				filename=CSVFilename("gcs.csv");
				datum=(geodeticdatum_t)atoi(CSVGetField(filename, "COORD_REF_SYS_CODE", ((int)GCSCode).ToString(),
					CSVCompareCriteria.CC_Integer, "DATUM_CODE"));
			}

			if((int)datum<1) return false;

			pm=(primemeridian_t)KvUserDefined;
			UOMAngle=(geounits_t)KvUserDefined;
			name=null;

			// --------------------------------------------------------------------
			//		Get the PM.
			// --------------------------------------------------------------------
			pm=(primemeridian_t)atoi(CSVGetField(filename, "COORD_REF_SYS_CODE", ((int)GCSCode).ToString(),
				CSVCompareCriteria.CC_Integer, "PRIME_MERIDIAN_CODE"));
			if((int)pm<1) return false;

			// --------------------------------------------------------------------
			//		Get the angular units.
			// --------------------------------------------------------------------
			UOMAngle=(geounits_t)atoi(CSVGetField(filename, "COORD_REF_SYS_CODE", ((int)GCSCode).ToString(),
				CSVCompareCriteria.CC_Integer, "UOM_CODE"));
			if((int)UOMAngle<1) return false;

			// --------------------------------------------------------------------
			//		Get the name.
			// --------------------------------------------------------------------
			name=CSVGetField(filename, "COORD_REF_SYS_CODE", ((int)GCSCode).ToString(), CSVCompareCriteria.CC_Integer,
				"COORD_REF_SYS_NAME");

			return true;
		}
Example #4
0
 // This function writes a geokey_t value to a GeoTIFF file.
 //
 // @param gtif The geotiff information handle from GTIFNew().
 //
 // @param keyID The geokey_t name (such as ProjectedCSTypeGeoKey).
 // This must come from the list of legal geokey_t values
 // (an enumeration) listed below.
 //
 // Note that key values aren't actually flushed to the file until
 // GTIFWriteKeys() is called. Till then
 // the new values are just kept with the GTIF structure.
 //
 // Example:
 //
 //	GTIFKeySet(gtif, GTRasterTypeGeoKey, RasterPixelIsArea);
 //	GTIFKeySet(gtif, GTCitationGeoKey, "UTM 11 North / NAD27");
 public static bool GTIFKeySet(GTIF gtif, geokey_t keyID, geodeticdatum_t val)
 {
     ushort[] val1 = new ushort[] { (ushort)val };
     return(GTIFKeySet(gtif, keyID, val1));
 }
Example #5
0
 public static int GTIFKeyGet(GTIF gtif, geokey_t thekey, out geodeticdatum_t val, int index)
 {
     return(GTIFKeyGet(gtif, thekey, out val, index, 0));
 }
Example #6
0
		// This function writes a geokey_t value to a GeoTIFF file.
		//
		// @param gtif The geotiff information handle from GTIFNew().
		//
		// @param keyID The geokey_t name (such as ProjectedCSTypeGeoKey).
		// This must come from the list of legal geokey_t values
		// (an enumeration) listed below.
		//
		// Note that key values aren't actually flushed to the file until
		// GTIFWriteKeys() is called. Till then
		// the new values are just kept with the GTIF structure.
		//
		// Example:
		//
		//	GTIFKeySet(gtif, GTRasterTypeGeoKey, RasterPixelIsArea);
		//	GTIFKeySet(gtif, GTCitationGeoKey, "UTM 11 North / NAD27");
		public static bool GTIFKeySet(GTIF gtif, geokey_t keyID, geodeticdatum_t val)
		{
			ushort[] val1=new ushort[] { (ushort)val };
			return GTIFKeySet(gtif, keyID, val1);
		}
Example #7
0
		public static int GTIFKeyGet(GTIF gtif, geokey_t thekey, out geodeticdatum_t val, int index)
		{
			return GTIFKeyGet(gtif, thekey, out val, index, 0);
		}
Example #8
0
		public static int GTIFKeyGet(GTIF gtif, geokey_t thekey, out geodeticdatum_t val, int index, int count)
		{
			// ignore count
			val=0;
			ushort[] vals;
			if(GTIFKeyGet(gtif, thekey, out vals, index, 1)==0) return 0;
			val=(geodeticdatum_t)vals[0];
			return 1;
		}