예제 #1
0
        /// <summary>
        /// Add a new surveyed surface to a site model via direct manipulation of the information in the grid
        /// </summary>
        /// <param name="SiteModelID"></param>
        /// <param name="designDescriptor"></param>
        /// <param name="asAtDate"></param>
        /// <param name="extents"></param>
        /// <param name="SuveyedSurfaceID"></param>
        public void AddDirect(Guid SiteModelID, DesignDescriptor designDescriptor, DateTime asAtDate, BoundingWorldExtent3D extents, out Guid SurveyedSurfaceID)
        {
            // This should be done under a lock on the cache key. For now, we will live with the race condition...

            INonSpatialAffinityKey cacheKey = CacheKey(SiteModelID);

            SurveyedSurfaceID = Guid.NewGuid();

            // Get the surveyed surfaces, creating it if it does not exist
            ISurveyedSurfaces ssList = DIContext.Obtain <ISurveyedSurfaces>();

            try
            {
                ssList.FromBytes(mutableNonSpatialCache.Get(cacheKey));
            }
            catch (KeyNotFoundException)
            {
                // Swallow exception, the list will be empty
            }

            // Add the new surveyed surface, generating a random ID from a GUID
            ssList.AddSurveyedSurfaceDetails(SurveyedSurfaceID, designDescriptor, asAtDate, extents);

            // Put the list back into the cache with the new entry
            mutableNonSpatialCache.Put(cacheKey, ssList.ToBytes());
        }
예제 #2
0
        /// <summary>
        /// Remove a given surveyed surface from a site model
        /// </summary>
        /// <param name="SiteModelID"></param>
        /// <param name="SurveySurfaceID"></param>
        /// <returns></returns>
        public bool RemoveDirect(Guid SiteModelID, Guid SurveySurfaceID)
        {
            // TODO: This should be done under a lock on the cache key. For now, we will live with the race condition

            try
            {
                INonSpatialAffinityKey cacheKey = CacheKey(SiteModelID);

                // Get the surveyed surfaces, creating it if it does not exist
                ISurveyedSurfaces ssList = DIContext.Obtain <ISurveyedSurfaces>();
                ssList.FromBytes(mutableNonSpatialCache.Get(cacheKey));

                // Add the new surveyed surface, generating a random ID from a GUID
                bool result = ssList.RemoveSurveyedSurface(SurveySurfaceID);

                // Put the list back into the cache with the new entry
                if (result)
                {
                    mutableNonSpatialCache.Put(cacheKey, ssList.ToBytes());
                }

                return(result);
            }
            catch (KeyNotFoundException)
            {
                return(false);
            }
        }
예제 #3
0
        /*
         *  /// <summary>
         *  /// Add a new design to a sitemodel
         *  /// </summary>
         *  /// <param name="SiteModelID"></param>
         *  /// <param name="designDescriptor"></param>
         *  public void Add(long SiteModelID, DesignDescriptor designDescriptor, BoundingWorldExtent3D extents)
         *  {
         *      mutableNonSpatialCache.Invoke(CacheKey(SiteModelID),
         *                                    new AddDesignProcessor(),
         *                                    new Design(SiteModelID, designDescriptor, extents));
         *  }
         */

        /// <summary>
        /// Add a new design to a sitemodel
        /// </summary>
        /// <param name="SiteModelID"></param>
        /// <param name="designDescriptor"></param>
        /// <param name="extents"></param>
        /// <param name="DesignID"></param>
        public void AddDirect(Guid SiteModelID, DesignDescriptor designDescriptor, BoundingWorldExtent3D extents, out Guid DesignID)
        {
            // This should be done under a lock on the cache key. For now, we will live with the race condition...

            INonSpatialAffinityKey cacheKey = VSS.TRex.Designs.Storage.Designs.CacheKey(SiteModelID);

            DesignID = Guid.NewGuid();

            // Get the designs, creating it if it does not exist
            IDesigns designList = new TRex.Designs.Storage.Designs();

            try
            {
                designList.FromBytes(MutableNonSpatialCache.Get(cacheKey));
            }
            catch (KeyNotFoundException)
            {
                // Swallow exception, the list will be empty
            }

            // Add the new design, generating a random ID from a GUID
            designList.AddDesignDetails(DesignID, designDescriptor, extents);

            // Put the list back into the cache with the new entry
            MutableNonSpatialCache.Put(cacheKey, designList.ToBytes());
        }
