Exemplo n.º 1
0
    private void UpdateProjectionValues()
    {
        if (grid.countY == 0)
        {
            return;
        }

        int count = grid.countY + 1;

        if (projection == null || projection.width != count)
        {
            CreateProjectionBuffer(count);
        }

        double min         = GeoCalculator.LatitudeToNormalizedMercator(grid.south);
        double max         = GeoCalculator.LatitudeToNormalizedMercator(grid.north);
        double invLatRange = (1.0 / (grid.north - grid.south));

        float[] lats            = new float[count];
        double  projLatInterval = (max - min) / (count - 1);

        for (int i = 0; i < count; i++)
        {
            double projLat = min + i * projLatInterval;
            double lat     = (2 * Math.Atan(Math.Exp(projLat * Math.PI)) - HalfPI) * Rad2Deg;
            lats[i] = Mathf.Clamp01((float)(1 - (lat - grid.south) * invLatRange));
        }
        byte[] latBytes = new byte[lats.Length * 4];
        Buffer.BlockCopy(lats, 0, latBytes, 0, latBytes.Length);
        projection.LoadRawTextureData(latBytes);
        projection.Apply();
    }
    //
    // Private/Protected Methods
    //

    private void UpdateProjectionValues()
    {
        double min         = GeoCalculator.LatitudeToNormalizedMercator(bounds.south);
        double max         = GeoCalculator.LatitudeToNormalizedMercator(bounds.north);
        double invLatRange = 1.0 / (bounds.north - bounds.south);

        float[] lats            = new float[ProjectionResolution];
        double  projLatInterval = (max - min) / (ProjectionResolution - 1);

        for (int i = 0; i < ProjectionResolution; i++)
        {
            double projLat = min + i * projLatInterval;
            double lat     = (2 * Math.Atan(Math.Exp(projLat * Math.PI)) - HalfPI) * Rad2Deg;
            lats[i] = Mathf.Clamp01((float)(1 - (lat - bounds.south) * invLatRange));
        }
        byte[] latBytes = new byte[lats.Length * 4];
        Buffer.BlockCopy(lats, 0, latBytes, 0, latBytes.Length);
        projection.LoadRawTextureData(latBytes);
        projection.Apply();
    }