/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { if (projInfo.IsSouth) { Y0 = 10000000; X0 = 500000; int zone; if (projInfo.Zone != null) { zone = projInfo.Zone.Value; if (zone <= 0 || zone > 60) throw new ProjectionException(35); zone -= 1; } else { zone = (int)Math.Floor((Proj.Adjlon(Lam0) + Math.PI) * 30 / Math.PI); if (zone < 0) zone = 0; if (zone >= 60) zone = 59; } Lam0 = (zone + .5) * Math.PI / 30 - Math.PI; K0 = 0.9996; Phi0 = 0; } base.OnInit(projInfo); }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { double pp; /* get control point locations */ double phi1 = projInfo.GetPhi1(); double lam1 = projInfo.GetLam1(); double phi2 = projInfo.GetPhi2(); double lam2 = projInfo.GetLam2(); if (phi1 == phi2 && lam1 == lam2) throw new ProjectionException(-25); Lam0 = Proj.Adjlon(0.5*(lam1 + lam2)); _dlam2 = Proj.Adjlon(lam2 - lam1); _cp1 = Math.Cos(phi1); _cp2 = Math.Cos(phi2); _sp1 = Math.Sin(phi1); _sp2 = Math.Sin(phi2); _cs = _cp1*_sp2; _sc = _sp1*_cp2; _ccs = _cp1*_cp2*Math.Sin(_dlam2); _z02 = Proj.Aacos(_sp1*_sp2 + _cp1*_cp2*Math.Cos(_dlam2)); _hz0 = .5*_z02; double A12 = Math.Atan2(_cp2*Math.Sin(_dlam2), _cp1*_sp2 - _sp1*_cp2*Math.Cos(_dlam2)); _ca = Math.Cos(pp = Proj.Aasin(_cp1*Math.Sin(A12))); _sa = Math.Sin(pp); _lp = Proj.Adjlon(Math.Atan2(_cp1*Math.Cos(A12), _sp1) - _hz0); _dlam2 *= .5; _lamc = HalfPi - Math.Atan2(Math.Sin(A12)*_sp1, Math.Cos(A12)) - _dlam2; _thz0 = Math.Tan(_hz0); _rhshz0 = .5/Math.Sin(_hz0); _r2z0 = 0.5/_z02; _z02 *= _z02; }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { double phi = 0; if (projInfo.StandardParallel1 != null) phi = projInfo.StandardParallel1.Value * Math.PI / 180; _rc = Math.Cos(phi); if(_rc <= 0) throw new ProjectionException(24); }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { Phi1 = projInfo.GetPhi1(); Phi2 = (Phi1 < 0) ? - HalfPi : HalfPi; Setup(); }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { if (projInfo.Parameters.ContainsKey("W")) { _w = projInfo.ParamD("W"); if (_w <= 0) throw new ProjectionException(27); } else { _w = .5; } if(projInfo.Parameters.ContainsKey("M")) { _m = projInfo.ParamD("M"); if(_m <= 0)throw new ProjectionException(27); } else { _m = 1; } _rm = 1/_m; _m /= _w; }
/// <summary> /// Creates a new instance of a Projection Param with the specified name /// and the specified projection as the default projection that will /// appear if no changes are made. /// </summary> /// <param name="name"></param> /// <param name="defaultProjection"></param> public ProjectionParam(string name, ProjectionInfo defaultProjection) { Name = name; Value = defaultProjection; ParamVisible = ShowParamInModel.No; ParamType = "MapWindow String Param"; DefaultSpecified = true; }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { Ra = 1/ (A = 6378388.0); Lam0 = DegToRad * 173; Phi0 = DegToRad * -41; X0 = 2510000; Y0 = 6023150; }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { if (IsElliptical) { _en = Proj.Enfn(Es); _ml0 = Proj.Mlfn(Phi0, Math.Sin(Phi0), Math.Cos(Phi0), _en); } else { _ml0 = -Phi0; } }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { if (projInfo.StandardParallel1 != null) { _cosphi1 = Math.Cos(projInfo.GetPhi1()); if (_cosphi1 == 0) throw new ProjectionException(22); } else { /* 50d28' or acos(2/pi) */ _cosphi1 = 0.636619772367581343; } }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { double phip0; _hlfE = 0.5 * E; double cp = Math.Cos(Phi0); cp *= cp; _c = Math.Sqrt(1 + Es * cp * cp * ROneEs); double sp = Math.Sin(Phi0); _cosp0 = Math.Cos( phip0 = Proj.Aasin(_sinp0 = sp / _c) ); sp *= E; _k = Math.Log(Math.Tan(FortPi + 0.5 * phip0)) - _c * ( Math.Log(Math.Tan(FortPi + 0.5 * Phi0)) - _hlfE * Math.Log((1+ sp) / (1- sp))); _kR = K0 * Math.Sqrt(OneEs) / (1- sp * sp); }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { if(Es != 0) { _en = MeridionalDistance.GetEN(Es); if(_en == null)throw new ProjectionException(0); _ml0 = MeridionalDistance.MeridionalLength(Phi0, Math.Sin(Phi0), Math.Cos(Phi0), _en); _esp = Es/(1 - Es); } else { _esp = K0; _ml0 = .5*_esp; } }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { Phi0 = projInfo.GetPhi0(); if (Math.Abs(Math.Abs(Phi0) - HalfPi) < EPS10) { _mode = Phi0 < 0 ? Modes.SouthPole : Modes.NorthPole; _sinph0 = Phi0 < 0 ? -1: 1; _cosph0 = 0; } else if (Math.Abs(Phi0) < EPS10) { _mode = Modes.Equitorial; _sinph0 = 0; _cosph0 = 1; } else { _mode = Modes.Oblique; _sinph0 = Math.Sin(Phi0); _cosph0 = Math.Cos(Phi0); } if (Es == 0)return; _en = Proj.Enfn(Es); if(projInfo.Parameters.ContainsKey("guam")) { _M1 = Proj.Mlfn(Phi0, _sinph0, _cosph0, _en); _isGuam = true; } else { switch (_mode) { case Modes.NorthPole: _Mp = Proj.Mlfn(HalfPi, 1, 0, _en); break; case Modes.SouthPole: _Mp = Proj.Mlfn(-HalfPi, -1, 0, _en); break; case Modes.Equitorial: case Modes.Oblique: _N1 = 1/ Math.Sqrt(1- Es * _sinph0 * _sinph0); _g = _sinph0 * (_He = E / Math.Sqrt(OneEs)); _He *= _cosph0; break; } } }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { _cosphi1 = Math.Cos(projInfo.GetPhi1()); }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { _phi1 = projInfo.GetPhi1(); if (Math.Abs(_phi1) < EPS10) throw new ProjectionException(-23); if (Es > 0) { _en = Proj.Enfn(Es); double c; _m1 = Proj.Mlfn(_phi1, _am1 = Math.Sin(_phi1), c = Math.Cos(_phi1), _en); _am1 = c / (Math.Sqrt(1 - Es * _am1 * _am1) * _am1); } else { if (Math.Abs(_phi1) + EPS10 >= HalfPi) _cphi1 = 0; else _cphi1 = 1/Math.Tan(_phi1); } }
/// <summary> /// Reprojects all of the in-ram vertices of this featureset. /// This will also update the projection to be the specified projection. /// </summary> /// <param name="targetProjection">The projection information to reproject the coordinates to.</param> public void Reproject(ProjectionInfo targetProjection) { if(InternalDataSet != null)InternalDataSet.Reproject(targetProjection); Projections.Reproject.ReprojectPoints(Vertex, Z, Projection, targetProjection, 0, Vertex.Length/2); UpdateCoordinates(); UpdateEnvelopes(); Projection = targetProjection; }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { if (!projInfo.Parameters.ContainsKey("bns")) return; if (projInfo.ParamI("bns") != 0) _noskew = true; }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { Setup(HalfPi); }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { if ((_h = projInfo.ParamD("h")) <= 0) throw new ProjectionException(-30); if (Phi0 == 0) throw new ProjectionException(-46); _radiusG = 1 + (_radiusG1 = _h / A); _c = _radiusG * _radiusG - 1.0; if (IsElliptical) { _radiusP = Math.Sqrt(OneEs); _radiusP2 = OneEs; _radiusPInv2 = ROneEs; } else { _radiusP = _radiusP2 = _radiusPInv2 = 1.0; } }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { _phi1 = projInfo.GetPhi1(); _phi2 = projInfo.GetPhi2(); Setup(); }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { Setup(Math.PI/3); }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { if(projInfo.StandardParallel1 != null) { _phi1 = projInfo.GetPhi1(); _cosphi1 = Math.Cos(_phi1); if(_cosphi1 < EPS) throw new ProjectionException(22); } _tanphi1 = Math.Tan(FortPi + 0.5 * _phi1); }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { M = 1; N = 2.570796326794896619231321691; Setup(); }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { _moll = new Mollweide(); _moll.Init(projInfo); _sinu = new Sinusoidal(); _sinu.Init(projInfo); }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { double t = Math.Abs(Phi0); if(Math.Abs(t - HalfPi) < EPS10) { _mode = Phi0 < 0 ? Modes.SouthPole : Modes.NorthPole; } else if(Math.Abs(t) < EPS10) { _mode = Modes.Equitorial; } else { _mode = Modes.Oblique; } if (Es == 0) { IsElliptical = false; _mode = Modes.Oblique; _sinb1 = Math.Sin(Phi0); _cosb1 = Math.Cos(Phi0); return; } IsElliptical = true; _qp = Proj.Qsfn(1, Es, OneEs); // _mmf = .5/(1 - Es); _apa = Proj.Authset(Es); switch(_mode) { case Modes.NorthPole: case Modes.SouthPole: _dd = 1; break; case Modes.Equitorial: _dd = 1/(_rq = Math.Sqrt(.5*_qp)); _xmf = 1; _ymf = .5*_qp; break; case Modes.Oblique: _rq = Math.Sqrt(.5*_qp); double sinphi = Math.Sin(Phi0); _sinb1 = Proj.Qsfn(sinphi, E, OneEs); _cosb1 = Math.Sqrt(1 - _sinb1*_sinb1); _dd = Math.Cos(Phi0)/(Math.Sqrt(1 - Es*sinphi*sinphi)*_rq*_cosb1); _ymf = _xmf = _rq/_dd; _xmf *= _dd; break; } }
/// <summary> /// Executes the ReprojectFeatureSet Operation tool programaticaly. /// </summary> /// <param name="featureSet">The input FeatureSet.</param> /// <param name="sourceProjection">The input Expression string to select features to Delete.</param> /// <param name="destProjection">The target projected coordinate system to reproject the featureset to</param> /// <param name="output">The output FeatureSet.</param> /// <param name="cancelProgressHandler">The progress handler.</param> /// Ping deleted "static" for external testing /// <returns></returns> public bool Execute(IFeatureSet featureSet, ProjectionInfo sourceProjection, ProjectionInfo destProjection, IFeatureSet output, ICancelProgressHandler cancelProgressHandler) { output.CopyFeatures(featureSet, true); output.Projection = featureSet.Projection; if(sourceProjection != null) output.Projection = sourceProjection; output.Reproject(destProjection); output.SaveAs(output.Filename, true); return true; }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { /* read some Parameters, * here Latitude Truescale */ double ts = 0; if(projInfo.StandardParallel1 != null) ts = projInfo.StandardParallel1.Value*Math.PI/180; _C_x = ts; /* we want Bessel as fixed ellipsoid */ A = 6377397.155; E = Math.Sqrt(Es = 0.006674372230614); /* if latitude of projection center is not set, use 49d30'N */ Phi0 = projInfo.LatitudeOfOrigin != null ? projInfo.GetPhi0() : 0.863937979737193; /* if center long is not set use 42d30'E of Ferro - 17d40' for Ferro */ /* that will correspond to using longitudes relative to greenwich */ /* as input and output, instead of lat/long relative to Ferro */ Lam0 = projInfo.CentralMeridian != null ? projInfo.GetLam0() : 0.7417649320975901 - 0.308341501185665; /* if scale not set default to 0.9999 */ K0 = projInfo.CentralMeridian != null ? projInfo.GetLam0() : 0.9999; if (!projInfo.Parameters.ContainsKey("czech")) return; int temp = projInfo.ParamI("czech"); if (temp != 0) _czech = true; }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { const double phi_0 = 0.0; _rok = A/K0; _rtk = A*K0; if (projInfo.Parameters.ContainsKey("alpha")) { double alpha = projInfo.ParamR("alpha"); double lonz = projInfo.ParamR("lonc"); _singam = Math.Atan(-Math.Cos(alpha)/(-Math.Sin(phi_0)*Math.Sin(alpha))) + lonz; _sinphi = Math.Asin(Math.Cos(phi_0)*Math.Sin(alpha)); } else { double phi_1 = projInfo.GetPhi1(); double phi_2 = projInfo.GetPhi2(); double lam_1 = projInfo.ParamR("lon_1"); double lam_2 = projInfo.ParamR("lon_2"); _singam = Math.Atan2(Math.Cos(phi_1)*Math.Sin(phi_2)*Math.Cos(lam_1) - Math.Sin(phi_1)*Math.Cos(phi_2)*Math.Cos(lam_2), Math.Sin(phi_1)*Math.Cos(phi_2)*Math.Sin(lam_2) - Math.Cos(phi_1)*Math.Sin(phi_2)*Math.Sin(lam_1)); _sinphi = Math.Atan(-Math.Cos(_singam - lam_1)/Math.Tan(phi_1)); } Lam0 = _singam + HalfPi; _cosphi = Math.Cos(_sinphi); _sinphi = Math.Sin(_sinphi); _singam = Math.Sin(_singam); }
/// <summary> /// /// </summary> /// <param name="points"></param> /// <param name="source"></param> /// <param name="dest"></param> /// <param name="startIndex"></param> /// <param name="numPoints"></param> public static void ReprojectPoints(double[] xy, double[] z, ProjectionInfo source, ProjectionInfo dest, int startIndex, int numPoints) { double toMeter = source.Unit.Meters; // Geocentric coordinates are centered at the core of the earth. Z is up toward the north pole. // The X axis goes from the center of the earth through greenwich. // The Y axis passes through 90E. // This section converts from geocentric coordinates to geodetic ones if necessary. if (source.IsGeocentric) { if (z == null) { throw new ProjectionException(45); } for (int i = startIndex; i < numPoints; i++) { if(toMeter != 1) { xy[i * 2] *= toMeter; xy[i * 2 + 1] *= toMeter; } } GeocentricGeodetic g = new GeocentricGeodetic(source.GeographicInfo.Datum.Spheroid); g.GeocentricToGeodetic(xy, z, startIndex, numPoints); } // Transform source points to lam/phi if they are not already ConvertToLatLon(source, xy, startIndex, numPoints); double fromGreenwich = source.GeographicInfo.Meridian.Longitude * source.GeographicInfo.Unit.Radians; if(fromGreenwich != 0) { for (int i = startIndex; i < numPoints; i++) { if (xy[2* i] != double.PositiveInfinity) xy[2 * i] += fromGreenwich; } } // DATUM TRANSFORM IF NEEDED if(!source.GeographicInfo.Datum.Matches(dest.GeographicInfo.Datum)) { DatumTransform(source, dest, xy, z, startIndex, numPoints); } // Adjust to new prime meridian if there is one in the destination cs fromGreenwich = dest.GeographicInfo.Meridian.Longitude*dest.GeographicInfo.Unit.Radians; if(fromGreenwich != 0) { for(int i = startIndex; i < numPoints; i++) { if(xy[i * 2] != double.PositiveInfinity) { xy[i * 2 +1] -= fromGreenwich; } } } if(dest.IsGeocentric) { if (z == null) { throw new ProjectionException(45); } GeocentricGeodetic g = new GeocentricGeodetic(dest.GeographicInfo.Datum.Spheroid); g.GeodeticToGeocentric(xy, z, startIndex, numPoints); double frmMeter = 1/dest.Unit.Meters; if(frmMeter != 1) { for (int i = startIndex; i < numPoints; i++) { if (xy[i * 2] != double.PositiveInfinity) { xy[i * 2] *= frmMeter; xy[i * 2+1] *= frmMeter; } } } } else { ConvertToProjected(dest, xy, startIndex, numPoints); } }
/// <summary> /// Initializes the transform using the parameters from the specified coordinate system information /// </summary> /// <param name="projInfo">A ProjectionInfo class contains all the standard and custom parameters needed to initialize this transform</param> protected override void OnInit(ProjectionInfo projInfo) { Setup(2, 2, true); }
/// <summary> /// Obtains all the members of this category, building a single /// array of the projection info classes. This returns the /// original classes, not a copy. /// </summary> /// <returns>The array of projection info classes</returns> public ProjectionInfo[] ToArray() { Type t = GetType(); FieldInfo[] fields = t.GetFields(); ProjectionInfo[] result = new ProjectionInfo[fields.Length]; for (int i = 0; i < fields.Length; i++ ) { result[i] = fields[i].GetValue(this) as ProjectionInfo; } return null; }