Lambert 投影转换相关代码
最近与Lambert投影做了一段时间斗争, 从saga中扣出来一个可直接使用得方法
调用代码
double a = 6378245;// oSourceSRS.GetSemiMajor(); //oSourceSRS.getdouble f = 1.0000000000000000000 / 298.3;// oSourceSRS.GetInvFlattening();double Origin_Latitude = 0 * PI / 180;double Central_Meridian = 105* PI / 180;double Std_Parallel_1 = 30* PI / 180;double Std_Parallel_2 = 62* PI / 180;double False_Easting = 0;double False_Northing = 0;Set_Lambert_Parameters(a,f,Origin_Latitude,Central_Meridian,Std_Parallel_1,Std_Parallel_2,False_Easting,False_Northing);double Latitude = 0;double Longitude = 0;Convert_Lambert_To_Geodetic(xsaga, ysaga, &Latitude, &Longitude);double deLatitude = Latitude * 180 / PI;double deLongitude = Longitude * 180 / PI;
实现代码文件lambert_1.c
/*********************************************************** Version $Id: lambert_1.c 911 2011-02-14 16:38:15Z reklov_w $*********************************************************/
/***************************************************************************/
/* RSC IDENTIFIER: LAMBERT_1** ABSTRACT** This component provides conversions between Geodetic coordinates* (latitude and longitude in radians) and Lambert Conformal Conic* (1 parallel) projection coordinates (easting and northing in meters) defined* by one standard parallel. ** ERROR HANDLING** This component checks parameters for valid values. If an invalid value* is found the error code is combined with the current error code using* the bitwise or. This combining allows multiple error codes to be* returned. The possible error codes are:** LAMBERT_1_NO_ERROR : No errors occurred in function* LAMBERT_1_LAT_ERROR : Latitude outside of valid range* (-90 to 90 degrees)* LAMBERT_1_LON_ERROR : Longitude outside of valid range* (-180 to 360 degrees)* LAMBERT_1_EASTING_ERROR : Easting outside of valid range* (depends on ellipsoid and projection* parameters)* LAMBERT_1_NORTHING_ERROR : Northing outside of valid range* (depends on ellipsoid and projection* parameters)* LAMBERT_1_ORIGIN_LAT_ERROR : Origin latitude outside of valid* range (-89 59 59.0 to 89 59 59.0 degrees)* LAMBERT_1_CENT_MER_ERROR : Central meridian outside of valid range* (-180 to 360 degrees)* LAMBERT_1_SCALE_FACTOR_ERROR : Scale factor outside of valid* range (0.3 to 3.0)* LAMBERT_1_A_ERROR : Semi-major axis less than or equal to zero* LAMBERT_1_INV_F_ERROR : Inverse flattening outside of valid range* (250 to 350)*** REUSE NOTES** LAMBERT_1 is intended for reuse by any application that performs a Lambert* Conformal Conic (1 parallel) projection or its inverse.* * REFERENCES** Further information on LAMBERT_1 can be found in the Reuse Manual.** LAMBERT_1 originated from:* U.S. Army Topographic Engineering Center* Geospatial Information Division* 7701 Telegraph Road* Alexandria, VA 22310-3864** LICENSES** None apply to this component.** RESTRICTIONS** LAMBERT_1 has no restrictions.** ENVIRONMENT** LAMBERT_1 was tested and certified in the following environments:** 1. Solaris 2.5 with GCC, version 2.8.1* 2. Windows 98/2000 with MS Visual C++, version 6** MODIFICATIONS** Date Description* ---- -----------* 03-05-05 Original Code***//***************************************************************************/
/** INCLUDES*/#include <math.h>
#include "lambert_1.h"
/** math.h - Standard C math library* lambert_1.h - Is for prototype error checking*//***************************************************************************/
/* DEFINES**/#define PI 3.14159265358979323e0 /* PI */
#define PI_OVER_2 (PI / 2.0)
#define PI_OVER_4 (PI / 4.0)
#define MAX_LAT (( PI * 89.99972222222222) / 180.0) /* 89 59 59.0 degrees in radians */
#define TWO_PI (2.0 * PI)
#define LAMBERT_m(clat,essin) (clat / sqrt(1.0 - essin * essin))
#define LAMBERT_t(lat,essin) tan(PI_OVER_4 - lat / 2) / \pow((1.0 - essin) / (1.0 + essin), es_OVER_2)
#define ES_SIN(sinlat) (es * sinlat)
#define MIN_SCALE_FACTOR 0.3
#define MAX_SCALE_FACTOR 3.0/**************************************************************************/
/* GLOBAL DECLARATIONS**//* Ellipsoid Parameters, default to WGS 84 */
static double Lambert_1_a = 6378137.0; /* Semi-major axis of ellipsoid, in meters */
static double Lambert_1_f = 1 / 298.257223563; /* Flattening of ellipsoid */
static double es = 0.08181919084262188000; /* Eccentricity of ellipsoid */
static double es_OVER_2 = .040909595421311; /* Eccentricity / 2.0 */
static double Lambert_1_n = 0.70710678118655; /* Ratio of angle between meridians */
static double Lambert_1_rho0 = 6388838.2901212; /* Height above ellipsoid */
static double Lambert_1_rho_olat = 6388838.2901211;
static double Lambert_1_t0 = 0.41618115138974;/* Lambert_Conformal_Conic projection Parameters */
static double Lambert_1_Origin_Lat = (45 * PI / 180); /* Latitude of origin in radians */
static double Lambert_1_Origin_Long = 0.0; /* Longitude of origin, in radians */
static double Lambert_1_False_Northing = 0.0; /* False northing, in meters */
static double Lambert_1_False_Easting = 0.0; /* False easting, in meters */
static double Lambert_1_Scale_Factor = 1.0; /* Scale Factor *//* Maximum variance for easting and northing values for WGS 84. */
static double Lambert_Delta_Easting = 40000000.0;
static double Lambert_Delta_Northing = 40000000.0;/* These state variables are for optimization purposes. The only function* that should modify them is Set_Lambert_1_Parameters. *//************************************************************************/
/* FUNCTIONS**/long Set_Lambert_1_Parameters(double a,double f,double Origin_Latitude,double Central_Meridian,double False_Easting,double False_Northing,double Scale_Factor){ /* BEGIN Set_Lambert_1_Parameters */
/** The function Set_Lambert_1_Parameters receives the ellipsoid parameters and* Lambert Conformal Conic (1 parallel) projection parameters as inputs, and sets the* corresponding state variables. If any errors occur, the error code(s)* are returned by the function, otherwise LAMBERT_1_NO_ERROR is returned.** a : Semi-major axis of ellipsoid, in meters (input)* f : Flattening of ellipsoid (input)* Origin_Latitude : Latitude of origin, in radians (input)* Central_Meridian : Longitude of origin, in radians (input)* False_Easting : False easting, in meters (input)* False_Northing : False northing, in meters (input)* Scale_Factor : Projection scale factor (input) **/double es2;double es_sin;double m0;double inv_f = 1 / f;long Error_Code = LAMBERT_1_NO_ERROR;if (a <= 0.0){ /* Semi-major axis must be greater than zero */Error_Code |= LAMBERT_1_A_ERROR;}if ((inv_f < 250) || (inv_f > 350)){ /* Inverse flattening must be between 250 and 350 */Error_Code |= LAMBERT_1_INV_F_ERROR;}if (((Origin_Latitude < -MAX_LAT) || (Origin_Latitude > MAX_LAT)) ||(Origin_Latitude == 0)){ /* Origin Latitude out of range */Error_Code |= LAMBERT_1_ORIGIN_LAT_ERROR;}if ((Central_Meridian < -PI) || (Central_Meridian > TWO_PI)){ /* Origin Longitude out of range */Error_Code |= LAMBERT_1_CENT_MER_ERROR;}if ((Scale_Factor < MIN_SCALE_FACTOR) || (Scale_Factor > MAX_SCALE_FACTOR)){Error_Code |= LAMBERT_1_SCALE_FACTOR_ERROR;}if (!Error_Code){ /* no errors */Lambert_1_a = a;Lambert_1_f = f;Lambert_1_Origin_Lat = Origin_Latitude;if (Central_Meridian > PI)Central_Meridian -= TWO_PI;Lambert_1_Origin_Long = Central_Meridian;Lambert_1_False_Easting = False_Easting;Lambert_1_False_Northing = False_Northing;Lambert_1_Scale_Factor = Scale_Factor;es2 = 2.0 * Lambert_1_f - Lambert_1_f * Lambert_1_f;es = sqrt(es2);es_OVER_2 = es / 2.0;Lambert_1_n = sin(Lambert_1_Origin_Lat);es_sin = ES_SIN(sin(Lambert_1_Origin_Lat));m0 = LAMBERT_m(cos(Lambert_1_Origin_Lat), es_sin);Lambert_1_t0 = LAMBERT_t(Lambert_1_Origin_Lat, es_sin);Lambert_1_rho0 = Lambert_1_a * Lambert_1_Scale_Factor * m0 / Lambert_1_n;Lambert_1_rho_olat = Lambert_1_rho0;}return (Error_Code);
} /* END OF Set_Lambert_1_Parameters */void Get_Lambert_1_Parameters(double *a,double *f,double *Origin_Latitude,double *Central_Meridian,double *False_Easting,double *False_Northing,double *Scale_Factor){ /* BEGIN Get_Lambert_1_Parameters */
/* * The function Get_Lambert_1_Parameters returns the current ellipsoid* parameters and Lambert Conformal Conic (1 parallel) projection parameters.** a : Semi-major axis of ellipsoid, in meters (output)* f : Flattening of ellipsoid (output)* Origin_Latitude : Latitude of origin, in radians (output)* Central_Meridian : Longitude of origin, in radians (output)* False_Easting : False easting, in meters (output)* False_Northing : False northing, in meters (output)* Scale_Factor : Projection scale factor (output) */*a = Lambert_1_a;*f = Lambert_1_f;*Origin_Latitude = Lambert_1_Origin_Lat;*Central_Meridian = Lambert_1_Origin_Long;*False_Easting = Lambert_1_False_Easting;*False_Northing = Lambert_1_False_Northing;*Scale_Factor = Lambert_1_Scale_Factor;return;
} /* END OF Get_Lambert_1_Parameters */long Convert_Geodetic_To_Lambert_1 (double Latitude,double Longitude,double *Easting,double *Northing){ /* BEGIN Convert_Geodetic_To_Lambert_1 */
/** The function Convert_Geodetic_To_Lambert_1 converts Geodetic (latitude and* longitude) coordinates to Lambert Conformal Conic (1 parallel) projection (easting* and northing) coordinates, according to the current ellipsoid and* Lambert Conformal Conic (1 parallel) projection parameters. If any errors occur, the* error code(s) are returned by the function, otherwise LAMBERT_NO_ERROR is* returned.** Latitude : Latitude, in radians (input)* Longitude : Longitude, in radians (input)* Easting : Easting (X), in meters (output)* Northing : Northing (Y), in meters (output)*/double t;double rho;double dlam;double theta;long Error_Code = LAMBERT_1_NO_ERROR;if ((Latitude < -PI_OVER_2) || (Latitude > PI_OVER_2)){ /* Latitude out of range */Error_Code|= LAMBERT_1_LAT_ERROR;}if ((Longitude < -PI) || (Longitude > TWO_PI)){ /* Longitude out of range */Error_Code|= LAMBERT_1_LON_ERROR;}if (!Error_Code){ /* no errors */if (fabs(fabs(Latitude) - PI_OVER_2) > 1.0e-10){t = LAMBERT_t(Latitude, ES_SIN(sin(Latitude)));rho = Lambert_1_rho0 * pow(t / Lambert_1_t0, Lambert_1_n);}else{if ((Latitude * Lambert_1_n) <= 0){ /* Point can not be projected */Error_Code |= LAMBERT_1_LAT_ERROR;return (Error_Code);}rho = 0.0;}dlam = Longitude - Lambert_1_Origin_Long;if (dlam > PI){dlam -= TWO_PI;}if (dlam < -PI){dlam += TWO_PI;}theta = Lambert_1_n * dlam;*Easting = rho * sin(theta) + Lambert_1_False_Easting;*Northing = Lambert_1_rho_olat - rho * cos(theta) + Lambert_1_False_Northing;}return (Error_Code);
} /* END OF Convert_Geodetic_To_Lambert */long Convert_Lambert_1_To_Geodetic (double Easting,double Northing,double *Latitude,double *Longitude){ /* BEGIN Convert_Lambert_1_To_Geodetic */
/** The function Convert_Lambert_1_To_Geodetic converts Lambert Conformal* Conic (1 parallel) projection (easting and northing) coordinates to Geodetic* (latitude and longitude) coordinates, according to the current ellipsoid* and Lambert Conformal Conic (1 parallel) projection parameters. If any errors occur,* the error code(s) are returned by the function, otherwise LAMBERT_NO_ERROR* is returned.** Easting : Easting (X), in meters (input)* Northing : Northing (Y), in meters (input)* Latitude : Latitude, in radians (output)* Longitude : Longitude, in radians (output)*/double dx;double dy;double rho;double rho_olat_MINUS_dy;double t;double PHI;double es_sin;double tempPHI = 0.0;double theta = 0.0;double tolerance = 4.85e-10;int count = 30;long Error_Code = LAMBERT_1_NO_ERROR;if ((Easting < (Lambert_1_False_Easting - Lambert_Delta_Easting))||(Easting > (Lambert_1_False_Easting + Lambert_Delta_Easting))){ /* Easting out of range */Error_Code |= LAMBERT_1_EASTING_ERROR;}if ((Northing < (Lambert_1_False_Northing - Lambert_Delta_Northing))|| (Northing > (Lambert_1_False_Northing + Lambert_Delta_Northing))){ /* Northing out of range */Error_Code |= LAMBERT_1_NORTHING_ERROR;}if (!Error_Code){ /* no errors */dy = Northing - Lambert_1_False_Northing;dx = Easting - Lambert_1_False_Easting;rho_olat_MINUS_dy = Lambert_1_rho_olat - dy;rho = sqrt(dx * dx + (rho_olat_MINUS_dy) * (rho_olat_MINUS_dy));if (Lambert_1_n < 0.0){rho *= -1.0;dx *= -1.0;rho_olat_MINUS_dy *= -1.0;}if (rho != 0.0){theta = atan2(dx, rho_olat_MINUS_dy) / Lambert_1_n;t = Lambert_1_t0 * pow(rho / Lambert_1_rho0, 1 / Lambert_1_n);PHI = PI_OVER_2 - 2.0 * atan(t);while (fabs(PHI - tempPHI) > tolerance && count){tempPHI = PHI;es_sin = ES_SIN(sin(PHI));PHI = PI_OVER_2 - 2.0 * atan(t * pow((1.0 - es_sin) / (1.0 + es_sin), es_OVER_2));count --;}if(!count)return Error_Code |= LAMBERT_1_NORTHING_ERROR;*Latitude = PHI;*Longitude = theta + Lambert_1_Origin_Long;if (fabs(*Latitude) < 2.0e-7) /* force lat to 0 to avoid -0 degrees */*Latitude = 0.0;if (*Latitude > PI_OVER_2) /* force distorted values to 90, -90 degrees */*Latitude = PI_OVER_2;else if (*Latitude < -PI_OVER_2)*Latitude = -PI_OVER_2;if (*Longitude > PI){if (*Longitude - PI < 3.5e-6) *Longitude = PI;else*Longitude -= TWO_PI;}if (*Longitude < -PI){if (fabs(*Longitude + PI) < 3.5e-6)*Longitude = -PI;else*Longitude += TWO_PI;}if (fabs(*Longitude) < 2.0e-7) /* force lon to 0 to avoid -0 degrees */*Longitude = 0.0;if (*Longitude > PI) /* force distorted values to 180, -180 degrees */*Longitude = PI;else if (*Longitude < -PI)*Longitude = -PI;}else{if (Lambert_1_n > 0.0)*Latitude = PI_OVER_2;else*Latitude = -PI_OVER_2;*Longitude = Lambert_1_Origin_Long;}}return (Error_Code);
} /* END OF Convert_Lambert_1_To_Geodetic */
lambert.c
/*********************************************************** Version $Id: lambert.c 911 2011-02-14 16:38:15Z reklov_w $*********************************************************/
/***************************************************************************/
/* RSC IDENTIFIER: LAMBERT** ABSTRACT** This component provides conversions between Geodetic coordinates* (latitude and longitude in radians) and Lambert Conformal Conic* projection coordinates (easting and northing in meters) defined* by two standard parallels. When both standard parallel parameters* are set to the same latitude value, the result is a Lambert * Conformal Conic projection with one standard parallel at the * specified latitude.** ERROR HANDLING** This component checks parameters for valid values. If an invalid value* is found the error code is combined with the current error code using* the bitwise or. This combining allows multiple error codes to be* returned. The possible error codes are:** LAMBERT_NO_ERROR : No errors occurred in function* LAMBERT_LAT_ERROR : Latitude outside of valid range* (-90 to 90 degrees)* LAMBERT_LON_ERROR : Longitude outside of valid range* (-180 to 360 degrees)* LAMBERT_EASTING_ERROR : Easting outside of valid range* (depends on ellipsoid and projection* parameters)* LAMBERT_NORTHING_ERROR : Northing outside of valid range* (depends on ellipsoid and projection* parameters)* LAMBERT_FIRST_STDP_ERROR : First standard parallel outside of valid* range (-89 59 59.0 to 89 59 59.0 degrees)* LAMBERT_SECOND_STDP_ERROR : Second standard parallel outside of valid* range (-89 59 59.0 to 89 59 59.0 degrees)* LAMBERT_ORIGIN_LAT_ERROR : Origin latitude outside of valid range* (-89 59 59.0 to 89 59 59.0 degrees)* LAMBERT_CENT_MER_ERROR : Central meridian outside of valid range* (-180 to 360 degrees)* LAMBERT_A_ERROR : Semi-major axis less than or equal to zero* LAMBERT_INV_F_ERROR : Inverse flattening outside of valid range* (250 to 350)* LAMBERT_HEMISPHERE_ERROR : Standard parallels cannot be opposite latitudes* LAMBERT_FIRST_SECOND_ERROR : The 1st & 2nd standard parallels cannot* both be 0*** REUSE NOTES** LAMBERT is intended for reuse by any application that performs a Lambert* Conformal Conic projection or its inverse.* * REFERENCES** Further information on LAMBERT can be found in the Reuse Manual.** LAMBERT originated from:* U.S. Army Topographic Engineering Center* Geospatial Information Division* 7701 Telegraph Road* Alexandria, VA 22310-3864** LICENSES** None apply to this component.** RESTRICTIONS** LAMBERT has no restrictions.** ENVIRONMENT** LAMBERT was tested and certified in the following environments:** 1. Solaris 2.5 with GCC, version 2.8.1* 2. Windows 98/2000 with MS Visual C++, version 6** MODIFICATIONS** Date Description* ---- -----------* 10-02-97 Original Code* 08-15-99 Re-engineered Code* 03-05-05 Re-engineered Code***//***************************************************************************/
/** INCLUDES*/#include <math.h>
#include "lambert.h"#include "lambert_1.h"
/** math.h - Standard C math library* lambert.h - Is for prototype error checking* lambert_1.h - Is called to do conversion*//***************************************************************************/
/* DEFINES**/#define PI 3.14159265358979323e0 /* PI */
#define PI_OVER_2 (PI / 2.0)
#define PI_OVER_4 (PI / 4.0)
#define MAX_LAT (( PI * 89.99972222222222) / 180.0) /* 89 59 59.0 degrees in radians */
#define TWO_PI (2.0 * PI)
#define LAMBERT_m(clat,essin) (clat / sqrt(1.0 - essin * essin))
#define LAMBERT_t(lat,essin) tan(PI_OVER_4 - lat / 2) * \pow((1.0 + essin) / (1.0 - essin), es_OVER_2)
#define ES_SIN(sinlat) (es * sinlat)/**************************************************************************/
/* GLOBAL DECLARATIONS**//* Ellipsoid Parameters, default to WGS 84 */
static double Lambert_a = 6378137.0; /* Semi-major axis of ellipsoid, in meters */
static double Lambert_f = 1 / 298.257223563; /* Flattening of ellipsoid */
static double es = 0.081819190842621; /* Eccentricity of ellipsoid */
static double es_OVER_2 = 0.040909595421311; /* Eccentricity / 2.0 */
static double Lambert_lat0 = 0.78669154042193; /* Calculated origin latitude */
static double Lambert_k0 = 0.99620424745181; /* Calculated scale factor */
static double Lambert_false_northing = 8204.2214438468; /* Calculated false northing *//* Lambert_Conformal_Conic projection Parameters */
static double Lambert_Std_Parallel_1 = (40 * PI / 180); /* Lower std. parallel, in radians */
static double Lambert_Std_Parallel_2 = (50 * PI / 180); /* Upper std. parallel, in radians */
static double Lambert_Origin_Lat = (45 * PI / 180); /* Latitude of origin, in radians */
static double Lambert_Origin_Long = 0.0; /* Longitude of origin, in radians */
static double Lambert_False_Northing = 0.0; /* False northing, in meters */
static double Lambert_False_Easting = 0.0; /* False easting, in meters *//* Maximum variance for easting and northing values for WGS 84. */
static double Lambert_Delta_Easting = 40000000.0;
static double Lambert_Delta_Northing = 40000000.0;/* These state variables are for optimization purposes. The only function* that should modify them is Set_Lambert_Parameters. *//************************************************************************/
/* FUNCTIONS**/long Set_Lambert_Parameters(double a,double f,double Origin_Latitude,double Central_Meridian,double Std_Parallel_1,double Std_Parallel_2,double False_Easting,double False_Northing){ /* BEGIN Set_Lambert_Parameters */
/** The function Set_Lambert_Parameters receives the ellipsoid parameters and* Lambert Conformal Conic projection parameters as inputs, and sets the* corresponding state variables. If any errors occur, the error code(s)* are returned by the function, otherwise LAMBERT_NO_ERROR is returned.** a : Semi-major axis of ellipsoid, in meters (input)* f : Flattening of ellipsoid (input)* Origin_Latitude : Latitude of origin, in radians (input)* Central_Meridian : Longitude of origin, in radians (input)* Std_Parallel_1 : First standard parallel, in radians (input)* Std_Parallel_2 : Second standard parallel, in radians (input)* False_Easting : False easting, in meters (input)* False_Northing : False northing, in meters (input)** Note that when the two standard parallel parameters are both set to the * same latitude value, the result is a Lambert Conformal Conic projection * with one standard parallel at the specified latitude.*/double es2;double es_sin;double t0;double t1;double t2;double t_olat;double m0;double m1;double m2;double m_olat;double n; /* Ratio of angle between meridians */double const_value;double inv_f = 1 / f;long Error_Code = LAMBERT_NO_ERROR;if (a <= 0.0){ /* Semi-major axis must be greater than zero */Error_Code |= LAMBERT_A_ERROR;}if ((inv_f < 250) || (inv_f > 350)){ /* Inverse flattening must be between 250 and 350 */Error_Code |= LAMBERT_INV_F_ERROR;}if ((Origin_Latitude < -MAX_LAT) || (Origin_Latitude > MAX_LAT)){ /* Origin Latitude out of range */Error_Code |= LAMBERT_ORIGIN_LAT_ERROR;}if ((Std_Parallel_1 < -MAX_LAT) || (Std_Parallel_1 > MAX_LAT)){ /* First Standard Parallel out of range */Error_Code |= LAMBERT_FIRST_STDP_ERROR;}if ((Std_Parallel_2 < -MAX_LAT) || (Std_Parallel_2 > MAX_LAT)){ /* Second Standard Parallel out of range */Error_Code |= LAMBERT_SECOND_STDP_ERROR;}if ((Std_Parallel_1 == 0) && (Std_Parallel_2 == 0)){ /* First & Second Standard Parallels are both 0 */Error_Code |= LAMBERT_FIRST_SECOND_ERROR;}if (Std_Parallel_1 == -Std_Parallel_2){ /* Parallels are the negation of each other */Error_Code |= LAMBERT_HEMISPHERE_ERROR;}if ((Central_Meridian < -PI) || (Central_Meridian > TWO_PI)){ /* Origin Longitude out of range */Error_Code |= LAMBERT_CENT_MER_ERROR;}if (!Error_Code){ /* no errors */Lambert_a = a;Lambert_f = f;Lambert_Origin_Lat = Origin_Latitude;Lambert_Std_Parallel_1 = Std_Parallel_1;Lambert_Std_Parallel_2 = Std_Parallel_2;if (Central_Meridian > PI)Central_Meridian -= TWO_PI;Lambert_Origin_Long = Central_Meridian;Lambert_False_Easting = False_Easting;Lambert_False_Northing = False_Northing;if (fabs(Lambert_Std_Parallel_1 - Lambert_Std_Parallel_2) > 1.0e-10){es2 = 2 * Lambert_f - Lambert_f * Lambert_f;es = sqrt(es2);es_OVER_2 = es / 2.0;es_sin = ES_SIN(sin(Lambert_Origin_Lat));m_olat = LAMBERT_m(cos(Lambert_Origin_Lat), es_sin);t_olat = LAMBERT_t(Lambert_Origin_Lat, es_sin);es_sin = ES_SIN(sin(Lambert_Std_Parallel_1));m1 = LAMBERT_m(cos(Lambert_Std_Parallel_1), es_sin);t1 = LAMBERT_t(Lambert_Std_Parallel_1, es_sin);es_sin = ES_SIN(sin(Lambert_Std_Parallel_2));m2 = LAMBERT_m(cos(Lambert_Std_Parallel_2), es_sin);t2 = LAMBERT_t(Lambert_Std_Parallel_2, es_sin);n = log(m1 / m2) / log(t1 / t2);Lambert_lat0 = asin(n);es_sin = ES_SIN(sin(Lambert_lat0));m0 = LAMBERT_m(cos(Lambert_lat0), es_sin);t0 = LAMBERT_t(Lambert_lat0, es_sin);Lambert_k0 = (m1 / m0) * (pow(t0 / t1, n));const_value = ((Lambert_a * m2) / (n * pow(t2, n)));Lambert_false_northing = ((const_value * pow(t_olat, n)) - (const_value * pow(t0, n))) + Lambert_False_Northing;}else{Lambert_lat0 = Lambert_Std_Parallel_1;Lambert_k0 = 1.0;Lambert_false_northing = Lambert_False_Northing;}Set_Lambert_1_Parameters(Lambert_a, Lambert_f, Lambert_lat0, Lambert_Origin_Long, Lambert_False_Easting, Lambert_false_northing, Lambert_k0);}return (Error_Code);
} /* END OF Set_Lambert_Parameters */void Get_Lambert_Parameters(double *a,double *f,double *Origin_Latitude,double *Central_Meridian,double *Std_Parallel_1,double *Std_Parallel_2,double *False_Easting,double *False_Northing){ /* BEGIN Get_Lambert_Parameters */
/* * The function Get_Lambert_Parameters returns the current ellipsoid* parameters and Lambert Conformal Conic projection parameters.** a : Semi-major axis of ellipsoid, in meters (output)* f : Flattening of ellipsoid (output)* Origin_Latitude : Latitude of origin, in radians (output)* Central_Meridian : Longitude of origin, in radians (output)* Std_Parallel_1 : First standard parallel, in radians (output)* Std_Parallel_2 : Second standard parallel, in radians (output)* False_Easting : False easting, in meters (output)* False_Northing : False northing, in meters (output)*/*a = Lambert_a;*f = Lambert_f;*Std_Parallel_1 = Lambert_Std_Parallel_1;*Std_Parallel_2 = Lambert_Std_Parallel_2;*Origin_Latitude = Lambert_Origin_Lat;*Central_Meridian = Lambert_Origin_Long;*False_Easting = Lambert_False_Easting;*False_Northing = Lambert_False_Northing;return;
} /* END OF Get_Lambert_Parameters */long Convert_Geodetic_To_Lambert (double Latitude,double Longitude,double *Easting,double *Northing){ /* BEGIN Convert_Geodetic_To_Lambert */
/** The function Convert_Geodetic_To_Lambert converts Geodetic (latitude and* longitude) coordinates to Lambert Conformal Conic projection (easting* and northing) coordinates, according to the current ellipsoid and* Lambert Conformal Conic projection parameters. If any errors occur, the* error code(s) are returned by the function, otherwise LAMBERT_NO_ERROR is* returned.** Latitude : Latitude, in radians (input)* Longitude : Longitude, in radians (input)* Easting : Easting (X), in meters (output)* Northing : Northing (Y), in meters (output)*/long Error_Code = LAMBERT_NO_ERROR;if ((Latitude < -PI_OVER_2) || (Latitude > PI_OVER_2)){ /* Latitude out of range */Error_Code|= LAMBERT_LAT_ERROR;}if ((Longitude < -PI) || (Longitude > TWO_PI)){ /* Longitude out of range */Error_Code|= LAMBERT_LON_ERROR;}if (!Error_Code){ /* no errors */Set_Lambert_1_Parameters(Lambert_a, Lambert_f, Lambert_lat0, Lambert_Origin_Long, Lambert_False_Easting, Lambert_false_northing, Lambert_k0);Error_Code = Convert_Geodetic_To_Lambert_1(Latitude, Longitude, Easting, Northing);}return (Error_Code);
} /* END OF Convert_Geodetic_To_Lambert */long Convert_Lambert_To_Geodetic (double Easting,double Northing,double *Latitude,double *Longitude){ /* BEGIN Convert_Lambert_To_Geodetic */
/** The function Convert_Lambert_To_Geodetic converts Lambert Conformal* Conic projection (easting and northing) coordinates to Geodetic* (latitude and longitude) coordinates, according to the current ellipsoid* and Lambert Conformal Conic projection parameters. If any errors occur,* the error code(s) are returned by the function, otherwise LAMBERT_NO_ERROR* is returned.** Easting : Easting (X), in meters (input)* Northing : Northing (Y), in meters (input)* Latitude : Latitude, in radians (output)* Longitude : Longitude, in radians (output)*/long Error_Code = LAMBERT_NO_ERROR;if ((Easting < (Lambert_False_Easting - Lambert_Delta_Easting))||(Easting > (Lambert_False_Easting + Lambert_Delta_Easting))){ /* Easting out of range */Error_Code |= LAMBERT_EASTING_ERROR;}if ((Northing < (Lambert_false_northing - Lambert_Delta_Northing))|| (Northing > (Lambert_false_northing + Lambert_Delta_Northing))){ /* Northing out of range */Error_Code |= LAMBERT_NORTHING_ERROR;}if (!Error_Code){ /* no errors */Set_Lambert_1_Parameters(Lambert_a, Lambert_f, Lambert_lat0, Lambert_Origin_Long, Lambert_False_Easting, Lambert_false_northing, Lambert_k0);Error_Code = Convert_Lambert_1_To_Geodetic(Easting, Northing, Latitude, Longitude);}return (Error_Code);
} /* END OF Convert_Lambert_To_Geodetic */
其实就2个c文件, 直接引用工程即可
Lambert 投影转换相关代码相关推荐
- x-http-wrapper: 如何解决每次发版时,修改http相关代码造成的错误!(Android、iOS、h5)...
其实是我做了个开源工具(^__^),拿出来给大家鉴赏下,欢迎大家提意见 项目:github.com/xuyt11/x-ht- 欢迎关注和star . 功能:这是一个http相关代码的创建工具. 现在我 ...
- mysql和redis统计网站活跃度,最代码网站用户私信列表采用mysql union查询优化为Redis查询的经验和相关代码片段分享...
由于用户和私信的数据量逐渐增加,查询用户和其他用户的私信合并排重排序的sql语法给mysql带来了很大的压力,springdata jpa的hql查询语法如下:select id from (sele ...
- android 分辨率合集,Android编程之分辨率处理相关代码段合集
本文实例讲述了Android编程之分辨率处理相关代码段.分享给大家供大家参考,具体如下: 1. 通常我们所说的屏幕分辨率如800x480.960x540等.这些分辨率是可以通过代码获取到的.手机屏幕分 ...
- 【Android 安全】DEX 加密 ( Java 工具开发 | 解压 apk 文件 | 加密生成 dex 文件 | 打包未签名 apk 文件 | 文件解压缩相关代码 )
文章目录 一.解压 apk 文件 二.加密生成 dex 文件 三.打包未签名 apk 文件 四.完整代码示例 五.文件解压缩相关代码 六.执行结果 参考博客 : [Android 安全]DEX 加密 ...
- 该系列主要整理收集在使用C#开发WinForm应用文章及相关代码来源于WinForms小组...
该系列主要整理收集在使用C#开发WinForm应用文章及相关代码, 平时看到大家主要使用C#来开发Asp.Net应用,这方面的文章也特别多,而关于WinForm的文章相对少很多,而自己对WinForm ...
- html提交列表编号自动生成目录,解析 Html 自动生成目录 TOC 的相关代码
解析 Html 自动生成目录 TOC 的相关代码 相关代码function create_content_TOC(dom, config, target) { let hList = dom.find ...
- 【高校宿舍管理系统】第二章 整合Mybatis和写CRUD的基本流程以及使用代码生成器生成Mapper等相关代码
第二章 整合Mybatis和写CRUD的基本流程以及使用代码生成器生成Mapper等相关代码 提示:本博客个为人独立博客,不是权威,仅供参考!所有思路只做交流之用!如有不足之处,望各位在评论区友善指正 ...
- 图书管理系统(说明文档与相关代码)
图书信息管理系统 目录 一.设计说明 3 1.功能结构 3 2.项目架构 3 3.包及 Java 类说明 4 4.数据库设计 5 二.功能实现 5 1.登录 5 2.系统主界面 6 3.图书列表页面 ...
- 【cornerstoneTools】【vue】使用cornerstoneTools搭建标注系统相关代码
使用cornerstoneTools搭建标注系统相关代码 cornerstoneTools引入 注册cornerstoneTools工具 cornerstone 右键平移 标注工具的切换 初始化标注 ...
- react相关代码库以及框架的源码解析
持续更新中react相关库源码浅析, react ts3 项目 ???对react相关代码库以及框架的源码进行了一定的分析 ?react16.6 View contents 源码实例分析:可见runl ...
最新文章
- 如何快速实现移动端短视频功能?
- python true_True关键字,带Python示例
- StackOverFlow优选的十条编程观点
- java 数据库操作教程_数据库基本操作:增删改查及联表操作
- 银行卡掉了一定要在开户银行补吗?
- linux 中文乱码 转png_使用pdfBox实现pdf转图片,解决中文方块乱码等问题
- 7.24实习培训日志-Docker-Compose
- 【更新于2019】SCI EI 索引最新查询方法(已验证有效)
- 计算机主机号截图,电脑如何截图?截图三种方法推荐
- 从四大云计算公司走向 看云行业趋势
- 【离散数学】编程练习:求偏序集中的极大元与极小元
- 让Windows2000飞起来(转)
- 怎么清晰地理解、表达 IaaS 、 PaaS 、 SaaS ?
- ABtest系统是什么?
- 云服务器有几种类型,一般要如何选购
- Windows下 wget 的安装与使用
- 重装VS6时,弹出Setup Was Unable to Create a DCOM User Account错误的解决方法
- 软件开发人员的作战手册 - 让程序员活的久一点
- s5p4418的uboot开通网络支持
- 深富策略:A股跨年行情仍在 逢低仍是配置良机