Example #1
0
        /// <summary>
        /// Add a new design to a site model
        /// </summary>
        public IDesign Add(Guid siteModelId, DesignDescriptor designDescriptor, BoundingWorldExtent3D extents, ISubGridTreeBitMask existenceMap)
        {
            if (extents == null)
            {
                throw new ArgumentNullException(nameof(extents));
            }

            if (existenceMap == null)
            {
                throw new ArgumentNullException(nameof(existenceMap));
            }

            // Add the design to the designs list
            var designs = Load(siteModelId);
            var result  = designs.AddDesignDetails(designDescriptor.DesignID, designDescriptor, extents);

            // Store the existence map into the cache
            using var stream = existenceMap.ToStream();
            var fileName = BaseExistenceMapRequest.CacheKeyString(ExistenceMaps.Interfaces.Consts.EXISTENCE_MAP_DESIGN_DESCRIPTOR, designDescriptor.DesignID);

            if (_writeStorageProxy.WriteStreamToPersistentStore(siteModelId, fileName,
                                                                FileSystemStreamType.DesignTopologyExistenceMap, stream, existenceMap) != FileSystemErrorStatus.OK)
            {
                _log.LogError("Failed to write existence map to persistent store for key {fileName}");
                return(null);
            }

            // Store performs Commit() operation
            Store(siteModelId, designs);

            return(result);
        }
Example #2
0
        /// <summary>
        /// Saves a sub grid existence map for the design to a file
        /// </summary>
        private bool SaveSubGridIndex(string fileName)
        {
            try
            {
                // Write the index out to a file
                using (var fs = new FileStream(fileName, FileMode.CreateNew, FileAccess.Write, FileShare.None))
                {
                    subGridIndex.ToStream(fs);
                }

                Log.LogInformation($"Saved sub grid index file {fileName}");

                return(true);
            }
            catch (Exception e)
            {
                Log.LogError(e, "Exception in SaveSubGridIndex");
            }

            Log.LogError($"Unable to save sub grid index file {fileName}");
            return(false);
        }
Example #3
0
        /// <summary>
        /// Add a new surveyed surface to a site model
        /// </summary>
        public ISurveyedSurface Add(Guid siteModelUid, DesignDescriptor designDescriptor, DateTime asAtDate, BoundingWorldExtent3D extents,
                                    ISubGridTreeBitMask existenceMap)
        {
            if (asAtDate.Kind != DateTimeKind.Utc)
            {
                throw new ArgumentException("AsAtDate must be a UTC date time");
            }

            if (extents == null)
            {
                throw new ArgumentNullException(nameof(extents));
            }

            if (existenceMap == null)
            {
                throw new ArgumentNullException(nameof(existenceMap));
            }

            var ss = Load(siteModelUid);
            var newSurveyedSurface = ss.AddSurveyedSurfaceDetails(designDescriptor.DesignID, designDescriptor, asAtDate, extents);

            // Store the existence map into the cache
            using var stream = existenceMap.ToStream();
            var fileName = BaseExistenceMapRequest.CacheKeyString(ExistenceMaps.Interfaces.Consts.EXISTENCE_SURVEYED_SURFACE_DESCRIPTOR, designDescriptor.DesignID);

            if (_writeStorageProxy.WriteStreamToPersistentStore(siteModelUid, fileName,
                                                                FileSystemStreamType.DesignTopologyExistenceMap, stream, existenceMap) != FileSystemErrorStatus.OK)
            {
                _log.LogError("Failed to write existence map to persistent store for key {fileName}");
                return(null);
            }

            // Store performs Commit() operation
            Store(siteModelUid, ss);

            return(newSurveyedSurface);
        }