novotnyllc / s2-geometry-library-csharp Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
can i use this library to have several grids and query the cell values at some latitude and longitude? for example i want to know at position X the value of the cell that goes from 0 to 5 for how dangerous is that cell and another grid that goes from 0 to 200 for the max speed alowed if it is a street or highway or else.
I am trying to get the level 10 cell ID for central Manchester.
Google says its coordinate is 53.479683, -2.242776. So i tried it like that:
S2LatLng ll = S2LatLng.FromDegrees(53.479683, -2.242776);
But now if i try to get the ID like this:
S2CellId.FromLatLng(ll).Id.ToString();
It returns the wrong cell ID and
S2CellId.FromLatLng(ll).Level
is always level 30 without any chance of choosing it. How can i set the S2 cell level i like and get the right cell ID?
I occasionally get the following exception when getting a covering for a large area. It sometimes succeeds (guessing 10-20% of the time in this case, however it seems to be random). This doesn't seem to happen with lower level's like 10.
Error:
Additional information: The runtime has encountered a fatal error. The address of the error was at 0x705fe24f, on thread 0x2dc0. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.
Code to reproduce:
using System.Collections.Generic;
using Google.Common.Geometry;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var region_rect = S2LatLngRect.FromPointPair(S2LatLng.FromRadians(0.733204387077201, -1.99196858250162), S2LatLng.FromRadians(0.567830031749048, -2.17145323019111));
var coverer = new S2RegionCoverer()
{
MaxLevel = 13,
MinLevel = 13
};
var covering = new List<S2CellId>();
coverer.GetCovering(region_rect, covering);
}
}
}
C5 has a known issue that prevents it from compiling with .NET Native due to infinite expansion.
I suggest you use native .NET collections in place of C5. I used HashSet and Dictionary in place of HashBag and HashDictionary and the library appears to work correctly.
๐ or ๐
I need to extract Lat/Lng coordinates from a given CellId, but I'm having a slight difference netween the returned values and the correct ones, and I can't understand why.
The original coordinates are
47.678956162876,-122.12871664749933
while the CellId
is
6093384589483442176
What I get back is
47.72217122031298,-122.12705319813203
Here's a little snippet of my code:
var cellId = new S2CellId(CellId).ToLatLng();
return new Geopoint(new BasicGeoposition() {Latitude = cellId.LatDegrees, Longitude = cellId.LngDegrees})
Am I doing something wrong or is there an issue when converting back to Lat/Lng?
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.