Files
Ultimate-Fishing-Simulator-…/Assets/Scripts/Assembly-CSharp/MultiBandsLoader.cs
2026-03-04 09:37:33 +08:00

74 lines
2.2 KiB
C#

using System.Collections;
using GISTech.GISTerrainLoader;
using UnityEngine;
using UnityEngine.UI;
public class MultiBandsLoader : MonoBehaviour
{
public Text data;
private string MultibandTiffPath = Application.streamingAssetsPath + "/GIS Terrains/Example_Tiff_MultiBands/MultiBands_Tiff.tif";
private DVector2 LatLonPosition = new DVector2(-119.9581587375, 38.940618894);
private GISTerrainLoaderPrefs Prefs = new GISTerrainLoaderPrefs();
private void Start()
{
StartCoroutine(LoadTiffBands());
}
private IEnumerator LoadTiffBands()
{
InitializingRuntimePrefs(Prefs);
if (Application.platform == RuntimePlatform.WebGLPlayer || Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
{
byte[] FileData = new byte[0];
yield return StartCoroutine(GISTerrainLoaderPlatformHelper.LoadFileBytes(Prefs.TerrainFilePath, delegate(byte[] Fdata)
{
FileData = Fdata;
}));
GISTerrainLoaderTiffMultiBands rasterBands = GISTerrainLoaderTIFFLoader.LoadTiffBands(Prefs, FileData);
ParseData(rasterBands);
}
else
{
GISTerrainLoaderTiffMultiBands rasterBands = GISTerrainLoaderTIFFLoader.LoadTiffBands(Prefs);
ParseData(rasterBands);
}
}
private void InitializingRuntimePrefs(GISTerrainLoaderPrefs Prefs)
{
Prefs.LoadSettings();
Prefs.TerrainFilePath = MultibandTiffPath;
Prefs.projectionMode = ProjectionMode.Geographic;
}
private void ParseData(GISTerrainLoaderTiffMultiBands RasterBands)
{
float[] values = RasterBands.GetValues(RasterBands.BandsNumber, LatLonPosition);
for (int i = 0; i < values.Length; i++)
{
float num = values[i];
string text = "Value For Band N : " + i + " " + num;
Text text2 = data;
text2.text = text2.text + "\n" + text;
Debug.Log(text);
}
int num2 = 7;
float value = RasterBands.GetValue(num2, LatLonPosition);
string text3 = "Value For Band N : " + num2 + " " + value;
Text text4 = data;
text4.text = text4.text + "\n" + text3;
Debug.Log(text3);
int row = 194;
int col = 305;
float value2 = RasterBands.GetValue(num2, row, col);
text3 = "Band : " + num2 + " " + value2;
Text text5 = data;
text5.text = text5.text + "\n" + text3;
Debug.Log(text3);
}
}