/// <summary> /// Returns the NW, NE, SW, SE corners of the township /// </summary> /// <param name="township"></param> /// <param name="range"></param> /// <param name="meridian"></param> /// <returns></returns> internal LatLongCorners[] TownshipMarkers(byte township, byte range, byte meridian) { //ask the boundary provider for a list of sections that border this township //each township is numbered as: // 31|32|33|34|35|36 // 30|29|28|27|26|25 // 19|20|21|22|23|24 // 18|17|16|15|14|13 // 07|08|09|10|11|12 // 06|05|04|03|02|01 //look at each coordinate pair until we find ones that are the extreme corners var key = (ushort)(meridian << 13 | range << 7 | township); if (!_offsets.TryGetValue(key, out var townshipFloats)) { return(null); } int section = 0; var corners = new LatLongCorners[36]; for (int offset = 0; offset < 288; offset += 8) { var se = LatLongCoordinate(townshipFloats, offset + 0); var sw = LatLongCoordinate(townshipFloats, offset + 2); var nw = LatLongCoordinate(townshipFloats, offset + 4); var ne = LatLongCoordinate(townshipFloats, offset + 6); // Build a boundary object that contains 1-4 corners. corners[section] = new LatLongCorners(se, sw, nw, ne); section++; } return(corners); }
private static LatLongCoordinate Interpolate4Point(byte legalSubdivision, LatLongCorners geoList) { if (geoList.SouthEast == null || geoList.SouthWest == null || geoList.NorthWest == null || geoList.NorthEast == null) { return(LatLongCoordinate.Origin); } var lat = new float[2, 2]; var lng = new float[2, 2]; lat[0, 0] = geoList.SouthWest.Value.Latitude; lat[0, 1] = geoList.SouthEast.Value.Latitude; lat[1, 0] = geoList.NorthWest.Value.Latitude; lat[1, 1] = geoList.NorthEast.Value.Latitude; lng[0, 0] = geoList.SouthWest.Value.Longitude; lng[0, 1] = geoList.SouthEast.Value.Longitude; lng[1, 0] = geoList.NorthWest.Value.Longitude; lng[1, 1] = geoList.NorthEast.Value.Longitude; return(BilinearInterpolate(legalSubdivision, lat, lng)); }