1 using System.Collections;
2 using System.Collections.Generic;
3 using System.Globalization;
16 public double altitude;
17 public string altitudeMode;
20 public float movementSmoothing;
21 public int maxNumberOfLocationUpdates;
22 public bool useMovingAverage;
23 public bool hideObjectUtilItIsPlaced;
25 public AltitudeMode getAltitudeMode()
27 if (altitudeMode ==
"GroundRelative") {
28 return AltitudeMode.GroundRelative;
29 }
else if (altitudeMode ==
"DeviceRelative") {
30 return AltitudeMode.DeviceRelative;
31 }
else if (altitudeMode ==
"Absolute") {
32 return AltitudeMode.Absolute;
34 return AltitudeMode.Ignore;
54 private List<DataEntry> _dataEntries =
new List<DataEntry>();
55 private List<GameObject> _stages =
new List<GameObject>();
56 private List<PlaceAtLocation> _placeAtComponents =
new List<PlaceAtLocation>();
65 void BuildGameObjects()
67 foreach (var entry
in _dataEntries)
73 Debug.LogWarning($
"[ARLocation#WebMapLoader]: Prefab {entry.meshId} not found.");
77 var PlacementOptions =
new PlaceAtLocation.PlaceAtOptions()
79 MovementSmoothing = entry.movementSmoothing,
80 MaxNumberOfLocationUpdates = entry.maxNumberOfLocationUpdates,
81 UseMovingAverage = entry.useMovingAverage,
82 HideObjectUntilItIsPlaced = entry.hideObjectUtilItIsPlaced
85 var location =
new Location()
88 Longitude = entry.lng,
89 Altitude = entry.altitude,
90 AltitudeMode = entry.getAltitudeMode(),
94 var instance = PlaceAtLocation.CreatePlacedInstance(Prefab,
99 _stages.Add(instance);
108 Debug.Log(xmlString);
110 XmlDocument xmlDoc =
new XmlDocument();
113 xmlDoc.LoadXml(xmlString);
114 }
catch(XmlException e) {
115 Debug.LogError(
"[ARLocation#WebMapLoader]: Failed to parse XML file: " + e.Message);
118 var root = xmlDoc.FirstChild;
119 var nodes = root.ChildNodes;
120 foreach (XmlNode node
in nodes)
122 Debug.Log(node.InnerXml);
123 Debug.Log(node[
"id"].InnerText);
125 int id =
int.Parse(node[
"id"].InnerText);
126 double lat =
double.Parse(node[
"lat"].InnerText, CultureInfo.InvariantCulture);
127 double lng =
double.Parse(node[
"lng"].InnerText, CultureInfo.InvariantCulture);
128 double altitude =
double.Parse(node[
"altitude"].InnerText, CultureInfo.InvariantCulture);
129 string altitudeMode = node[
"altitudeMode"].InnerText;
130 string name = node[
"name"].InnerText;
131 string meshId = node[
"meshId"].InnerText;
132 float movementSmoothing =
float.Parse(node[
"movementSmoothing"].InnerText, CultureInfo.InvariantCulture);
133 int maxNumberOfLocationUpdates =
int.Parse(node[
"maxNumberOfLocationUpdates"].InnerText);
134 bool useMovingAverage =
bool.Parse(node[
"useMovingAverage"].InnerText);
135 bool hideObjectUtilItIsPlaced =
bool.Parse(node[
"hideObjectUtilItIsPlaced"].InnerText);
137 DataEntry entry =
new DataEntry() {
141 altitudeMode = altitudeMode,
145 movementSmoothing = movementSmoothing,
146 maxNumberOfLocationUpdates = maxNumberOfLocationUpdates,
147 useMovingAverage =useMovingAverage,
148 hideObjectUtilItIsPlaced = hideObjectUtilItIsPlaced };
150 _dataEntries.Add(entry);
152 Debug.Log($
"{id}, {lat}, {lng}, {altitude}, {altitudeMode}, {name}, {meshId}, {movementSmoothing}, {maxNumberOfLocationUpdates}, {useMovingAverage}, {hideObjectUtilItIsPlaced}");