-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Examples #48
Comments
Hi @infinityplusb, Agreed -- documentation / examples (and in particular, differences vs. the upstream library) are on my list of things to try and improve for the next release. I've just been swamped with other work-things as of late and haven't had any time yet to crank it out.
|
So, I actually tried to port it to netstandard2.0 (because I am actually wanting to use it as part of Unity Game Engine for some displays), so it's possible I messed up something on the port. Anyway the code I'm trying to run: static void Main(string[] args)
{
Console.WriteLine("Hello World!");
double lat = -37.81753;
double lng = 144.96715;
GeoCoord melb = new GeoCoord(lat, lng);
// 10 - 622496586184982527
// 9 - 617992986557677567
H3Index melbH3 = H3Index.FromGeoCoord(melb, 10);
Console.WriteLine(melbH3);
Console.WriteLine("Melb Lat, Long: " + melb.Latitude + "," + melb.Longitude);
var CellBoundariesVertArray = melbH3.GetCellBoundaryVertices().ToArray();
Console.WriteLine("Cell Boundaries Vertices: ");
for (int i = 0; i< CellBoundariesVertArray.Length; i++)
{
Console.WriteLine("Vertex: " + (i+1));
var thing = CellBoundariesVertArray[i];
// Trying a few different things to test
Console.WriteLine("ToCoordinate: " + thing.ToCoordinate());
Console.WriteLine("ToPoint: " + thing.ToPoint());
Console.WriteLine("ToPoint Length: " + thing.ToPoint().Length);
Console.WriteLine("Lat, Long: " + thing.Latitude + "," + thing.Longitude);
Console.WriteLine();
}
} The output I get looks like:
|
Ah, interesting ok. I'd be interested in seeing what you ended up having to do to go back to In this case, I think I've found your issue though:
As I mentioned previously, |
So that doesn't let me call use
I can add in an overload public static GeoCoord FromCoordinate(double latd, double lngd) => new()
{
Latitude = latd * M_PI_180,
Longitude = lngd * M_PI_180
}; which means I end up with a different hash value
|
Err.. yeah, see that's what happens when I respond to issues before coffee. I meant
So, in using H3.Extensions;
using H3.Model;
using NetTopologySuite.Geometries;
using System;
using System.Linq;
namespace H3.Test {
public class Program {
static void Main(string[] args) {
var melbCoord = new Coordinate(144.96715, -37.81753);
var melb = H3Index.FromGeoCoord(GeoCoord.FromCoordinate(melbCoord), 10);
Console.WriteLine(melb.ToString());
var vertices = melb.GetCellBoundaryVertices().ToArray();
foreach (var vertex in vertices) {
Console.WriteLine(vertex.ToCoordinate());
}
}
}
} And I get:
Or Which looks like its working ok.. so if you're still having issues then it could be related to your port. I'll create a new issue to formally support |
@infinityplusb I had a quick look at your fork and used that as a guide for implementing support for Along those lines, if there's anything else package or documentation-wise that helps for utilizing this in Unity, it'd be great if you would be able to contribute those bits so that I can include them in the next release. FYI, I think this might actually be your bug -- your "polyfill" for double sinLon = Clamp(Math.Sin(az) * sinDist / cosP2Lat, -1.0, 1.0);
double cosLon = Clamp((cosDist - sinP1Lat * Math.Sin(p2.Latitude)) / cosP1Lat / cosP2Lat, -1.0, 1.0); public static T Clamp<T>(T value, T max, T min)
where T : System.IComparable<T>
{
T result = value;
if (value.CompareTo(max) > 0)
result = max;
if (value.CompareTo(min) < 0)
result = min;
return result;
} whereas Cheers! |
@infinityplusb I've added some basic documentation in this branch as well. I'm hoping to release in the next week or two depending on how busy things are with work. Let me know if there's anything else in particular you're looking for and I'd be happy to help. |
That's what I get for copy-pasting stuff from StackOverflow! I'll try draw it and see what that looks like :) |
I think that's because of the implicit operator for converting to Glad to hear that was your issue. I am going to go ahead and close this now; feel free to yell at me or open a new issue if you have any further questions or difficulties! |
Just trying to get some of the library working, but running into some issues.
In particular, at the moment is finding the vertices of a H3 cell.
I'm trying to use
but vertices is of length 0. :(
if I use
that doesn't seem to be returning anything useful.
It'd be great to have some examples of simple stuff like that, and/or some sort of comparison between this api and the "standard" api.
TIA
The text was updated successfully, but these errors were encountered: