Giter VIP home page Giter VIP logo

Comments (3)

airbreather avatar airbreather commented on June 17, 2024

I don't think so. If so, it wouldn't really be anything that ProjNet4GeoAPI adds, since this library is just concerned with coordinate transformations.

You could, for example, use a conformal projection and compute angles there using NetTopologySuite, but that wouldn't really be different than just computing the angles on the unprojected coordinates.

Mike Gavaghan wrote a Geodesy library in both Java and C#... I copied the C# one onto GitHub (with his permission) at airbreather/Gavaghan.Geodesy, which seems a bit more promising.

GeodeticCalculator.CalculateGeodeticCurve can give you a GeodeticCurve which has the Azimuth / ReverseAzimuth, which you should be able to translate to bearing / reverse bearing, right?

from projnet4geoapi.

eiredrake avatar eiredrake commented on June 17, 2024

Rolled back around to this and had a hard time remembering where I'd asked the question. but thank you I'll look into it. I appreciate the referral.

from projnet4geoapi.

juliusfriedman avatar juliusfriedman commented on June 17, 2024

Something like this?

/// <summary>
		/// 
		/// </summary>
		public enum CompassDirection
        {
			N,
			NE,
			E,
			SE,
			S,
			SW,
			W,
			NW
        }

		/// <summary>
		/// 
		/// </summary>
		/// <param name="bearing"></param>
		/// <returns></returns>
		[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
		public static CompassDirection GetCompassDirection(double bearing)
        {
			if (bearing >= 0 && bearing <= 22.5)
			{
				return CompassDirection.N;
			}
			else if (bearing >= 22.5 && bearing <= 67.5)
			{
				return CompassDirection.NE;
			}
			else if (bearing >= 67.5 && bearing <= 112.5)
			{
				return CompassDirection.E;
			}
			else if (bearing >= 112.5 && bearing <= 157.5)
			{
				return CompassDirection.SE;
			}
			else if (bearing >= 157.5 && bearing <= 205.5)
			{
				return CompassDirection.S;
			}
			else if (bearing >= 202.5 && bearing <= 247.5)
			{
				return CompassDirection.SW;
			}
			else if (bearing >= 247.5 && bearing <= 292.5)
			{
				return CompassDirection.W;
			}
			else if (bearing >= 292.5 && bearing <= 337.5)
			{
				return CompassDirection.NW;
			}
            else
            {
				return CompassDirection.N;
            }
		}
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
		public static double DegreeBearing(double lon1, double lat1, double lon2, double lat2)
		{
			var dLon = ToRadians(lon2 - lon1);
			var dPhi = Math.Log(Math.Tan(ToRadians(lat2) / 2 + Math.PI / 4) / Math.Tan(ToRadians(lat1) / 2 + Math.PI / 4));
			if (Math.Abs(dLon) > Math.PI) dLon = dLon > 0 ? -(2 * Math.PI - dLon) : (2 * Math.PI + dLon);
			return ToBearing(Math.Atan2(dLon, dPhi));
		}


[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
		public static double ToBearing(double radians)
		{
			// convert radians to degrees (as bearing: 0...360)
			return (ToDegrees(radians) + 360) % 360;
		}

See also: StackOverflow

from projnet4geoapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.