/* * This file is part of the UCB release of Plan 9. It is subject to the license * terms in the LICENSE file found in the top-level directory of this * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No * part of the UCB release of Plan 9, including this file, may be copied, * modified, propagated, or distributed except according to the terms contained * in the LICENSE file. */#include <u.h>#include <libc.h>#include "map.h"static struct coord stdp0, stdp1;static double k;static intXlambert(struct place *place, double *x, double *y){ double r; if(place->nlat.l < -80.*RAD) return(-1); if(place->nlat.l > 89.*RAD) r = 0; /* slovenly */ else r = stdp0.c*exp(0.5*k*log( (1+stdp0.s)*(1-place->nlat.s)/((1-stdp0.s)*(1+place->nlat.s)))); if(stdp1.l<0.) r = -r; *x = - r*sin(k * place->wlon.l); *y = - r*cos(k * place->wlon.l); return(1);}projlambert(double par0, double par1){ double temp; if(fabs(par0)>fabs(par1)){ temp = par0; par0 = par1; par1 = temp; } deg2rad(par0, &stdp0); deg2rad(par1, &stdp1); if(fabs(par1+par0)<.1) return(mercator()); if(fabs(par1-par0)<.1) return(perspective(-1.)); if(fabs(par0)>89.5||fabs(par1)>89.5) return(0); k = 2*log(stdp1.c/stdp0.c)/log( (1+stdp0.s)*(1-stdp1.s)/((1-stdp0.s)*(1+stdp1.s))); return(Xlambert);}
/*
* This file is part of the UCB release of Plan 9. It is subject to the license
* terms in the LICENSE file found in the top-level directory of this
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
* part of the UCB release of Plan 9, including this file, may be copied,
* modified, propagated, or distributed except according to the terms contained
* in the LICENSE file.
*/
#include <u.h>
#include <libc.h>
#include "map.h"
static struct coord stdp0, stdp1;
static double k;
static int
Xlambert(struct place *place, double *x, double *y)
{
double r;
if(place->nlat.l < -80.*RAD)
return(-1);
if(place->nlat.l > 89.*RAD)
r = 0; /* slovenly */
else
r = stdp0.c*exp(0.5*k*log(
(1+stdp0.s)*(1-place->nlat.s)/((1-stdp0.s)*(1+place->nlat.s))));
if(stdp1.l<0.)
r = -r;
*x = - r*sin(k * place->wlon.l);
*y = - r*cos(k * place->wlon.l);
return(1);
}
proj
lambert(double par0, double par1)
{
double temp;
if(fabs(par0)>fabs(par1)){
temp = par0;
par0 = par1;
par1 = temp;
}
deg2rad(par0, &stdp0);
deg2rad(par1, &stdp1);
if(fabs(par1+par0)<.1)
return(mercator());
if(fabs(par1-par0)<.1)
return(perspective(-1.));
if(fabs(par0)>89.5||fabs(par1)>89.5)
return(0);
k = 2*log(stdp1.c/stdp0.c)/log(
(1+stdp0.s)*(1-stdp1.s)/((1-stdp0.s)*(1+stdp1.s)));
return(Xlambert);
}