Coder Social home page Coder Social logo

dsherret / coordinatesharp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tronald/coordinatesharp

0.0 3.0 0.0 3.05 MB

A library designed to ease geographic coordinate format conversions, and determine sun/moon information in C#

License: MIT License

C# 100.00%

coordinatesharp's Introduction

v1.1.3.3

CoordinateSharp is a simple .NET standard library that is designed to assist with geographic coordinate formatting and location based celestial information. This library has the ability to convert various lat long formats, UTM, MGRS(NATO UTM) and Cartesian (X, Y, Z). The ability to calculate various pieces of celestial information (sunset, moon illum..) also exist.

CAUTION: v1.1.3.1 and above is considered a breaking change as MoonDistance has been converted from a double? object to a Distance object. Obsolete properties from 1.1.1.5 have also been removed as scheduled.

Change notes can be viewed here

Prerequisites

.NET 4.0 or greater.

Installing

CoordinateSharp is available as a nuget package from nuget.org

Alternatively, you may download the library directly on our website

Usage Example

CoordinateSharp is simple to use. In the below example we create a Coordinate by passing a lat/long and date. Once the Coordinate is created we have access to various formats and celestial data.

//Seattle coordinates on 5 Jun 2018 @ 10:10 AM (UTC)
Coordinate c = new Coordinate(47.6062, -122.3321, new DateTime(2018,6,5,10,10,0));

Console.WriteLine(c);                       // N 47º 36' 22.32" W 122º 19' 55.56"
Console.WriteLine(c.Latitude.Seconds);      // 22.32
Console.WriteLine(c.CelestialInfo.SunSet);  // 5-Jun-2018 4:02:00 AM
Console.WriteLine(c.UTM);                   // 10T 550200mE 5272748mN

Coordinate has its default lat/long format output as DMS (ex N 47º 36' 22.32" W 122º 19' 55.56"). This format can be changed quickly by setting the object formatting options.

Coordinate c = new Coordinate(40.57682, -70.75678);

c.FormatOptions.CoordinateFormatType = CoordinateFormatType.Degree_Decimal_Minutes;
c.FormatOptions.Display_Leading_Zeros = true;
c.FormatOptions.Round = 3;

c.ToString();           // N 40º 34.609' W 070º 045.407'
c.Latitude.ToString();  // N 40º 34.609'
c.Longitude.ToString(); // W 070º 45.407'

Abilities

  • Lat/Long formatting: Quickly format how a coordinate is output.
  • Coordinate conversions: Convert Lat/Long to UTM, MGRS, Cartesian or vice versa.
  • Coordinate parsing: Initialize a Coordinate with multiple format types using TryParse().
  • Coordinate moving/shifting: Shift coordinates using a distance and bearing, or a distance and target coordinate.
  • Location based celestial information: Quickly determine sun set, moon rise, next solar eclipse or even zodiac signs at the input location.
  • Property change notification: All properties automatically adjust as the Coordinate changes. For example, changing the GeoDate will cause all celestial times to recalculate. Adjusting a Coordinate latitudinal seconds, will retrigger all coordinate conversions and celestial data so your information is always up to date.

Guides

Check out the CoordinateSharp Developer Guide for more detailed instructions on using CoordinateSharp.

You may also view the Documentation for a more in depth look at CoordinateSharp's structure.

Acknowledgements

Most celestial calculations are based on "Astronomical Algorithms" 2nd edition by Jean Meeus (Willmann-Bell, Richmond) 1998.

Portions of SunTime calculations were adapted from NOAA and Zacky Pickholz 2008 "C# Class for Calculating Sunrise and Sunset Times" NOAA The Zacky Pickholz project

Portions of MoonTime calculations were adapted from the mourner / suncalc project (c) 2011-2015, Vladimir Agafonkin suncalc suncalc's moon calculations are based on "Astronomical Algorithms" 2nd edition by Jean Meeus (Willmann-Bell, Richmond) 1998. & These Formulas by Dr. Louis Strous

Portions of the calculations for illumination parameters of the moon based on NASA Formulas and Chapter 48 of "Astronomical Algorithms" 2nd edition by Jean Meeus (Willmann-Bell, Richmond) 1998.

UTM & MGRS Conversions were referenced from Sami Salkosuo's j-coordconvert library & Steven Dutch, Natural and Applied Sciences,University of Wisconsin - Green Bay

Solar and Lunar Eclipse calculations were adapted from NASA's Eclipse Calculator created by Chris O'Byrne and Fred Espenak.

Aspects of distance calculations referenced worked by Ed Williams Great Circle Calculator

Graphic and logo design work was donated by area55.

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.