예제 #4
0
        /*
         * /// <summary>
         * /// Remove a given design from a site model
         * /// </summary>
         * /// <param name="SiteModelID"></param>
         * /// <param name="DesignID"></param>
         * /// <returns></returns>
         * public bool Remove(long SiteModelID, long DesignID)
         * {
         * try
         * {
         *     return MutableNonSpatialCache.Invoke(TRex.Designs.Storage.Designs.CacheKey(SiteModelID),
         *                                          new RemoveDesignProcessor(),
         *                                          DesignID);
         * }
         * catch (KeyNotFoundException)
         * {
         *     return false;
         * }
         * }
         */

        /// <summary>
        /// Remove a given design from a site model
        /// </summary>
        /// <param name="SiteModelID"></param>
        /// <param name="DesignID"></param>
        /// <returns></returns>
        public bool RemoveDirect(Guid SiteModelID, Guid DesignID)
        {
            // TODO: This should be done under a lock on the cache key. For now, we will live with the race condition
            try
            {
                INonSpatialAffinityKey cacheKey = TRex.Designs.Storage.Designs.CacheKey(SiteModelID);

                // Get the designs, creating it if it does not exist
                IDesigns designList = new TRex.Designs.Storage.Designs();
                designList.FromBytes(MutableNonSpatialCache.Get(cacheKey));

                // Remove the design
                bool result = designList.RemoveDesign(DesignID);

                // Put the list back into the cache with the new entry
                if (result)
                {
                    MutableNonSpatialCache.Put(cacheKey, designList.ToBytes());
                }

                return(result);
            }
            catch (KeyNotFoundException)
            {
                return(false);
            }
        }
예제 #5
0
        /// <summary>
        /// List the surveyed surfaces for a site model
        /// </summary>
        public ISurveyedSurfaces List(Guid SiteModelID)
        {
            INonSpatialAffinityKey cacheKey = CacheKey(SiteModelID);

            Log.LogInformation($"Listing surveyed surfaces from {cacheKey}");

            try
            {
                ISurveyedSurfaces ss = DIContext.Obtain <ISurveyedSurfaces>();
                ss.FromBytes(mutableNonSpatialCache.Get(cacheKey));
                return(ss);
            }
            catch (KeyNotFoundException)
            {
                return(null);
            }
        }
예제 #6
0
        /// <summary>
        /// Finds a given design in a site model
        /// </summary>
        /// <param name="SiteModelID"></param>
        /// <param name="DesignID"></param>
        /// <returns></returns>
        public IDesign FindDirect(Guid SiteModelID, Guid DesignID)
        {
            try
            {
                INonSpatialAffinityKey cacheKey = TRex.Designs.Storage.Designs.CacheKey(SiteModelID);

                // Get the designs, creating it if it does not exist
                IDesigns designList = new TRex.Designs.Storage.Designs();
                designList.FromBytes(MutableNonSpatialCache.Get(cacheKey));

                // Find the design and return it
                return(designList.Count == 0 ? null : designList.Locate(DesignID));
            }
            catch (KeyNotFoundException)
            {
                return(null);
            }
        }
예제 #7
0
        /// <summary>
        /// Get a specific existence map given its key
        /// </summary>
        public ISubGridTreeBitMask GetExistenceMap(INonSpatialAffinityKey key)
        {
            try
            {
                if (key == null)
                {
                    throw new ArgumentNullException(nameof(key));
                }

                var siteModel = DIContext.Obtain <ISiteModels>().GetSiteModel(key.ProjectUID);

                if (siteModel == null)
                {
                    return(null);
                }

                var readResult = siteModel.PrimaryStorageProxy.ReadStreamFromPersistentStore(siteModel.ID, key.KeyName, Types.FileSystemStreamType.DesignTopologyExistenceMap, out var ms);
                if (readResult != Types.FileSystemErrorStatus.OK)
                {
                    _log.LogError($"Failed to read existence map in project {key.ProjectUID} for key {key.KeyName}");
                    return(null);
                }

                if (ms != null)
                {
                    using (ms)
                    {
                        var map = new SubGridTreeSubGridExistenceBitMask();
                        map.FromStream(ms);
                        return(map);
                    }
                }

                return(null);
            }
            catch (KeyNotFoundException)
            {
                // If the key is not present, return a null/empty array
                return(null);
            }
        }
예제 #8
0
 /// <summary>
 /// Executes the request to retrieve an existence map given it's key and returns a deserialised bit mask sub grid tree
 /// representing the existence map
 /// </summary>
 public ISubGridTreeBitMask Execute(INonSpatialAffinityKey key) => _server.GetExistenceMap(key);