/// <summary> /// Gets the pins in the specified circular area. /// </summary> internal void GetPinsInView( MercatorBoundingBox mercatorBox, MercatorBoundingCircle mercatorBoundingCircle, float levelOfDetail, ClusterMapPin clusterMapPinPrefab, Transform parentTransform, out List <MapPin> mapPins, out List <ClusterMapPin> clusterMapPins) { var lod = (short)Mathf.Min(Mathf.Round(levelOfDetail), _maxLod.Value); var tileLod = new TileLevelOfDetail(lod); var tileLodData = _tiledSpatialIndex[lod - 1]; var tiles = TileOperations.GetCoveredTileIds(mercatorBox, tileLod); mapPins = new List <MapPin>(); clusterMapPins = new List <ClusterMapPin>(); foreach (var tile in tiles) { var tileBounds = tile.ToMercatorBoundingBox(); var isTileCompletelyInsideMap = mercatorBoundingCircle.Contains(tileBounds); if (tileLodData.TryGetValue(tile.Value, out var tileData)) { if (tileData.IsClustered()) { var latLon = new LatLon(tileData.TotalLat / tileData.MapPinCount, tileData.TotalLon / tileData.MapPinCount); var mercatorCoordinate = latLon.ToMercatorCoordinate(); if (isTileCompletelyInsideMap || mercatorBoundingCircle.Intersects(mercatorCoordinate)) { // Use the ClusterMapPin. if (tileData.ClusterMapPin == null) { // Deactivate the GO to start with. It will get activated once elevation has been sampled and it's in view. clusterMapPinPrefab.gameObject.SetActive(false); var newClusterMapPin = UnityEngine.Object.Instantiate(clusterMapPinPrefab); if (parentTransform != null) { newClusterMapPin.transform.SetParent(parentTransform, false); } newClusterMapPin.LevelOfDetail = tileLod.Value; tileData.ClusterMapPin = newClusterMapPin; _clusterMapPins.Add(newClusterMapPin); } tileData.ClusterMapPin.Size = tileData.MapPinCount; tileData.ClusterMapPin.Location = new LatLon(latLon.LatitudeInDegrees, latLon.LongitudeInDegrees); clusterMapPins.Add(tileData.ClusterMapPin); } } else { // Add all of the MapPins in this tile to the list. if (isTileCompletelyInsideMap) { foreach (var mapPin in tileData.MapPins) { mapPins.Add(mapPin); } } else { foreach (var mapPin in tileData.MapPins) { if (mercatorBoundingCircle.Intersects(mapPin.MercatorCoordinate)) { mapPins.Add(mapPin); } } } } } } }
/// <summary> /// Constructs a <see cref="MapSceneOfBoundingBox"/> from the specified <see cref="MercatorBoundingBox"/>. /// </summary> public MapSceneOfBoundingBox(MercatorBoundingBox boundingBox) : this(boundingBox.ToGeoBoundingBox()) { }