64 lines
2.3 KiB
C#
64 lines
2.3 KiB
C#
using System.Collections;
|
|
using GISTech.GISTerrainLoader;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class ParseOSMFile : MonoBehaviour
|
|
{
|
|
public Text TextData;
|
|
|
|
private string OSMFilePath = Application.streamingAssetsPath + "/GIS Terrains/Example_VectorData/Desert_VectorData/OSM_Cuenca.osm";
|
|
|
|
private GISTerrainLoaderPrefs Prefs = new GISTerrainLoaderPrefs();
|
|
|
|
private void Start()
|
|
{
|
|
StartCoroutine(LoadOSMFile());
|
|
}
|
|
|
|
private IEnumerator LoadOSMFile()
|
|
{
|
|
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;
|
|
}));
|
|
new GISTerrainLoaderOSMFileLoader(FileData);
|
|
}
|
|
GISTerrainLoaderOSMFileLoader gISTerrainLoaderOSMFileLoader = new GISTerrainLoaderOSMFileLoader(Prefs.TerrainFilePath);
|
|
if (gISTerrainLoaderOSMFileLoader != null)
|
|
{
|
|
ParseData(gISTerrainLoaderOSMFileLoader);
|
|
}
|
|
}
|
|
|
|
private void InitializingRuntimePrefs(GISTerrainLoaderPrefs m_Prefs)
|
|
{
|
|
m_Prefs.LoadSettings();
|
|
m_Prefs.TerrainFilePath = OSMFilePath;
|
|
}
|
|
|
|
private void ParseData(GISTerrainLoaderOSMFileLoader osmloader)
|
|
{
|
|
GISTerrainLoaderGeoVectorData geoFiltredData = osmloader.GetGeoFiltredData("ParseOSMDemo");
|
|
TextData.text += "\n OSM File Loaded Correctly : ";
|
|
int count = geoFiltredData.GeoPoints.Count;
|
|
int count2 = geoFiltredData.GeoLines.Count;
|
|
int count3 = geoFiltredData.GeoPolygons.Count;
|
|
Text textData = TextData;
|
|
textData.text = textData.text + "\n Number Of Points: " + count + ", Lines : " + count2 + ", Polygons : " + count3;
|
|
GISTerrainLoaderGeoVectorData vectorDataByKeyValue = geoFiltredData.GetVectorDataByKeyValue("building", "residential", GeoVectorType.Polygon);
|
|
Text textData2 = TextData;
|
|
textData2.text = textData2.text + "\nNumber of Buildings with 'residential' Tag : " + vectorDataByKeyValue.GeoPolygons.Count;
|
|
for (int i = 0; i < vectorDataByKeyValue.GeoPolygons.Count; i++)
|
|
{
|
|
GISTerrainLoaderPolygonGeoData gISTerrainLoaderPolygonGeoData = vectorDataByKeyValue.GeoPolygons[i];
|
|
Text textData3 = TextData;
|
|
textData3.text = textData3.text + "\n building id : " + gISTerrainLoaderPolygonGeoData.ID;
|
|
}
|
|
}
|
|
}
|