public void PointInsideGeofenceTransmeridian() { var verts = new[] { new GeoCoord(0.01m, -Constants.H3.M_PI + 0.01m), new GeoCoord(0.01m, Constants.H3.M_PI - 0.01m), new GeoCoord(-0.01m, Constants.H3.M_PI - 0.01m), new GeoCoord(-0.01m, -Constants.H3.M_PI + 0.01m) }; var transMeridianGeofence = new GeoFence { NumVerts = 4, Verts = verts }; var eastPoint = new GeoCoord(0.001m, -Constants.H3.M_PI + 0.001m); var eastPointOutside = new GeoCoord(0.001m, -Constants.H3.M_PI + 0.1m); var westPoint = new GeoCoord(0.001m, Constants.H3.M_PI - 0.001m); var westPointOutside = new GeoCoord(0.001m, Constants.H3.M_PI - 0.1m); var bbox = transMeridianGeofence.ToBBox(); Assert.IsTrue(transMeridianGeofence.PointInside(bbox, westPoint)); Assert.IsTrue(transMeridianGeofence.PointInside(bbox, eastPoint)); Assert.IsFalse(transMeridianGeofence.PointInside(bbox, westPointOutside)); Assert.IsFalse(transMeridianGeofence.PointInside(bbox, eastPointOutside)); }
public void PointInsideLinkedGeoLoop() { var somewhere = new GeoCoord(1, 2); var inside = new GeoCoord(0.659m, -2.136m); var loop = CreateLinkedLoop(SfVerts); var box = loop.ToBBox(); Assert.IsTrue(loop.PointInside(box, inside)); Assert.IsFalse(loop.PointInside(box, somewhere)); loop.Clear(); }
public void PointInsideGeofence() { var geofence = new GeoFence { NumVerts = 6, Verts = SfVerts }; var inside = new GeoCoord(0.659m, -2.136m); var somewhere = new GeoCoord(1, 2); BBox bbox = geofence.ToBBox(); Assert.IsFalse(geofence.PointInside(bbox, SfVerts[0])); Assert.IsTrue(geofence.PointInside(bbox, SfVerts[4])); Assert.IsTrue(geofence.PointInside(bbox, inside)); Assert.IsFalse(geofence.PointInside(bbox, somewhere)); }
/// <summary> /// Find the Vertex node for a given edge, if it exists /// </summary> /// <param name="fromNode">Start vertex</param> /// <param name="toNode">End vertex, or NULL if we don't care</param> /// <returns>Reference to the vertex node, if found</returns> /// <!-- /// vertexGraph.c /// VertexNode* findNodeForVertex /// --> public VertexNode?FindEdge(GeoCoord fromNode, GeoCoord?toNode) { var possibles = _pool.Where(p => p.From == fromNode).ToList(); if (possibles.Count == 0) { return(null); } if (toNode == null) { return(possibles.First());//good luck! } List <VertexNode> answer = possibles.Where(p => p.To == toNode).ToList(); if (answer.Count == 0) { return(null); } return(answer.First()); }
/// <summary> /// average hexagon edge length in meters (excludes pentagons) /// </summary> public static decimal EdgeLengthM(int r) { return(GeoCoord.EdgeLengthM(r)); }
/// <summary> /// find the lat/lon center point g of the cell h3 /// </summary> public static void H3ToGeo(H3Index h3, out GeoCoord g) { g = h3.ToGeoCoord(); }
/// <summary> /// average hexagon area in square meters (excludes pentagons) /// </summary> public static decimal HexAreaM2(int r) { return(GeoCoord.HexAreaM2(r)); }
/// <summary> /// "great circle distance" between pairs of GeoCoord points in meters*/ /// </summary> public static decimal PointDistM(GeoCoord a, GeoCoord b) { return(a.DistanceToM(b)); }
/// <summary> /// "great circle distance" between pairs of GeoCoord points in radians*/ /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public static decimal PointDistRads(GeoCoord a, GeoCoord b) { return(a.DistanceToRadians(b)); }
/// <summary> /// find the H3 index of the resolution res cell containing the lat/lng /// </summary> public static H3Index GeoToH3(GeoCoord g, int r) { return(g.ToH3Index(r)); }
/// <summary> /// mutator to change vertex /// </summary> public LinkedGeoCoord Replacement(GeoCoord gc) { return(new LinkedGeoCoord(gc)); }
/// <summary> /// constructor with vertex /// </summary> public LinkedGeoCoord(GeoCoord gc) { _gc = gc; }
/// <summary> /// constructor /// </summary> public LinkedGeoCoord() { _gc = default; }
/// <summary> /// Constructor /// </summary> /// <param name="toNode"></param> /// <param name="fromNode"></param> public VertexNode(GeoCoord toNode, GeoCoord fromNode) { To = toNode; From = fromNode; }
/// <summary> /// Create a new node based on two GeoCoords /// </summary> /// <!-- /// vertexGraph.c /// void _initVertexNode /// --> private static VertexNode InitNode(GeoCoord fromNode, GeoCoord toNode) { return(new VertexNode(toNode, fromNode)); }
/// <summary>Find a Vertex node starting at the given vertex</summary> /// <param name="vertex">fromVtx Start vertex</param> /// <returns>Pointer to the vertex node, if found</returns> /// <!-- /// vertexGraph.c /// VertexNode* findNodeForVertex /// --> public VertexNode?FindVertex(GeoCoord vertex) { return(FindEdge(vertex, null)); }