protected override PrimitiveSpatialResult QueryPrimitivesInternal(PrimitiveSpatialQuery specification, bool uniqueEntities, DataSource.QueryProgress progress)
        {
            GeometryQueryRegion region = specification.SpatialFilter.Region as GeometryQueryRegion;

            TileLevelOfDetail tileLevel = (TileLevelOfDetail)host.WorldEngine.ScaleRanges.ScaleToTileLevelOfDetailValue(specification.SpatialFilter.GeometryOptions.Scale);


            if (region != null)
            {
                Box2 regionBox = region.Geometry as Box2;
                if (regionBox != null)
                {
                    int    levelValue = (int)tileLevel.Value > 5 ? (int)tileLevel.Value : 5;
                    double iconSize   = 64.0 / Math.Pow(2, levelValue);
                    this.step = iconSize / 2.0;

                    RasterPatch2 rasterPatch = probesHelper.GetTilePatch(pointSet, regionBox, iconSize);

                    if (rasterPatch != null)
                    {
                        PrimitiveSpecification spec = new PrimitiveSpecification(entity,
                                                                                 this.Ontology.PrimitiveTypes["RasterPatch"], rasterPatch);
                        SimplePrimitive primitive = new SimplePrimitive(this, spec);
                        return(new SingleImageResult(primitive));
                    }
                }
            }

            return(new SingleImageResult(null));
        }
예제 #2
0
        /// <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);
                                }
                            }
                        }
                    }
                }
            }
        }