private List <Tile> MakeTileMatrix(int levelOfDetail, List <List <AltitudeResponse> > altitudes)
        {
            List <Tile> tileMatrix = new List <Tile>();

            foreach (var line in altitudes)
            {
                foreach (var point in line)
                {
                    TileSystem.LatLongToPixelXY(point.Location.Lat, point.Location.Lng, levelOfDetail, out var pixelX, out var pixelY);
                    TileSystem.PixelXYToTileXY(pixelX, pixelY, out var tileX, out var tileY);
                    TileSystem.MapPixelXYToTileInnerPixelXY(pixelX, pixelY, out var tileInnerX, out var tileInnerY);

                    MapPoint mapPoint = new MapPoint(tileInnerX, tileInnerY, point.Elevation);

                    if (mapPoint.Z > 0)
                    {
                        Tile tile = tileMatrix.FirstOrDefault(t => t.TileX == tileX && t.TileY == tileY);
                        if (tile == null)
                        {
                            tile = new Tile(levelOfDetail, tileX, tileY);
                            tileMatrix.Add(tile);
                        }
                        tile.Points.Add(mapPoint);
                    }
                }
            }
            return(tileMatrix);
        }
Beispiel #2
0
    public static QkTile GetQktileFromPix(Vector2Int pix, int lod)
    {
        TileSystem.PixelXYToTileXY(pix.x, pix.y, out var xidx, out var yidx);
        var rv = new QkTile(lod, xidx, yidx);

        return(rv);
    }
Beispiel #3
0
 public static RelativePixel GetRelativePixel(double lat, double lon, int zoom)
 {
     TileSystem.LatLongToPixelXY(lat, lon, zoom, out int pixelX, out int pixelY);
     TileSystem.PixelXYToTileXY(pixelX, pixelY, out int tileX, out int tileY);
     return(new RelativePixel()
     {
         pixel = new Point(pixelX - (256 * tileX), pixelY - (256 * tileY)),
         tile = new Point(tileX, tileY)
     });
 }
        public void PixelXYToTileXY_ShouldReturnCorrectTileXYCoordinates()
        {
            int pileX = 876680;
            int pileY = 481296;

            (int tileX, int tileY)expected = (3424, 1880);

            (int tileX, int tileY)actual = TileSystem.PixelXYToTileXY(pileX, pileY);

            Assert.Equal(expected, actual);
        }
Beispiel #5
0
        /// <summary>
        /// This will list all the affected assets affected by lightning strikes.
        /// </summary>
        /// <returns>A collection of Asset objects.</returns>
        public List <Asset> ListAffectedAssets()
        {
            // This will get the data of lightning strikes.
            var strikes = _dataContext.Strikes
                          .Where(x => x.FlashType == FlashType.CloudToGround);

            // This will initialize the quad key collection.
            var quadKeys = new List <string>();

            // This will iterate through the collection of lightning strikes.
            foreach (var item in strikes)
            {
                // This will initialize the required values
                int pixelX, pixelY, tileX, tileY;

                // This will convert the inital longitude and latitude value to pixel x and y values.
                TileSystem.LatLongToPixelXY(item.Latitude, item.Longitude, 12, out pixelX, out pixelY);

                // This will convert the pixel x and y values to tile x and y values.
                TileSystem.PixelXYToTileXY(pixelX, pixelY, out tileX, out tileY);

                // This will convert the tile x and y values to a usable quad key.
                var quadKey = TileSystem.TileXYToQuadKey(tileX, tileY, 12);

                // This will determine if the resulting quad key already exists in the collection.
                if (!quadKeys.Contains(quadKey))
                {
                    // This will add the quad key to the quad key collection.
                    quadKeys.Add(quadKey);
                }
            }
            // This will extract the affected assets by their quad key.
            var affectedAssets = _dataContext.Assets.Where(x => quadKeys.Contains(x.QuadKey));

            return(affectedAssets.ToList());
        }
Beispiel #6
0
 public static Point LatLonToTileCoordinate(double latitude, double longitude, int zoomFactor)
 {
     TileSystem.LatLongToPixelXY(latitude, longitude, zoomFactor, out int pixelX, out int pixelY);
     TileSystem.PixelXYToTileXY(pixelX, pixelY, out int tileX, out int tileY);
     return(new Point(tileX, tileY));
 }