/* INFINITY CODE */
/* https://infinity-code.com */
using System;
using System.Collections.Generic;
using UnityEngine;
namespace InfinityCode.RealWorldTerrain.OSM
{
///
/// This class contains meta-information about the building.
///
[Serializable]
[AddComponentMenu("")]
public class RealWorldTerrainOSMMeta : MonoBehaviour
{
///
/// The coordinate of the center point of the building
///
public Vector2 center;
///
/// Indicates that building has a URL.
///
public bool hasURL;
///
/// Indicates that building has a website.
///
public bool hasWebsite;
///
/// Indicates that building has a Wikipedia page.
///
public bool hasWikipedia;
///
/// Array of meta-information.
///
public RealWorldTerrainOSMMetaTag[] metaInfo;
private void AddInfo(string title, string info)
{
if (metaInfo == null) metaInfo = new RealWorldTerrainOSMMetaTag[0];
List metaList = new List(metaInfo)
{
new RealWorldTerrainOSMMetaTag {info = info, title = title}
};
if (title == "url") hasURL = true;
else if (title == "website") hasWebsite = true;
else if (title == "wikipedia") hasWikipedia = true;
metaInfo = metaList.ToArray();
}
public bool ContainKeyOrValue(string tag, bool searchInKey, bool searchInValue)
{
if (metaInfo == null) return false;
for (int i = 0; i < metaInfo.Length; i++)
{
RealWorldTerrainOSMMetaTag t = metaInfo[i];
if (t.CompareKeyOrValue(tag, searchInKey, searchInValue)) return true;
}
return false;
}
public RealWorldTerrainOSMMeta GetFromOSM(RealWorldTerrainOSMBase item, Vector2 center = default(Vector2))
{
foreach (RealWorldTerrainOSMTag itemTag in item.tags) AddInfo(itemTag.key, itemTag.value);
this.center = center;
return this;
}
}
}