public override Coordinate Project(double lam, double phi, Coordinate coord) { if (_spherical) { coord.X = ScaleFactor * lam; coord.Y = ScaleFactor * Math.Log(Math.Tan(ProjectionMath.PiFourth + 0.5 * phi)); } else { coord.X = ScaleFactor * lam; coord.Y = -ScaleFactor *Math.Log(ProjectionMath.tsfn(phi, Math.Sin(phi), _e)); } return(coord); }
public override Coordinate Project(double lam, double phi, Coordinate xy) { double con, q, s, ul, us, vl, vs; vl = Math.Sin(bl * lam); if (Math.Abs(Math.Abs(phi) - ProjectionMath.PiHalf) <= EPS10) { ul = phi < 0.0 ? -singam : singam; us = al * phi / bl; } else { q = el / (!Spherical ? Math.Pow(ProjectionMath.tsfn(phi, Math.Sin(phi), Eccentricity), bl) : Math.Tan(.5 * (ProjectionMath.PiHalf - phi))); s = .5 * (q - 1.0 / q); ul = 2.0 * (s * singam - vl * cosgam) / (q + 1.0 / q); con = Math.Cos(bl * lam); if (Math.Abs(con) >= Tolerance) { us = al * Math.Atan((s * cosgam + vl * singam) / con) / bl; if (con < 0.0) { us += Math.PI * al / bl; } } else { us = al * bl * lam; } } if (Math.Abs(Math.Abs(ul) - 1.0) <= EPS10) { throw new ProjectionException("Obl 3"); } vs = .5 * al * Math.Log((1.0 - ul) / (1.0 + ul)) / bl; us -= u_0; if (!rot) { xy.X = us; xy.Y = vs; } else { xy.X = vs * cosrot + us * sinrot; xy.Y = us * cosrot - vs * sinrot; } return(xy); }
public override void Initialize() { base.Initialize(); double cosphi, sinphi; Boolean secant; if (ProjectionLatitude1 == 0) { ProjectionLatitude1 = ProjectionLatitude2 = ProjectionLatitude; } if (Math.Abs(ProjectionLatitude1 + ProjectionLatitude2) < 1e-10) { throw new ProjectionException(); } n = sinphi = Math.Sin(ProjectionLatitude1); cosphi = Math.Cos(ProjectionLatitude1); secant = Math.Abs(ProjectionLatitude1 - ProjectionLatitude2) >= 1e-10; _spherical = (EccentricitySquared == 0.0); if (!Spherical) { double ml1, m1; m1 = ProjectionMath.msfn(sinphi, cosphi, EccentricitySquared); ml1 = ProjectionMath.tsfn(ProjectionLatitude1, sinphi, Eccentricity); if (secant) { n = Math.Log(m1 / ProjectionMath.msfn(sinphi = Math.Sin(ProjectionLatitude2), Math.Cos(ProjectionLatitude2), EccentricitySquared)); n /= Math.Log(ml1 / ProjectionMath.tsfn(ProjectionLatitude2, sinphi, Eccentricity)); } c = (rho0 = m1 * Math.Pow(ml1, -n) / n); rho0 *= (Math.Abs(Math.Abs(ProjectionLatitude) - ProjectionMath.PiHalf) < 1e-10) ? 0.0 : Math.Pow(ProjectionMath.tsfn(ProjectionLatitude, Math.Sin(ProjectionLatitude), Eccentricity), n); } else { if (secant) { n = Math.Log(cosphi / Math.Cos(ProjectionLatitude2)) / Math.Log(Math.Tan(ProjectionMath.PiFourth + .5 * ProjectionLatitude2) / Math.Tan(ProjectionMath.PiFourth + .5 * ProjectionLatitude1)); } c = cosphi * Math.Pow(Math.Tan(ProjectionMath.PiFourth + .5 * ProjectionLatitude1), n) / n; rho0 = (Math.Abs(Math.Abs(ProjectionLatitude) - ProjectionMath.PiHalf) < 1e-10) ? 0.0 : c *Math.Pow(Math.Tan(ProjectionMath.PiFourth + .5 * ProjectionLatitude), -n); } }
public override Coordinate Project(double x, double y, Coordinate coord) { double rho; if (Math.Abs(Math.Abs(y) - ProjectionMath.PiHalf) < 1e-10) { rho = 0.0; } else { rho = c * (Spherical ? Math.Pow(Math.Tan(ProjectionMath.PiFourth + .5 * y), -n) : Math.Pow(ProjectionMath.tsfn(y, Math.Sin(y), Eccentricity), n)); } coord.X = ScaleFactor * (rho * Math.Sin(x *= n)); coord.Y = ScaleFactor * (rho0 - rho * Math.Cos(x)); return(coord); }
public override void Initialize() { double t; base.Initialize(); if (Math.Abs((t = Math.Abs(ProjectionLatitude)) - ProjectionMath.PiHalf) < EPS10) { _mode = ProjectionLatitude < 0.0 ? AzimuthalMode.SouthPole : AzimuthalMode.NorthPole; } else { _mode = t > EPS10 ? AzimuthalMode.Oblique : AzimuthalMode.Equator; } TrueScaleLatitude = Math.Abs(TrueScaleLatitude); if (!Spherical) { double X; switch (Mode) { case AzimuthalMode.NorthPole: case AzimuthalMode.SouthPole: if (Math.Abs(TrueScaleLatitude - ProjectionMath.PiHalf) < EPS10) { _akm1 = 2.0 * ScaleFactor / Math.Sqrt(Math.Pow(1 + Eccentricity, 1 + Eccentricity) * Math.Pow(1 - Eccentricity, 1 - Eccentricity)); } else { _akm1 = Math.Cos(TrueScaleLatitude) / ProjectionMath.tsfn(TrueScaleLatitude, t = Math.Sin(TrueScaleLatitude), Eccentricity); t *= Eccentricity; _akm1 /= Math.Sqrt(1.0 - t * t); } break; case AzimuthalMode.Equator: _akm1 = 2.0 * ScaleFactor; break; case AzimuthalMode.Oblique: t = Math.Sin(ProjectionLatitude); X = 2.0 * Math.Atan(ssfn(ProjectionLatitude, t, Eccentricity)) - ProjectionMath.PiHalf; t *= Eccentricity; _akm1 = 2.0 * ScaleFactor * Math.Cos(ProjectionLatitude) / Math.Sqrt(1.0 - t * t); _sinphi0 = Math.Sin(X); _cosphi0 = Math.Cos(X); break; } } else { switch (Mode) { case AzimuthalMode.Oblique: case AzimuthalMode.Equator: if (Mode == AzimuthalMode.Oblique) { _sinphi0 = Math.Sin(ProjectionLatitude); _cosphi0 = Math.Cos(ProjectionLatitude); } _akm1 = 2.0 * ScaleFactor; break; case AzimuthalMode.SouthPole: case AzimuthalMode.NorthPole: _akm1 = Math.Abs(TrueScaleLatitude - ProjectionMath.PiHalf) >= EPS10 ? Math.Cos(TrueScaleLatitude) / Math.Tan(ProjectionMath.PiFourth - .5 * TrueScaleLatitude) : 2.0 * ScaleFactor; break; } } }
public override Coordinate Project(double lam, double phi, Coordinate xy) { double coslam = Math.Cos(lam); double sinlam = Math.Sin(lam); double sinphi = Math.Sin(phi); if (Spherical) { double cosphi = Math.Cos(phi); switch (Mode) { case AzimuthalMode.Equator: xy.Y = 1.0 + cosphi * coslam; if (xy.Y <= EPS10) { throw new ProjectionException(); } xy.X = (xy.Y = _akm1 / xy.Y) * cosphi * sinlam; xy.Y *= sinphi; break; case AzimuthalMode.Oblique: xy.Y = 1.0 + _sinphi0 * sinphi + _cosphi0 * cosphi * coslam; if (xy.Y <= EPS10) { throw new ProjectionException(); } xy.X = (xy.Y = _akm1 / xy.Y) * cosphi * sinlam; xy.Y *= _cosphi0 * sinphi - _sinphi0 * cosphi * coslam; break; case AzimuthalMode.NorthPole: case AzimuthalMode.SouthPole: if (Mode == AzimuthalMode.NorthPole) { coslam = -coslam; phi = -phi; } if (Math.Abs(phi - ProjectionMath.PiHalf) < Tolerance) { throw new ProjectionException(); } xy.X = sinlam * (xy.Y = _akm1 * Math.Tan(ProjectionMath.PiFourth + .5 * phi)); xy.Y *= coslam; break; } } else { double sinX = 0, cosX = 0, X, A; if (Mode == AzimuthalMode.Oblique || Mode == AzimuthalMode.Equator) { sinX = Math.Sin(X = 2.0 * Math.Atan(ssfn(phi, sinphi, Eccentricity)) - ProjectionMath.PiHalf); cosX = Math.Cos(X); } switch (Mode) { case AzimuthalMode.Oblique: A = _akm1 / (_cosphi0 * (1.0 + _sinphi0 * sinX + _cosphi0 * cosX * coslam)); xy.Y = A * (_cosphi0 * sinX - _sinphi0 * cosX * coslam); xy.X = A * cosX; break; case AzimuthalMode.Equator: A = 2.0 * _akm1 / (1.0 + cosX * coslam); xy.Y = A * sinX; xy.X = A * cosX; break; case AzimuthalMode.SouthPole: case AzimuthalMode.NorthPole: if (Mode == AzimuthalMode.SouthPole) { phi = -phi; coslam = -coslam; sinphi = -sinphi; } xy.X = _akm1 * ProjectionMath.tsfn(phi, sinphi, Eccentricity); xy.Y = -xy.X * coslam; break; } xy.X = xy.X * sinlam; } return(xy); }
public override void Initialize() { base.Initialize(); double con, com, cosphi0, d, f, h, l, sinphi0, p, j; //FIXME-setup rot, alpha, longc,lon/lat1/2 rot = true; lamc = _lonc; // true if alpha provided int azi = Double.IsNaN(Alpha) ? 0 : 1; if (azi != 0) { // alpha specified if (Math.Abs(Alpha) <= Tolerance || Math.Abs(Math.Abs(ProjectionLatitude) - ProjectionMath.PiHalf) <= Tolerance || Math.Abs(Math.Abs(Alpha) - ProjectionMath.PiHalf) <= Tolerance) { throw new ProjectionException("Obl 1"); } } else { if (Math.Abs(phi1 - phi2) <= Tolerance || (con = Math.Abs(phi1)) <= Tolerance || Math.Abs(con - ProjectionMath.PiHalf) <= Tolerance || Math.Abs(Math.Abs(ProjectionLatitude) - ProjectionMath.PiHalf) <= Tolerance || Math.Abs(Math.Abs(phi2) - ProjectionMath.PiHalf) <= Tolerance) { throw new ProjectionException("Obl 2"); } } com = (_spherical = (EccentricitySquared == 0.0)) ? 1 : Math.Sqrt(_oneEs); if (Math.Abs(ProjectionLatitude) > EPS10) { sinphi0 = Math.Sin(ProjectionLatitude); cosphi0 = Math.Cos(ProjectionLatitude); if (!Spherical) { con = 1.0 - EccentricitySquared * sinphi0 * sinphi0; bl = cosphi0 * cosphi0; bl = Math.Sqrt(1.0 + EccentricitySquared * bl * bl / _oneEs); al = bl * ScaleFactor * com / con; d = bl * com / (cosphi0 * Math.Sqrt(con)); } else { bl = 1.0; al = ScaleFactor; d = 1.0 / cosphi0; } if ((f = d * d - 1.0) <= 0.0) { f = 0.0; } else { f = Math.Sqrt(f); if (ProjectionLatitude < 0.0) { f = -f; } } el = f += d; if (!Spherical) { el *= Math.Pow(ProjectionMath.tsfn(ProjectionLatitude, sinphi0, Eccentricity), bl); } else { el *= Math.Tan(.5 * (ProjectionMath.PiHalf - ProjectionLatitude)); } } else { bl = 1.0 / com; al = ScaleFactor; el = d = f = 1.0; } if (azi != 0) { Gamma = Math.Asin(Math.Sin(Alpha) / d); ProjectionLongitude = lamc - Math.Asin((.5 * (f - 1.0 / f)) * Math.Tan(Gamma)) / bl; } else { if (!Spherical) { h = Math.Pow(ProjectionMath.tsfn(phi1, Math.Sin(phi1), Eccentricity), bl); l = Math.Pow(ProjectionMath.tsfn(phi2, Math.Sin(phi2), Eccentricity), bl); } else { h = Math.Tan(.5 * (ProjectionMath.PiHalf - phi1)); l = Math.Tan(.5 * (ProjectionMath.PiHalf - phi2)); } f = el / h; p = (l - h) / (l + h); j = el * el; j = (j - l * h) / (j + l * h); if ((con = lam1 - lam2) < -Math.PI) { lam2 -= ProjectionMath.TwoPI; } else if (con > Math.PI) { lam2 += ProjectionMath.TwoPI; } ProjectionLongitude = ProjectionMath.NormalizeLongitude(.5 * (lam1 + lam2) - Math.Atan( j * Math.Tan(.5 * bl * (lam1 - lam2)) / p) / bl); Gamma = Math.Atan(2.0 * Math.Sin(bl * ProjectionMath.NormalizeLongitude(lam1 - ProjectionLongitude)) / (f - 1.0 / f)); Alpha = Math.Asin(d * Math.Sin(Gamma)); } singam = Math.Sin(Gamma); cosgam = Math.Cos(Gamma); // f = MapMath.param(params, "brot_conv").i ? Gamma : alpha; f = Alpha;//FIXME sinrot = Math.Sin(f); cosrot = Math.Cos(f); // u_0 = MapMath.param(params, "bno_uoff").i ? 0. : u_0 = false ? 0.0 ://FIXME Math.Abs(al * Math.Atan(Math.Sqrt(d * d - 1.0) / cosrot) / bl); if (ProjectionLatitude < 0.0) { u_0 = -u_0; } }