Code Monkey home page Code Monkey logo

coordinatesharp's People

Contributors

area55git avatar b4rrch avatar dsherret avatar jetelain avatar jtrotta avatar tronald avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coordinatesharp's Issues

Give the name of moon phase

By example, we can calculate and return name of moon phase, based on age (from 0 to 1)

private string MoonPhaseName(double age) {
string phase = "";
if (age >= 0.98)
{
phase = _localizer["TourNewMoon"].Value;
}
else if (age > 0.5 && age < 0.98)
{
phase = (int)Math.Ceiling((age - 0.5) * 30) + " " + _localizer["TourDateMoonSet"].Value;
}
else if (age > 0 && age < 0.49)
{
phase = (int)Math.Ceiling((age * 30)) + " " + _localizer["TourDateMoonRise"].Value;
}
else if (age >= 0.49 && age <= 0.5)
{
phase = _localizer["TourFullMoon"].Value;
}
return phase;
}

EagerLoadType enums not working in EagerLoad constructor

The ability to pass enum flags to the EagerLoading constructor doesn't seem to work in all cases. When I try doing "EagerLoad eagerLoad = new EagerLoad(EagerLoadType.UTM_MGRS);", the UTM_MGRS property is still set to false. I have to manually set the property to true by doing "eagerLoad.UTM_MGRS = true;".

Also, the examples you provide in the Developers Guide/Eager Loading section don't appear to work either. Those examples attempt to set the EagerLoadType.Celestial and EagerLoadType.Cartesian properties to true, which does happen, but the UTM_MGRS property is also set to true but, it should be set to false.

ArgumentOutOfRangeException using Puebla, Mexico coordinates

Hi,

I met a case that throw new ArgumentOutOfRangeException :
new Coordinate(19.0991676999824, -98.2209974507276, new DateTime(2018,10,31,0,0,0))

It seems that using these coordinates (Albuquerque) and this date, the calculated Sunset time is "24".

Thanks for your help.

AdditionalSolarTimes ArgumentException Error

ArgumentException Error is occurring at latitudes where there is technically a SunSet or SunRise, but no Dawn or Dusk.

Error should be caught, with a null DateTime value returned.

Un-representable during multithreading

First of all - great plugin! Thanks a ton for making it.

Getting an unfortunate error though when running my app multi-threaded.

Any idea how to resolve? Thanks!
Emil

