public CL() { Proj1.Add("AhCounter", DateTime.MinValue); Proj1.Add("IE", DateTime.MinValue); Proj1.Add("LE", DateTime.MinValue); Proj1.Add("TopicsMaster", DateTime.MinValue); Proj2.Add("IE", DateTime.MinValue); Proj2.Add("LE", DateTime.MinValue); Proj2.Add("GE", DateTime.MinValue); Proj3.Add("IE", DateTime.MinValue); Proj3.Add("LE", DateTime.MinValue); Proj3.Add("GE", DateTime.MinValue); Proj4.Add("Timer", DateTime.MinValue); Proj4.Add("TME", DateTime.MinValue); Proj4.Add("Speaker", DateTime.MinValue); Proj4.Add("TopicsMaster", DateTime.MinValue); Proj5.Add("Speaker", DateTime.MinValue); Proj5.Add("GE", DateTime.MinValue); Proj5.Add("TME", DateTime.MinValue); Proj5.Add("TopicsMaster", DateTime.MinValue); Proj7.Add("TME", DateTime.MinValue); Proj7.Add("GE", DateTime.MinValue); Proj7.Add("Speaker", DateTime.MinValue); Proj8.Add("IE", DateTime.MinValue); Proj8.Add("GE", DateTime.MinValue); }
public GPSPosition fromWGS84(double longitude, double latitude, double elevation) { Console.Error.WriteLine("fromWGS84 {0} {1} {2}", longitude, latitude, elevation); Console.Error.WriteLine( "{0} {1} {2}", Utils.toRad(longitude), Utils.toRad(latitude), elevation ); var pos = Proj4.proj_trans(Proj, Proj4.PJ_DIRECTION.PJ_FWD, Proj4.proj_coord(Utils.toRad(longitude), Utils.toRad(latitude), elevation, 0)); if (double.IsInfinity(pos.up)) { /* * proj4 returns infinity value for up when we are outside of the geoid grid bounding box * * use fake geoid heigt, which we set to elevation, so that * we can use SWEREF99 projections outside of the RH2000 bounding box * this is usefull for running the device at real world location where * we don't support the local projection system */ pos.up = elevation; } return(new GPSPosition(ProjName, pos.north, pos.east, pos.up)); }
public void toWGS84(GPSPosition pos, out double longitude, out double latitude, out double elevation) { var wgsPos = Proj4.proj_trans(Proj, Proj4.PJ_DIRECTION.PJ_INV, Proj4.proj_coord(pos.East, pos.North, pos.Altitude)); if (double.IsInfinity(wgsPos.north) || double.IsInfinity(wgsPos.east) || double.IsInfinity(wgsPos.up)) { /* proj4 returns infinity value if it can't transform position */ throw new CoordinateTransformationException("WGS84", pos); } longitude = Utils.toDegrees(wgsPos.east); latitude = Utils.toDegrees(wgsPos.north); elevation = wgsPos.up; }
public Converter(string projection) : base() { ProjName = projection; var ProjString = string.Format( #if UNITY_ANDROID /* * skip doing RH2000 height calculation on android for now, * as proj4 can't load geogird data on android */ "{0} +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs", #else "{0} +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs", // "{0} +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +geoidgrids=SWEN17_RH2000.gtx +units=m +no_defs", #endif ProjParams[projection]); Proj = Proj4.CreateProj(ProjString); }
/// <summary> /// The code that actually tests an input projection /// </summary> public static void TestProjection(ProjectionInfo pStart) { ProjectionInfo pEnd = KnownCoordinateSystems.Geographic.World.WGS1984; double[] xy = new double[2]; double x = 0; if (pStart.FalseEasting != null) { x = pStart.FalseEasting.Value; xy[0] = pStart.FalseEasting.Value; } double[] z = new double[1]; Reproject.ReprojectPoints(xy, z, pStart, pEnd, 0, 1); double y = 0; string source = pStart.ToProj4String(); Proj4.ProjectPoint(ref x, ref y, source, pEnd.ToProj4String()); if (Math.Abs(x - xy[0]) > 0.00000001) { Assert.Fail(String.Format("The longitude was off by {0} decimal degrees from proj4", (x - xy[0]))); } if (Math.Abs(y - xy[1]) > 0.00000001) { Assert.Fail(String.Format("The latitude was off by {0} decimal degrees from proj4", (y - xy[1]))); } z[0] = 0; Reproject.ReprojectPoints(xy, z, pEnd, pStart, 0, 1); Proj4.ProjectPoint(ref x, ref y, pEnd.ToProj4String(), source); if (Math.Abs(x - xy[0]) > 1 / pStart.Unit.Meters) { Assert.Fail(String.Format("The X coordinate was off by {0} {1}", (x - xy[0]), pStart.GetUnitText(xy[0]))); } if (Math.Abs(y - xy[1]) > 1 / pStart.Unit.Meters) { Assert.Fail(String.Format("The Y coordinate was off by {0} {1}", (y - xy[1]), pStart.GetUnitText(xy[1]))); } }
/// <summary> /// The code that actually tests an input projection /// </summary> public static void TestProjection(ProjectionInfo pStart) { var pEnd = KnownCoordinateSystems.Geographic.World.WGS1984; var xy = new double[2]; double x = 0; if (pStart.FalseEasting != null) { x = pStart.FalseEasting.Value; xy[0] = pStart.FalseEasting.Value; } var z = new double[1]; Reproject.ReprojectPoints(xy, z, pStart, pEnd, 0, 1); double y = 0; var source = pStart.ToProj4String(); var prj = new Proj4(); prj.ProjectPoint(ref x, ref y, source, pEnd.ToProj4String()); if (Math.Abs(x - xy[0]) > 0.00000001) { Assert.Fail("The longitude was off by {0} decimal degrees from proj4", (x - xy[0])); } if (Math.Abs(y - xy[1]) > 0.00000001) { Assert.Fail("The latitude was off by {0} decimal degrees from proj4", (y - xy[1])); } z[0] = 0; Reproject.ReprojectPoints(xy, z, pEnd, pStart, 0, 1); prj.ProjectPoint(ref x, ref y, pEnd.ToProj4String(), source); if (Math.Abs(x - xy[0]) > 1 / pStart.Unit.Meters) { Assert.Fail("The X coordinate was off by {0} {1}", (x - xy[0]), pStart.GetUnitText(xy[0])); } if (Math.Abs(y - xy[1]) > 1 / pStart.Unit.Meters) { Assert.Fail("The Y coordinate was off by {0} {1}", (y - xy[1]), pStart.GetUnitText(xy[1])); } }
protected Proj4Converter() { /* look for geoid grid tables in streaming assets directory */ Proj4.SetSearchPath(AppPaths.StreamingAssetsDir); }