/// <summary> /// Handles the incoming rest requests /// </summary> /// <param name="boundVariables"> The bound variables. </param> /// <param name="operationInput"> The operation input. </param> /// <param name="outputFormat"> The output format. </param> /// <param name="requestProperties"> The request properties. </param> /// <param name="responseProperties"> The response properties. </param> /// <returns> </returns> /// <exception cref="System.ArgumentNullException"></exception> public static byte[] Handler(NameValueCollection boundVariables, JsonObject operationInput, string outputFormat, string requestProperties, out string responseProperties) { responseProperties = null; var errors = new ErrorModel(400); string layerName; double? utmx, utmy; object[] attributeListObj; var found = operationInput.TryGetString("layerName", out layerName); if (!found || string.IsNullOrEmpty(layerName)) { throw new ArgumentNullException("layerName"); } found = operationInput.TryGetAsDouble("utmx", out utmx); if (!found || !utmx.HasValue) { throw new ArgumentNullException("utmx"); } found = operationInput.TryGetAsDouble("utmy", out utmy); if (!found || !utmy.HasValue) { throw new ArgumentNullException("utmy"); } found = operationInput.TryGetArray("attributeList", out attributeListObj); if (!found || attributeListObj == null || attributeListObj.Length < 1) { throw new ArgumentNullException("attributeList"); } var attributeList = attributeListObj.Cast<string>().ToArray(); var searchArgs = new PointInPolyArgs(layerName, utmx.Value, utmy.Value, attributeList); var connector = SdeConnectorFactory.Create(layerName); if (connector == null) { return Json(new { Message = "Database does not exist for {0}".With(layerName) }); } var workspace = connector.Connect(); var featureWorkSpace = workspace as IFeatureWorkspace; if (featureWorkSpace == null) { return Json(new { Message = "Error connecting to SDE." }); } var response = CommandExecutor.ExecuteCommand(new PointInPolygoinQueryCommand(searchArgs, featureWorkSpace)); if (response == null) { return Json(new { Message = "No features found in {2} at the location {0}, {1}.".With( searchArgs.Point.X, searchArgs.Point.Y, searchArgs.LayerName) }); } return Json(response); }
public ErrorContainer(int code) { Error = new ErrorModel(code); }
/// <summary> /// Handles the incoming rest requests /// </summary> /// <param name="boundVariables"> The bound variables. </param> /// <param name="operationInput"> The operation input. </param> /// <param name="outputFormat"> The output format. </param> /// <param name="requestProperties"> The request properties. </param> /// <param name="responseProperties"> The response properties. </param> /// <returns> </returns> /// <exception cref="System.ArgumentNullException"></exception> public static byte[] Handler(NameValueCollection boundVariables, JsonObject operationInput, string outputFormat, string requestProperties, out string responseProperties) { responseProperties = null; var errors = new ErrorModel(400); string layerName; double? utmx, utmy; var found = operationInput.TryGetString("layerName", out layerName); if (!found || string.IsNullOrEmpty(layerName)) { throw new ArgumentNullException("layerName"); } found = operationInput.TryGetAsDouble("utmx", out utmx); if (!found || !utmx.HasValue) { throw new ArgumentNullException("utmx"); } found = operationInput.TryGetAsDouble("utmy", out utmy); if (!found || !utmy.HasValue) { throw new ArgumentNullException("utmy"); } var connector = SdeConnectorFactory.Create(layerName); if (connector == null) { return Json(new { Message = "Database does not exist for {0}".With(layerName) }); } var workspace = connector.Connect(); var featureWorkSpace = workspace as IFeatureWorkspace; if (featureWorkSpace == null) { errors.Message = "Error connecting to SDE."; return Json(errors); } var rasterArgs = new RasterArgs(layerName, utmx, utmy); var response = CommandExecutor.ExecuteCommand(new GetValueFromRasterCommand(rasterArgs, featureWorkSpace as IRasterWorkspaceEx)); if (response == null) { errors.Message = "No features found in {2} at the location {0}, {1}.".With( rasterArgs.X, rasterArgs.Y, rasterArgs.LayerName); return Json(errors); } return Json(response); }