Beispiel #1
0
    private void DrawSelection()
    {
        Color red = Color.black;

        red.a = 0.6f;

        Color redAlpha = Color.red;

        redAlpha.a = 0.3f;


        int tileRadius = TileManager.tileRadius;

        for (int i = -tileRadius; i <= tileRadius; i++)
        {
            for (int j = -tileRadius; j <= tileRadius; j++)
            {
                OSMBoundingBox box = new OSMBoundingBox(
                    TileManager.OriginLongitude - TileManager.TileWidth / 2d + TileManager.TileWidth * i,
                    TileManager.OriginLatitude - TileManager.TileWidth / 2d + TileManager.TileWidth * j,
                    TileManager.OriginLongitude + TileManager.TileWidth / 2d + TileManager.TileWidth * i,
                    TileManager.OriginLatitude + TileManager.TileWidth / 2d + TileManager.TileWidth * j
                    );
                Vector2 pixelPositionMin = WorldToPixelPosition(box.MinLongitude, box.MinLatitude, ZoomLevel);
                Vector2 pixelPositionMax = WorldToPixelPosition(box.MaxLongitude, box.MaxLatitude, ZoomLevel);
                Vector2 pixelSize        = pixelPositionMax - pixelPositionMin;
                Rect    rect             = new Rect(pixelPositionMin.x - pixelOrigin.x - 1, pixelPositionMin.y - pixelOrigin.y + 1, pixelSize.x - 2, pixelSize.y + 2);
                //CustomGUIUtils.DrawFrameBox(rect, red, 1f, redAlpha);
                GUI.DrawTexture(rect, CustomGUIUtils.GetSimpleColorTexture(redAlpha), ScaleMode.StretchToFill, true);
                //Debug.Log(rect);
            }
        }
    }
Beispiel #2
0
    //private static void DownloadUsingWWW(string url, string tmpfile)
    //{
    //    // Start a download of the given URL
    //    WWW www = new WWW(url);

    //    WWW.LoadFromCacheOrDownload(url, Hash128.Parse(url));
    //    while (!www.isDone)
    //    {
    //        if (www.error != null)
    //        {
    //            //Debug.LogError(www.error);
    //            return false;
    //        }
    //    }

    //    return true;
    //}


    public static OSMBoundingBox Tile2OSMBoundingBox(int xIndex, int yIndex, int zoomLevel)
    {
        OSMBoundingBox bb = new OSMBoundingBox();

        bb.MinLatitude  = Tile2Latitude(yIndex, zoomLevel);
        bb.MaxLatitude  = Tile2Latitude(yIndex + 1, zoomLevel);
        bb.MinLongitude = Tile2Longitude(xIndex, zoomLevel);
        bb.MaxLongitude = Tile2Longitude(xIndex + 1, zoomLevel);
        return(bb);
    }
Beispiel #3
0
    public bool FirstInBounds(OSMBoundingBox box, OSMData osm)
    {
        OSMNode node;

        if (osm.nodes.TryGetValue(WayNodes[0], out node))
        {
            return(node.IsInBounds(box));
        }
        return(false);
    }
Beispiel #4
0
    public static float[,] GetInterpolatedTerrain(OSMBoundingBox boundingBox, out float height)
    {
        float[,] result = new float[257, 257];

        float minHeight = float.MaxValue;
        float maxHeight = float.MinValue;

        for (int i = 0; i < 257; i++)
        {
            for (int j = 0; j < 257; j++)
            {
                result[i, j] = SRTMHeightProvider.GetInterpolatedHeight(boundingBox.MinLatitude + ((double)i / 257) * (boundingBox.MaxLatitude - boundingBox.MinLatitude),
                                                                        boundingBox.MinLongitude + ((double)j / 257) * (boundingBox.MaxLongitude - boundingBox.MinLongitude));
                if (result[i, j] < -32767)
                {
                    continue;
                }

                minHeight = Mathf.Min(result[i, j], minHeight);
                maxHeight = Mathf.Max(result[i, j], maxHeight);
            }
        }

        for (int i = 0; i < 257; i++)
        {
            for (int j = 0; j < 257; j++)
            {
                if (result[i, j] < -32767)
                {
                    result[i, j] = minHeight;
                }
                else
                {
                    result[i, j] = result[i, j] / maxHeight;
                }
            }
        }

        // Prevent zerodivision by TerrainComponent
        if (maxHeight > 0f)
        {
            height = maxHeight;
        }
        else
        {
            height = 1f;
        }

        TerrainLayer.MinTerrainHeight = minHeight;
        TerrainLayer.MaxTerrainHeight = maxHeight;

        return(result);
    }
Beispiel #5
0
    public static void LoadCells(OSMBoundingBox boundingBox)
    {
        int minLatIndex  = (int)System.Math.Floor(boundingBox.MinLatitude);
        int maxLatIndex  = (int)System.Math.Floor(boundingBox.MaxLatitude);
        int minLongIndex = (int)System.Math.Floor(boundingBox.MinLongitude);
        int maxLongIndex = (int)System.Math.Floor(boundingBox.MaxLongitude);

        for (int i = minLatIndex; i < maxLatIndex; i++)
        {
            for (int j = minLongIndex; j < maxLongIndex; j++)
            {
                GetSRTMDataCell(i, j);// new SRTMDataCell(i, j);
            }
        }
    }
Beispiel #6
0
 public bool IsInBounds(OSMBoundingBox box)
 {
     if (latitude > box.MaxLatitude)
     {
         return(false);
     }
     if (latitude < box.MinLatitude)
     {
         return(false);
     }
     if (longitude > box.MaxLongitude)
     {
         return(false);
     }
     if (longitude < box.MinLongitude)
     {
         return(false);
     }
     return(true);
 }