var NE = new CoordinateSharp.Coordinate(center.Latitude, center.Longitude);
NE.Move(0.5* 1000, -45, Shape.Sphere); <-- Error line
System.ArgumentOutOfRangeException: 'The added or subtracted value results in an un-representable DateTime.
Parameter name: value'
at System.DateTime.AddTicks(Int64 value)
   at CoordinateSharp.SolarEclipseDetails..ctor(List`1 values)
   at CoordinateSharp.SunCalc.CalculateSolarEclipse(DateTime date, Double lat, Double longi, Celestial c)
   at CoordinateSharp.SunCalc.CalculateSunTime(Double lat, Double longi, DateTime date, Celestial c, Double offset)
   at CoordinateSharp.Celestial.CalculateCelestialTime(Double lat, Double longi, DateTime date)
   at CoordinateSharp.Coordinate.NotifyPropertyChanged(String propName)
   at CoordinateSharp.CoordinatePart.NotifyProperties(PropertyTypes p)
   at CoordinateSharp.CoordinatePart.set_DecimalDegree(Double value)
   at CoordinateSharp.Coordinate.Move(Double distance, Double bearing, Shape shape)
   at GoogleMapsScraper.ViewportCoordinates..ctor(Coordinate center, Double kmRadius) in D:\Downloads\code\GooglePlace.cs:line 342
   at GoogleMapsScraper.Coordinate.GetViewpointCoordinates(Double kmRadius) in D:\Downloads\code\GooglePlace.cs:line 400
   at GoogleMapsScraper.Coordinate.ViewportUrl() in D:\Downloads\code\GooglePlace.cs:line 391
   at GoogleMapsScraper.Program.Scrape(WebClient client) in D:\Downloads\code\Program.cs:line 55
   at GoogleMapsScraper.Program.<>c__DisplayClass5_0.<Main>b__0() in D:\Downloads\code\Program.cs:line 37
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

SunAltitude stopped working

Hey, thanks for fixing the .net core warnings. Unfortunately the sun altitude calculation seems to have stopped working:

Debug.WriteLine(GetAltitude(new DateTime(2018, 8, 5, 16, 0, 0)));
Debug.WriteLine(GetAltitude(new DateTime(2018, 8, 5, 17, 0, 0)));
Debug.WriteLine(GetAltitude(new DateTime(2018, 8, 5, 18, 0, 0)));
Debug.WriteLine(GetAltitude(new DateTime(2018, 8, 5, 19, 0, 0)));
Debug.WriteLine(GetAltitude(new DateTime(2018, 8, 5, 20, 0, 0)));
Debug.WriteLine(GetAltitude(new DateTime(2018, 8, 5, 21, 0, 0)));
Debug.WriteLine(GetAltitude(new DateTime(2018, 8, 5, 22, 0, 0)));
Debug.WriteLine(GetAltitude(new DateTime(2018, 8, 5, 23, 0, 0)));

double GetAltitude(DateTime dateTime)
{
    var coordinate = new Coordinate(43.653908, -79.384293, dateTime.ToUniversalTime());
    return coordinate.CelestialInfo.SunAltitude;
}

Outputs:

5.49222218568126
5.49222218568126
5.49222218568126
5.49222218568126
5.28696706518481
5.28696706518481
5.28696706518481
5.28696706518481

Logo Proposal for CoordinateSharp

Hi, I'm a graphic designer and I like to collaborate with open source projects. Do you know that the graphic image of a project is very important? thinking about it I would like to design a logo for your Project CoordinateSharp.

I will be pleased to collaborate with you.

--

(please delete this one)

Support for TryParse on a CoordinatePart

Is there functionality to have a TryParse for just latitude or longitude. I am working with lat and long separately and need to parse one or the other. The problem with Coordinate.TryParse() is that you need to past both a lat and long. I have tried to add the missing part. So for example if the lat is provided and long isn't I would append "W 12.234" to the lat. However, the format of lat and long must match so working with either lat or long is not flexible. I think their should be a CoordinatePart.TryParse() function to parse either a longitude or latitude part.

Ellipsoid Height & Proper ECEF Functionality

Hi,

This is an excellent Nuget library.

I wanted to convert from ECEF X, Y, Z to Latitude, Longitude and Ellipsoid height (and vice visa)

I would have expected the resultant coord object to have ellipsoid height somewhere but I cannot find it, to my surprise.

var coord = CoordinateSharp.Cartesian.CartesianToLatLong(_x, _y, _z);

Am I missing something?

Thanks
Joshua

Tell Us What You're Using CoordinateSharp For!

How Are You Using CoordinateSharp?

This library took a lot of effort to make, and takes a lot of effort to maintain. It's done so completely for the good of the developer community. Please make it worth while by sharing what you are using the library for in this issue.

A Few Currently Known Real World Uses

-Multiple video games to include the first major use, Walking Dead Our World.
-Air Force Flight Planning Software.
-Coast Guard Mission Management Software.
-Army Artillery Informational Briefings.
-Army Field Medical Communication Tech.
-Power Savings Applications.
-Weather Station Grouping Applications.
-Automated Moon Tracking Telescopes.
-Animal Observation Logging.
-Animal Nutritional Research.
-Digital Combat and Aerial Simulators.
-Mobile Laser Scanning.
-Drone Mesh Networking.
-Multiple Smart Home applications and IoT devices.
-Emergency response guidance.
-UxV simulations.
-And much much more!

Please comment below or shoot us a message as we love to hear how you are using CoordinateSharp!

Other planets of Solar System

As additional to current Sun and Moon in the application...
Is it possible to add Venus and Mars trajectory algorithm
and calculate when their fly near the Earth in perigee

.NET Framework set to 4.51

Framework set to 4.5.1 by mistake on last push. The framework may be lowered to increase compatibility.

Bug: CoordinatePart.TryParse ignores S hemisphere.

The TryParse function withing the CoordinatePart class does not correctly parse a value that is in degree decimal minutes format but only has a hemisphere and a degree value. So for example: "S 37". This input will always parse the hemisphere and change it to N. So "S 37" will be outputted as "N 37 0".
CoordinatePart.TryParse("S 37", CoordinateType.Lat, out var coordPart);
Above the value of coordPart will have a toDouble() of 37 but should really be -37.

This does not occur with Longitude values. So "W 37" will correctly be parsed to return a double value of -37. It only seems to be occurring to the latitude values that have a S hemisphere.

Multi-Framework Targeting for Nuget

As my Nuget skills are limited, I am seeking help/guidance on ways to properly deploy this library to Nuget in a way that allows it to be used on different runtimes such as .NET Standard, Core, Xamarin.iOS, etc. The library code is already compatible with Standard and Core, but when downloaded via Nuget, users will receive compatibility warnings due to what I believe is improper mutli-targeted publishing. I have no clue weather this library can be used with Xamarin.iOS or MonoAndroid.

-The library is currently built in .NET 4.0.

Any assistance with this subject is appreciated.

1.1.3.9 branch Coordinates ctor throws not implemented exception

var eagerLoad = new EagerLoad();
eagerLoad.Cartesian = false;
eagerLoad.Celestial = false;
eagerLoad.UTM_MGRS = false;
coordinate = new Coordinate(lat, lng, eagerLoad);

will throw a not implemented exception at Coordinate.ECEF.cs line 20.

You must include
eagerLoad.ECEF = false;

lunar eclipse

31.01.2018 was the Total Lunar Eclipse

Is it possible to find algorithm of such and later eclipses and add it to the CoordinateSharp application?

Consider using flags / bitmasking enum for eagerload settings

Not much of a problem when you only have 1 or 2 bools to set for eagerload settings, but as more coordinate systems get integrated it would be more concise to have flag enums. For example,
new EagerLoadSettings(CelestialInfo | Cartesian);

I'd be happy to pick this up over the next week or so. Just tell me what branch to work it out in.

Nuget Package Missing Description

1.1.4.4 is missing its description on Nuget. It was removed by mistake while updating the package change summary.

Will be re-added in 1.1.4.5.

1.1.4.1 crashing with .NET Framework 4.6.0

The new version of CoordinateSharp is crashing our IIS website on startup on our staging server but not when run locally in debug. The server is Windows Server 2016 running NET Framework 4.6.0.

The app pool process would die after a few seconds, I took a memory dump and it was seemingly from a stack buffer overflow. Swapping out CoordinateSharp.dll with the previous 1.1.3.9 version fixed the issue.

I cloned the repo and narrowed the issue down. Removing the DebugType from the net40 release configuration in the csproj stopped the crashes:

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net40|AnyCPU'">
  <DocumentationFile>bin\Release\net40\CoordinateSharp.xml</DocumentationFile>
  <DebugSymbols>false</DebugSymbols>
  <DebugType>none</DebugType>
</PropertyGroup>

Does anyone have any ideas why this would break in my environment?

MGRS to Lat/Long incorrect below latitudes of -80.16

A bug was discovered while creating the Test_Proj where conversions of MGRS to Lat/Long below -80.16 degrees latitude incorrectly convert. Latitudes will be off by approximately 19 degrees if conversion is done below the specified latitude.

It should be noted that MGRS conversion should not be done at this latitude anyway as it exceeds MGRS purpose and reliability. This is most likely why this bug hasn't been discovered yet. With that said, this issue will remain open until it is fixed for awareness. However, it will still be recommended that MGRS conversion in circumpolar regions be avoided as it has no real reliability.

Inserting seconds for N & W coordinates

Howdy,
I just found your project and it's fantastic!

But, when i try to insert a UTM/WGS84 coordinate, the seconds part, I'll insert 27.03 as second and will tell me that i Can't.
Am i doing something wrong or is it a bug?

==
Dim c As New CoordinateSharp.Coordinate
c.Latitude = New CoordinateSharp.CoordinatePart(txtwgs84_nd.Text, txtwgs84_nm.Text, txtwgs84_ns.Text, CoordinateSharp.CoordinatesPosition.N, c)
c.Longitude = New CoordinateSharp.CoordinatePart(txtwgs84_wd.Text, txtwgs84_wm.Text, txtwgs84_ws.Text, CoordinateSharp.CoordinatesPosition.W, c)

    c.GeoDate = New DateTime(2019, 1, 5, 11, 56, 0)

    MsgBox(c.Latitude.DecimalDegree & " - " & c.Longitude.DecimalDegree)

==

Thanks in advanced,

Mars opposition

Today is the Great opposition of Mars

in principle, these days could be also included into the library

2018-07-27
2020-10-14
2022-12-08
2025-01-16
2027-02-19
2029-03-25
2018-07-31
2020-10-06
2022-12-01
2025-01-12
2027-02-20
2029-03-29

Coordinate.TryParse() will not accept coordinate without a hemisphere

A coordinate in degree minute second or degree decimal minutes will not be accepted if they do not have a hemisphere value (N, S, E, W). For example a TryParse with latitude as the passed type with "12 12.123" as the coordinate string will not be parsed correctly. That should be parsed to return a double degree value of 12.20205.

1.1.4.3 Some EagerLoadType enums still not working in EagerLoad constructor

Some of the EagerLoadType enums are still not working correctly in the 1.1.4.3 version of the EagerLoad() constructor, in particular these combinations are failing:

failed: EagerLoad(EagerLoadType.Cartesian)
failed: EagerLoad(EagerLoadType.Celestial)
failed: EagerLoad(EagerLoadType.Cartesian | EagerLoadType.Celestial)

They are incorrectly setting the UTM_MGRS property to true instead of false.

Circular references?

It's me again, I was trying to serialize a class containing a Coordinate member but apparently I can't.

      (new System.Web.Script.Serialization.JavaScriptSerializer).Serialize(my_object)

I get an exception that states that it can't serialize the Coordinate instance because of circular references.

I get errors also with Yaml and Json from the Persist library that I am using (it's old tough).

Update: Actually I was able to serialize it with:

(new YamlDotNet.Serialization.Serializer).Serialize(myObject)

It is the underlying lib that Persist uses for Yaml, but it kind of defies the purpose of having the Persist library....

Do you recommend some other library to easily store an object to a file and back that works with CoordinateSharp's coordinates class ?

Add dusk and dawn for sun times?

It would be great to have the times for dusk and dawn calculated and stored as in the original suncalc script. Are there any plans to add this?

sunset is nullable and never sets in Oklahoma?

I realize that the sunset and sunrise are nullable and there are real situations for this (e.g. Alaska).

However, please try this:

        Coordinate c = new Coordinate(33.87515, -95.96789, new DateTime(2019, 2, 6, 1, 39, 22));
        Console.WriteLine(c.CelestialInfo.SunCondition);

Sunset is nullable. Suncondition is NoSet. However, look where the coordinates are:

https://www.google.com/maps/place/33%C2%B052'30.5%22N+95%C2%B058'04.4%22W/@33.5441522,-98.1716845,7.42z/data=!4m5!3m4!1s0x0:0x0!8m2!3d33.87515!4d-95.96789

Last i checked, the sun does set in Oklahoma every day all year around?

Am i doing something wrong or making some assumptions that i shouldn't here?
thanks

new output Property - Distance to the Moon

Good evening
I just want to say thank you for you Celestial c# application
It is interesting to test it

Can I ask just one thing to add
inside Celestial.MoonCalculations.cs
we can see the nice class MoonPosition with property Distance

is it possible to add new property to output - calculated distance from Earth to Moon?
when application provide output in such way
double distance = c.CelestialInfo.MoonDistance;
to know when will be the perigee and apogee day

Calculate sun altitude and azimuth for sun position?

Thanks for a great piece of code. This is excellent. I have added a few requests that I think would make this library more complete. I hope you agree.

The sun's altitude and azimuth currently seem to be missing from the calculations.

FormatException and OutOfRangeException in the constructor

I am passing (41.8532527957705, 12.5651266486892) to the constructor that uses doubles. I believe having a different thread culture may be the cause since this exception looks like it can't read back a date from a string. I use InvariantCulture, if you want to try to reproduce it.

The fix should be to pass a formatprovider taken from the current thread culture I think.

   in System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
   in System.Convert.ToDateTime(String value)
   in CoordinateSharp.SunCalc.CalculateSolarEclipse(DateTime date, Double lat, Double longi, Celestial c)
   in CoordinateSharp.SunCalc.CalculateAdditionSolarTimes(DateTime date, Double longi, Double lat, Celestial c)
   in CoordinateSharp.Celestial.CalculateCelestialTime(Double lat, Double longi, DateTime date)
   in CoordinateSharp.Celestial..ctor(Double lat, Double longi, DateTime geoDate)
   in CoordinateSharp.Coordinate..ctor(Double lat, Double longi)

Anyways after changing the culture to en-us I also get this OutOfRangeException (but I think i randomly got it before too):


   in System.Collections.Generic.List`1.Add(T item)
   in CoordinateSharp.SolarEclipseCalc.Calculate(DateTime d, Double latRad, Double longRad, Double[] ev)
   in CoordinateSharp.SolarEclipseCalc.CalculateSolarEclipse(DateTime d, Double latRad, Double longRad)
   in CoordinateSharp.SunCalc.CalculateSolarEclipse(DateTime date, Double lat, Double longi, Celestial c)
   in CoordinateSharp.SunCalc.CalculateAdditionSolarTimes(DateTime date, Double longi, Double lat, Celestial c)
   in CoordinateSharp.Celestial.CalculateCelestialTime(Double lat, Double longi, DateTime date)
   in CoordinateSharp.Celestial..ctor(Double lat, Double longi, DateTime geoDate)
   in CoordinateSharp.Coordinate..ctor(Double lat, Double longi)

Workaround: Right now I use the eagerload feature to disable celestial calculations and it seems to work.

Calculate time given by user

In MoonIllumination, the time is reset to midnight. This means that it is not possible to get the moon phase throughout the day. Is there any reason for this, or could it easily be fixed to provide times for any time given by the user?

How to move a coordinate?

I was thinking of using the line equation to move torwards another coordinate in the cartesian format.
But I read on the readme page that the cartesian projection is not very accurate.

Is there a way to do that with normal coordinates?

Class bindings not updating formatted string for bound Labels

This issue is stemming from the class not being able to call the ToString() method on property changes. The parent class is handling this currently, but causes issues with Labels.

The next update is going add Format and Display properties to the CoordinatePart class. Format strings will be passed through the Format property and members will bind to the Display property. This will ensure bindings are always up to date.

[proposed help wanted] Calculating beginning of a day (i.e. end of the sunrise)

Is it possible to include calculation of the beginning of a day? I saw that you @Tronald forked the suncalc.net repository which includes this timestamp.

I ported the javascript code to C# code months ago but unfortunately now discovered that there are certain issues with this lib, i.e. the calculated timestamps sometimes don't reflect the day they belong to. I also tried to calculate it myself based on some of the references you also used to create this library before I stumbled upon your code.

In my opinion, CoordinateSharp is the only useful .NET library for those astronomical calculations. Everything else I found either yielded wrong results (as far as I can tell) or insufficient results. The only thing I cannot find is the beginning of the day (or the end of the sunrise) or do I miss something here?

Moon Illumination not saved

The moon's fraction and angle are calculated, but not saved in GetMoonIllumination. Could they be added to the celestial object so that they are available outside of this function?

This could probably easily be added by setting c.MoonIllum = mi;
instead of just c.MoonIllum.Phase = mi.Phase;

and of course add something like "public MoonIllum MoonIllum;" to Celestial.cs

This probably requires moving the declaration of the class MoonIllum outside of the MoonCalc class.

Consider using Unit tests project for running tests

This is a bigger task, but would would have a lot more automation available. Would also prevent things like committing code that throws not implemented exceptions as the unit tests could be run with a pre-commit hook.
I'd be up for this but it might take me a month or so.

[edit] Also are there some sources to verify against? www.earthpoint.us can do a batch conversion which might be a good idea to build a database from that can be used to check a very wide range of coordinates.

Enhancement - Add some polyline, polygon algorithms?

You call this library CoordinateSharp. You added some useful functions like distance between two points, and some astronomic calculations.
Why not add some useful algorithms, very often used with coordinates? I mean:

  • If a point (lat, lon) in inside a polygon.
  • How far is a point from a polyline.
  • etc..
    What do you think?

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.