Nothing here yet
richardvasquez / h3netold Goto Github PK
View Code? Open in Web Editor NEWH3NET: A Hexagonal Hierarchical Geospatial Indexing System In C#
License: Apache License 2.0
H3NET: A Hexagonal Hierarchical Geospatial Indexing System In C#
License: Apache License 2.0
Nothing here yet
I was able to get this project to build in Visual Studio 2017, but only after upgrading the target framework. Didn't want to issue a pull request with such a big framework change, but after noticing that conversions between H3 and latitude/longitude were incorrect and that geo boundaries were not being generated correctly, I wrote this unit test for these conversions using the res0#ic.txt files in the input directory:
public static string[] ICFileNameStrings() => new [] { "res00ic.txt", "res01ic.txt", "res02ic.txt", "res03ic.txt", "res04ic.txt" };
[Test, Sequential]
public async Task Conversions_H3Index_GeoCoord([ValueSource("ICFileNameStrings")] string filename)
{
for (int i = 0; i <= 4; i++)
{
var fileName = $"res0{i}ic.txt";
var path = Path.Combine(TestContext.CurrentContext.TestDirectory, "input", fileName);
using (var sr = new StreamReader(path))
{
while (!sr.EndOfStream)
{
var line = await sr.ReadLineAsync();
var match = Regex.Match(line,
@"(?<h3>\w+)\s(?<lat>[-+]?([0-9]*\.[0-9]+|[0-9]+))\s(?<lon>[-+]?([0-9]*\.[0-9]+|[0-9]+))");
var h3str = match.Groups["h3"].Value;
var lat = double.Parse(match.Groups["lat"].Value);
var lon = double.Parse(match.Groups["lon"].Value);
var h3index = new H3Index(ulong.Parse(h3str, NumberStyles.HexNumber));
var coord = new GeoCoord(lat, lon);
assertExpected(h3index, ref coord);
}
}
}
}`
I was testing H3.Net and wanted to cross check it against Javascript version of the api at 3.2.0. I realized that the H3Index generated by .Net version and JS version differs even though they both are returned as valid index.
.Net code
GeoCoord gc = new GeoCoord(27.700769, 85.300140);
var index = Api.GeoToH3(gc, 7);
Console.WriteLine(index);
Console.WriteLine(Api.H3IsValid(index));
Result:
873F512E5FFFFFF
1
JavaScript code: (npm install [email protected])
const h3 = require("h3-js");
const h3Index = h3.geoToH3(27.700769, 85.300140, 7);
console.log(h3Index);
console.log(h3.h3IsValid(h3Index));
Result:
873c02992ffffff
true
Note: JS will produce same index for newer version of H3.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.