/// <summary> /// Creates a view model to use in WfsLayerEditor when we edit an existing layer. /// </summary> /// <param name="id">The layer id.</param> /// <returns></returns> public WfsLayerEditorViewModel CreateWfsLayerEditorViewModelInEditMode(int id) { var wfsLayerSetting = MapLayersSetting.GetWfsLayer(id); var model = new WfsLayerEditorViewModel { Id = id, Mode = WfsLayerEditorMode.Edit, WfsLayerSetting = wfsLayerSetting }; if (wfsLayerSetting.IsFile) { model.FeatureType = new WfsFeatureType { Title = wfsLayerSetting.Name }; model.ServerUrl = wfsLayerSetting.ServerUrl; } else { var wfsCapabilities = WFSManager.GetWFSCapabilitiesAndMergeDescribeFeatureType(wfsLayerSetting.ServerUrl, wfsLayerSetting.TypeName); model.WfsCapabilities = wfsCapabilities; var featureType = wfsCapabilities.FeatureTypes.FirstOrDefault(feature => feature.Name.FullName == wfsLayerSetting.TypeName); model.FeatureType = featureType; model.ServerUrl = wfsCapabilities.Capability.Requests.GetFeaturesRequest.GetUrlBase; } return(model); }
/// <summary> /// Render a WFS layer editor view. /// </summary> /// <param name="url">The WFS Server URL.</param> /// <param name="typeName">FeatureType.</param> /// <param name="filter">The filter.</param> /// <param name="mode">The mode.</param> /// <param name="id">The id (used if mode is Edit).</param> /// <returns></returns> public ActionResult WfsLayerEditor(string url, string typeName, string filter, WfsLayerEditorMode?mode, int?id) { ViewBag.RenderMapScriptTags = true; var viewManager = new WfsLayersViewManager(GetCurrentUser(), SessionHandler.MySettings); WfsLayerEditorViewModel model = viewManager.CreateWfsLayerEditorViewModel(url, typeName, filter, mode, id); return(View(model)); }
/// <summary> /// Creates a view model to use in WfsLayerEditor when we create a new layer. /// </summary> /// <param name="url">The server URL.</param> /// <param name="typeName">The typename.</param> /// <param name="filter">The filter.</param> /// <returns></returns> public WfsLayerEditorViewModel CreateWfsLayerEditorViewModelInCreateNewMode(string url, string typeName, string filter) { WFSCapabilities wfsCapabilities = WFSManager.GetWFSCapabilitiesAndMergeDescribeFeatureType(url, typeName); ArtDatabanken.GIS.WFS.Capabilities.WfsFeatureType featureType = wfsCapabilities.FeatureTypes.FirstOrDefault(feature => feature.Name.FullName == typeName); var model = new WfsLayerEditorViewModel(); model.Mode = WfsLayerEditorMode.New; model.WfsCapabilities = wfsCapabilities; model.FeatureType = featureType; model.ServerUrl = wfsCapabilities.Capability.Requests.GetFeaturesRequest.GetUrlBase; var wfsLayerSetting = new WfsLayerSetting(); wfsLayerSetting.Filter = ""; wfsLayerSetting.Name = ""; wfsLayerSetting.Color = MapLayersSetting.CreateMapLayerHexColor(); model.WfsLayerSetting = wfsLayerSetting; return(model); }