Ejemplo n.º 1
0
        public bool AddLayerToCapabilities(ServiceRecord serviceRecord, string capabilitiesPath, string layerPath)
        {
            bool        ret        = false;
            IOgcService ogcService = GetOgcService(serviceRecord.Type, serviceRecord.Version);

            switch (serviceRecord.Type)
            {
            case OgcServiceType.Wmts:
                IWmtsService wmtsService  = ogcService as IWmtsService;
                Capabilities capabilities = GetCapabilities(wmtsService, capabilitiesPath);
                if (capabilities != null)
                {
                    LayerType layerType = wmtsService.AddLayerType(capabilities, layerPath);
                    if (layerType != null)
                    {
                        SaveCapabilities(wmtsService, capabilitiesPath, capabilities);
                        ret = true;
                    }
                }
                break;
            }
            if (ret)
            {
                string      destName    = Path.GetFileNameWithoutExtension(layerPath);
                LayerRecord layerRecord = new LayerRecord()
                {
                    Name    = destName,
                    Path    = layerPath,
                    Service = serviceRecord
                };
                _configContext.Layers.Add(layerRecord);
            }
            return(ret);
        }
Ejemplo n.º 2
0
        public async Task RemoveLayerFromCapabilities(ServiceRecord serviceRecord, string capabilitiesPath, LayerRecord layerRecord)
        {
            if (layerRecord == null)
            {
                return;
            }
            #region  除数据库及数据
            _configContext.Layers.Remove(layerRecord);
            var ret = await _configContext.SaveChangesAsync();

            DeleteDataSet(layerRecord.Path);
            #endregion
            #region  除XML中的图层
            IOgcService ogcService = GetOgcService(serviceRecord.Type, serviceRecord.Version);
            switch (serviceRecord.Type)
            {
            case OgcServiceType.Wmts:
                IWmtsService wmtsService  = ogcService as IWmtsService;
                Capabilities capabilities = GetCapabilities(wmtsService, capabilitiesPath);
                wmtsService.RemoveLayerType(capabilities, layerRecord.Name);
                SaveCapabilities(wmtsService, capabilitiesPath, capabilities);
                break;
            }
            #endregion
        }