private void AppendObjectsToMap(ManMadeObject[] objectList) { var objCount = objectList.Length; var listOfPoints = new List <MapPoint>(); for (var index = 0; index < objCount; index++) { var obj = objectList[index]; if (obj.production?.location == null) { continue; } /* * if (numObject == 300) * Debug.Log("EL 300 es " + obj.id); * * if (numObject == 3000) * Debug.Log("EL 3000 es " + obj.id); * * if (numObject == 15000) * Debug.Log("EL 15000 es " + obj.id); * * numObject++; */ /* PRUEBA RENDIMIENTO */ var listOfCenturies = new List <TimeElement>(); if (obj.production?.time.Length > 0) { foreach (var timeElement in obj.production.time) { if (APIManager.instance.timeValues.TryGetValue(timeElement, out var time)) { listOfCenturies.Add(time); } } listOfCenturies = listOfCenturies.OrderBy(t => t.century).ToList(); } var objCategory = categoriesGroups[0]; var listOfCategories = new List <string>(); if (obj.production?.category != null && obj.production.category?.Length > 0 && obj.production.category[0] != null && obj.production.category[0].label != null) { listOfCategories = obj.production.category.Select(s => s.label).ToList(); switch (listOfCategories.Count) { case 0: objCategory = categoriesGroups[0]; break; case 1: { objCategory = categoriesDictionary.TryGetValue(listOfCategories[0], out var cat) ? cat : categoriesGroups[0]; break; } default: { var selectedCategories = new List <ScriptableCategory>(); foreach (var categoryName in listOfCategories) { if (!categoriesDictionary.TryGetValue(categoryName, out var cat)) { continue; } if (!selectedCategories.Contains(cat)) { selectedCategories.Add(cat); } } objCategory = selectedCategories.Count > 1 ? categoriesGroups[1] : selectedCategories[0]; selectedCategories.Clear(); break; } } } /* PRUEBA RENDIMIENTO */ foreach (var currentLocation in obj.production?.location) { var latitude = currentLocation.lat; var longitude = currentLocation.@long; if (float.IsNaN(latitude) || float.IsNaN(longitude)) { continue; } // Cada MapPoint tiene una serie de propiedades, la posición, escala y altitud vienen dentro de un objeto // MapPointMarker de OnlineMaps // Se añade la posicion (lat,long) y se asocia a un objeto 3d Cube, luego puede cambiarse var mapPoint = new MapPointMarker(longitude, latitude, prefabObject, false); //mapPoint.addPositionValue("Production", new Vector2(longitude, latitude)); if (mapPoint.getMarker3D() != null) { mapPoint.getMarker3D().altitude = 30.0f; mapPoint.getMarker3D().scale = 3.0f; } mapPoint.setMap(map); /* PRUEBA RENDIMIENTO */ // Se introducen el resto de propiedades (URI, categpry (clase), from y to (intervalo de tiempo) mapPoint.setURI(obj.id); mapPoint.setLabel(obj.label != null && obj.label.Length > 0 ? obj.label[0] : obj.identifier); if (obj.production?.time?.Length > 0) { map.GetPropertyManager().SetPropertyValue("time", mapPoint, obj.production.time.ToList()); if (listOfCenturies.Count > 0) { mapPoint.setFrom(listOfCenturies.First().@from); mapPoint.setTo(listOfCenturies.Last().to); } } //Set Properties values map.GetPropertyManager().SetPropertyValue("technique", mapPoint, obj.production.technique.ToList()); map.GetPropertyManager().SetPropertyValue("material", mapPoint, obj.production.material.ToList()); var listOfPlaces = obj.production.location.Select(s => s.label).ToList(); map.GetPropertyManager().SetPropertyValue("place", mapPoint, listOfPlaces); mapPoint.assignTexture(listOfPlaces.Count == 1 ? objCategory.defaultIcon: objCategory.multipleLocationIcon); mapPoint.setKnownLocation(listOfPlaces.Count == 1); map.GetPropertyManager().SetPropertyValue("category", mapPoint, listOfCategories); mapPoint.setDimension(map.GetDimension()); mapPoint.setMultipleLocations(obj.production.location.Length > 1); /* PRUEBA RENDIMIENTO */ listOfPoints.Add(mapPoint); } } map.addPoints(listOfPoints); }