public ActionResult AddWfsLayer(string url, WFSVersion wfsVersion) { string wfsUrl = null; try { wfsUrl = WFSManager.CreateGetCapabiltiesRequestUrl(url, wfsVersion); } catch (UriFormatException) { ModelState.AddModelError("", "The URL has wrong format"); } if (ModelState.IsValid) { if (wfsVersion == WFSVersion.Unknown) { wfsVersion = WFSManager.GetWFSVersionFromRequestUrl(url); if (wfsVersion == WFSVersion.Unknown) { wfsVersion = WFSVersion.Ver110; } } return(RedirectToAction("AddWfsLayer", new { @url = wfsUrl })); } var viewManager = new WfsLayersViewManager(GetCurrentUser(), SessionHandler.MySettings); var model = viewManager.CreateAddWfsLayerViewModel(ModelState, url, Url.Action("UploadMapDataFile"), Url.Action("WfsLayers")); return(View(model)); }
public void Get_WFSVersion_From_GetCapabilitiesRequest() { WFSVersion version; version = WFSManager.GetWFSVersionFromRequestUrl("http://slwgeo.artdata.slu.se:8080/geoserver/SLW/wfs?service=WFS&version=1.1.0&request=GetCapabilities"); Assert.AreEqual(WFSVersion.Ver110, version); version = WFSManager.GetWFSVersionFromRequestUrl("http://slwgeo.artdata.slu.se:8080/geoserver/SLW/wfs?service=WFS&version=1.0.0&request=GetCapabilities"); Assert.AreEqual(WFSVersion.Ver100, version); version = WFSManager.GetWFSVersionFromRequestUrl("http://slwgeo.artdata.slu.se:8080/geoserver/SLW/wfs?service=WFS&request=GetCapabilities&version=1.0.0"); Assert.AreEqual(WFSVersion.Ver100, version); version = WFSManager.GetWFSVersionFromRequestUrl("http://slwgeo.artdata.slu.se:8080/geoserver/SLW/wfs?service=WFS&request=GetCapabilities&version=1.5.0"); Assert.AreEqual(WFSVersion.Unknown, version); version = WFSManager.GetWFSVersionFromRequestUrl("http://slwgeo.artdata.slu.se:8080/geoserver/SLW/wfs?service=WFS&request=GetCapabilities&version=1.1."); Assert.AreEqual(WFSVersion.Unknown, version); version = WFSManager.GetWFSVersionFromRequestUrl("http://slwgeo.artdata.slu.se:8080/geoserver/SLW/wfs?service=WFS&request=GetCapabilities"); Assert.AreEqual(WFSVersion.Unknown, version); version = WFSManager.GetWFSVersionFromRequestUrl("abc"); Assert.AreEqual(WFSVersion.Unknown, version); }