/// <summary>
        /// Adds the features retrieved from cache to the receiver.
        /// </summary>
        /// <param name="processAttributes">A value indicating whether the attributes will be processed or not</param>
        /// <param name="cacheAccessor">Cache accessor instance</param>
        /// <param name="fr">An object that receives the retrieved features</param>
        /// <param name="bounds">Rectangle that defines a query region</param>
        /// <returns>Number of retrieved features</returns>
        public static int FillFromCache(IFeatureCollectionCacheAccessor cacheAccessor, IFeatureReceiver fr, BoundingRectangle bounds, bool processAttributes)
        {
            ISpatialIndex pointsIndex    = cacheAccessor.RestoreFeaturesIndex(MapAround.Mapping.FeatureType.Point);
            ISpatialIndex polylinesIndex = cacheAccessor.RestoreFeaturesIndex(MapAround.Mapping.FeatureType.Polyline);
            ISpatialIndex polygonsIndex  = cacheAccessor.RestoreFeaturesIndex(MapAround.Mapping.FeatureType.Polygon);

            BoundingRectangle b;

            if (!bounds.IsEmpty())
            {
                b = bounds.GetBoundingRectangle();
            }
            else
            {
                b = new BoundingRectangle();
                b.Join(pointsIndex.IndexedSpace);
                b.Join(polylinesIndex.IndexedSpace);
                b.Join(polygonsIndex.IndexedSpace);
            }

            List <Feature> points = new List <Feature>();

            pointsIndex.QueryObjectsInRectangle(bounds, points);

            List <Feature> polylines = new List <Feature>();

            polylinesIndex.QueryObjectsInRectangle(bounds, polylines);

            List <Feature> polygons = new List <Feature>();

            polygonsIndex.QueryObjectsInRectangle(bounds, polygons);

            points.ForEach(point => fr.AddFeature((Feature)point.Clone()));
            polylines.ForEach(polyline => fr.AddFeature((Feature)polyline.Clone()));
            polygons.ForEach(polygon => fr.AddFeature((Feature)polygon.Clone()));

            if (processAttributes)
            {
                fr.FeatureAttributeNames.Clear();
                IList <string> attributeNames = cacheAccessor.RestoreAttributeNames();
                foreach (string s in attributeNames)
                {
                    fr.FeatureAttributeNames.Add(s);
                }
            }

            return(points.Count + polylines.Count + polygons.Count);
        }
Esempio n. 2
0
        /// <summary>
        /// Saves a spatial index containing features to the cache.
        /// </summary>
        /// <param name="index">Spatial index</param>
        /// <param name="featureType">Type of features in index</param>
        public void SaveFeaturesIndex(ISpatialIndex index, FeatureType featureType)
        {
            List <Feature> features = new List <Feature>();

            lock (_syncRoot)
            {
                index.QueryObjectsInRectangle(index.IndexedSpace, features);

                foreach (Feature s in features)
                {
                    if (s.FeatureType != featureType)
                    {
                        throw new ArgumentException("Illegal feature type", "index");
                    }
                }

                AddOrReplaceIndex((ISpatialIndex)index.Clone(), featureType);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Saves a spatial index containing features to the cache.
        /// </summary>
        /// <param name="index">Spatial index</param>
        /// <param name="featureType">Type of features in index</param>
        public void SaveFeaturesIndex(ISpatialIndex index, FeatureType featureType)
        {
            List<Feature> features = new List<Feature>();
            lock (_syncRoot)
            {
                index.QueryObjectsInRectangle(index.IndexedSpace, features);

                foreach (Feature s in features)
                    if (s.FeatureType != featureType)
                        throw new ArgumentException("Illegal feature type", "index");

                AddOrReplaceIndex((ISpatialIndex)index.Clone(), featureType);
            }
        }