public static GeoPointMercator ToMercator(this GeoPointUTM geoPoint) { GeoPointMercator mercator = new GeoPointMercator(_transformationFromUTMToMercator.MathTransform.Transform(geoPoint.ToArray())) { altitude = geoPoint.altitude }; return(mercator); }
public static GeoPointUTM ToUTM(this GeoPointMercator geoPoint) { GeoPointUTM utm = new GeoPointUTM(_transformationFromMercatorToUTM.MathTransform.Transform(geoPoint.ToArray())) { altitude = geoPoint.altitude }; return(utm); }
public static GeoPointWGS84 ToWGS84(this GeoPointUTM geoPoint) { GeoPointWGS84 wgs84 = new GeoPointWGS84(_transformationFromUTMToUGS84.MathTransform.Transform(geoPoint.ToArray())) { altitude = geoPoint.altitude }; return(wgs84); }
// Update is called once per frame void Update() { if (_test) { GeoPointUTM coordinatesUtm = _testPoint.transform.position.ToUTM(); Debug.Log("Test point - UTM: " + coordinatesUtm); GeoPointWGS84 wgs84 = coordinatesUtm.ToWGS84(); Debug.Log("Test point - WGS84: " + wgs84); GeoPointMercator utm = coordinatesUtm.ToMercator(); Debug.Log("Test point - Mercator: " + utm); _test = false; } if (_testCoord) { GameObject point = GameObject.CreatePrimitive(PrimitiveType.Sphere); point.transform.position = _wgsPointToTest.ToUTM().ToUnity(); _testCoord = false; } if (_testDistance) { Debug.Log(Vector3.Distance(_testDistancePointA.position, _testDistancePointB.position) + "meters"); _testDistance = false; } if (_testOrientation) { transform.LookAt(_testOrientationPoint); _testOrientation = false; } if (_testDistancePoint) { GameObject point = GameObject.CreatePrimitive(PrimitiveType.Sphere); point.transform.position = transform.position + transform.forward * _distance; _testDistancePoint = false; } if (_moveToDistance) { Ray ray = new Ray(transform.position, transform.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit, float.PositiveInfinity)) { float offset = hit.distance - _moveDistance; transform.position = transform.position + transform.forward * offset; } _moveToDistance = false; } Debug.DrawRay(transform.position, transform.forward * 100); }
static GeoUtils() { _utmZone = ConfigManager.ConfigFile.UtmZone; _utmNorth = ConfigManager.ConfigFile.IsUtmNorth; CoordinateTransformationFactory _ctf = new CoordinateTransformationFactory(); _transformationFromWGS84ToUTM = _ctf.CreateFromCoordinateSystems(GeographicCoordinateSystem.WGS84, ProjectedCoordinateSystem.WGS84_UTM(_utmZone, _utmNorth)); _transformationFromWGS84ToMercator = _ctf.CreateFromCoordinateSystems(GeographicCoordinateSystem.WGS84, ProjectedCoordinateSystem.WebMercator); _transformationFromMercatorToWGS84 = _ctf.CreateFromCoordinateSystems(ProjectedCoordinateSystem.WebMercator, GeographicCoordinateSystem.WGS84); _transformationFromUTMToUGS84 = _ctf.CreateFromCoordinateSystems(ProjectedCoordinateSystem.WGS84_UTM(_utmZone, _utmNorth), GeographicCoordinateSystem.WGS84); _transformationFromUTMToMercator = _ctf.CreateFromCoordinateSystems(ProjectedCoordinateSystem.WGS84_UTM(_utmZone, _utmNorth), ProjectedCoordinateSystem.WebMercator); _transformationFromMercatorToUTM = _ctf.CreateFromCoordinateSystems(ProjectedCoordinateSystem.WebMercator, ProjectedCoordinateSystem.WGS84_UTM(_utmZone, _utmNorth)); _utmOrigin = default(GeoPointUTM); }
public static Vector3 ToUnity(this GeoPointUTM geoPoint) { GeoPointUTM ucs = geoPoint - _utmOrigin; return(new Vector3(x: (float)ucs.longitude, y: (float)ucs.altitude, z: (float)ucs.latitude)); }