public static EnvelopeN InitializeEnvelope(EnvelopeN baseEnv, Extent bbox) { EnvelopeN result; try { EnvelopeN envelopeN; if (baseEnv == null) { envelopeN = baseEnv; } else { envelopeN = new EnvelopeN(); } envelopeN.XMin = bbox.XMin.Value; envelopeN.XMax = bbox.XMax.Value; envelopeN.YMin = bbox.YMin.Value; envelopeN.YMax = bbox.YMax.Value; envelopeN.SpatialReference = AGSSpatialReference.SpRefFromString(bbox.SpatialReference); result = envelopeN; } catch { result = baseEnv; } return(result); }
public static SpatialReference SpRefFromWKID(ref int wkid) { SpatialReference result; try { if (!AGSSpatialReference.IsGeographicWKID(wkid)) { result = new ProjectedCoordinateSystem { WKID = wkid, WKIDSpecified = true }; } else { result = new GeographicCoordinateSystem { WKID = wkid, WKIDSpecified = true }; } } catch { result = null; } return(result); }
public static SpatialReference SpRefFromString(string str) { SpatialReference result; try { SpatialReference spatialReference; if (AGSSpatialReference.IsInteger(str)) { int num = int.Parse(str); spatialReference = AGSSpatialReference.SpRefFromWKID(ref num); } else { string text = str; spatialReference = AGSSpatialReference.SpRefFromWKT(ref text); } result = spatialReference; } catch { result = null; } return(result); }
public AGSSpatialReference(AGSSpatialReference src) { if (!string.IsNullOrEmpty(src.Name)) { this.Name = string.Copy(src.Name); } if (!string.IsNullOrEmpty(src.WKT)) { this.WKT = string.Copy(src.WKT); } }
public override ITask GetExportTask(AGSExportOptions eo, HiddenUpdateForm form) { string arg = base.Parent.URL + "/" + base.FullName + "/ImageServer/exportImage"; StringBuilder arg2 = this.BuildURIRequest(eo); string requestURL = arg + arg2; return(new UpdateRasterImageTask(base.Parent) { RequestURL = requestURL, UpdateForm = form, OutputFile = eo.OutputFile, OutputSpatialReference = AGSSpatialReference.SpRefFromString(eo.OutputWKT) }); }
public Extent(PointN[] points) { try { this.XMin = new double?(Math.Min(points[0].X, points[1].X)); this.XMin = new double?(Math.Min(this.XMin.Value, points[2].X)); this.YMin = new double?(Math.Min(points[0].Y, points[1].Y)); this.YMin = new double?(Math.Min(this.YMin.Value, points[2].Y)); this.XMax = new double?(Math.Max(points[0].X, points[1].X)); this.XMax = new double?(Math.Max(this.XMax.Value, points[2].X)); this.YMax = new double?(Math.Max(points[0].Y, points[1].Y)); this.YMax = new double?(Math.Max(this.YMax.Value, points[2].Y)); if (points[0].SpatialReference != null) { this.SpatialReference = AGSSpatialReference.GetSpRefString(points[0].SpatialReference); } } catch { } }
public void ExportImage(AGSExportOptions eo, ExportImageEventHandler action) { try { string arg = base.Parent.URL + "/" + base.FullName + "/ImageServer/exportImage"; StringBuilder arg2 = this.BuildURIRequest(eo); Mouse.OverrideCursor = Cursors.Wait; IDictionary <string, object> dictionary = base.Parent.MakeDictionaryRequest(arg + arg2); if (dictionary == null) { Mouse.OverrideCursor = null; if (string.IsNullOrEmpty(base.Parent.ErrorMessage)) { ErrorReport.ShowErrorMessage(AfaStrings.AnUnexpectedErrorOccured); } else { ErrorReport.ShowErrorMessage(base.Parent.ErrorMessage); } return; } SpatialReference spatialReference = null; if (dictionary != null) { object obj; if (!dictionary.TryGetValue("href", out obj)) { string text = AfaStrings.Error; if (dictionary.ContainsKey("error")) { IDictionary <string, object> dictionary2 = dictionary["error"] as IDictionary <string, object>; if (dictionary2.ContainsKey("details")) { object obj2; if (dictionary2.TryGetValue("details", out obj2)) { object[] array = obj2 as object[]; if (array != null) { text = text + " - " + array[0].ToString(); } } } else { text += AfaStrings.UnknownError; } } Mouse.OverrideCursor = null; ErrorReport.ShowErrorMessage(text); return; } string text2 = obj as string; if (text2.Length > 0) { ExportedImage exportedImage = new ExportedImage(this, text2); if (dictionary.TryGetValue("width", out obj)) { exportedImage.Properties.Add("width", obj); } if (dictionary.TryGetValue("height", out obj)) { exportedImage.Properties.Add("height", obj); } if (dictionary.TryGetValue("scale", out obj)) { exportedImage.Properties.Add("scale", obj); } if (dictionary.TryGetValue("extent", out obj)) { IDictionary <string, object> dictionary3 = obj as IDictionary <string, object>; object obj3; if (dictionary3.TryGetValue("xmin", out obj3)) { exportedImage.Properties.Add("xmin", obj3); } if (dictionary3.TryGetValue("xmax", out obj3)) { exportedImage.Properties.Add("xmax", obj3); } if (dictionary3.TryGetValue("ymax", out obj3)) { exportedImage.Properties.Add("ymax", obj3); } if (dictionary3.TryGetValue("ymin", out obj3)) { exportedImage.Properties.Add("ymin", obj3); } if (dictionary3.TryGetValue("spatialReference", out obj3)) { IDictionary <string, object> dictionary4 = obj3 as IDictionary <string, object>; object obj4; if (dictionary4.TryGetValue("wkid", out obj4)) { exportedImage.Properties.Add("spatialReference", obj4); int num = int.Parse(obj4.ToString()); spatialReference = AGSSpatialReference.SpRefFromWKID(ref num); } else if (dictionary4.TryGetValue("wkt", out obj4)) { exportedImage.Properties.Add("spatialReference", obj4); string text3 = obj4.ToString(); spatialReference = AGSSpatialReference.SpRefFromWKT(ref text3); } } PointN pointN = new PointN(); if (spatialReference != null) { pointN.SpatialReference = spatialReference; } double num2 = double.Parse(exportedImage.Properties["xmin"].ToString()); double num3 = double.Parse(exportedImage.Properties["ymin"].ToString()); double num4 = double.Parse(exportedImage.Properties["xmax"].ToString()); double num5 = double.Parse(exportedImage.Properties["ymax"].ToString()); pointN.X = num2; pointN.Y = num3; pointN.Z = 0.0; PointN[] points = new PointN[] { pointN, new PointN { SpatialReference = spatialReference, X = num4, Y = num3, Z = 0.0 }, new PointN { SpatialReference = spatialReference, X = num2, Y = num5, Z = 0.0 } }; try { if (File.Exists(eo.OutputFile)) { File.Delete(eo.OutputFile); if (App.TempFiles.Contains(eo.OutputFile)) { App.TempFiles.Remove(eo.OutputFile); } } new WebClient(); if (!base.Parent.DownloadFile(text2, eo.OutputFile)) { eo.OutputFile = text2; if (string.IsNullOrEmpty(eo.OutputFile)) { ErrorReport.ShowErrorMessage(AfaStrings.ErrorCreatingOutputFile); } } } catch { eo.OutputFile = text2; if (string.IsNullOrEmpty(eo.OutputFile)) { ErrorReport.ShowErrorMessage(AfaStrings.ErrorCreatingOutputFile); } } finally { if (action != null) { action(this, new ExportedImageEventArgs(this, eo, points)); } } Mouse.OverrideCursor = null; return; } } } } catch { Mouse.OverrideCursor = null; } Mouse.OverrideCursor = null; }
public void SetWKTFrom(object obj) { this.SpatialReference = AGSSpatialReference.GetWKTFrom(obj); }
private void DoTask() { try { IDictionary <string, object> dictionary = this.Parent.MakeDictionaryRequest(this.RequestURL); if (dictionary == null) { string text = this.Parent.ErrorMessage; if (string.IsNullOrEmpty(text)) { text = AfaStrings.AnUnexpectedErrorOccured; } ErrorReport.ShowErrorMessage(text); } this.UpdateForm.SetReady(false); SpatialReference spatialReference = null; if (dictionary != null) { object obj; if (!dictionary.TryGetValue("href", out obj)) { string text2 = AfaStrings.Error; if (dictionary.ContainsKey("error")) { IDictionary <string, object> dictionary2 = dictionary["error"] as IDictionary <string, object>; object obj2; if (dictionary2.ContainsKey("details") && dictionary2.TryGetValue("details", out obj2)) { object[] array = obj2 as object[]; if (array != null) { text2 = text2 + " - " + array[0].ToString(); } } } Mouse.OverrideCursor = null; ErrorReport.ShowErrorMessage(text2); } else { string text3 = obj as string; if (text3.Length > 0) { decimal value = 0m; decimal value2 = 0m; decimal value3 = 0m; decimal value4 = 0m; if (dictionary.TryGetValue("extent", out obj)) { IDictionary <string, object> dictionary3 = obj as IDictionary <string, object>; object obj3; if (dictionary3.TryGetValue("spatialReference", out obj3)) { IDictionary <string, object> dictionary4 = obj3 as IDictionary <string, object>; object obj4; if (dictionary4.TryGetValue("wkid", out obj4)) { int num = int.Parse(obj4.ToString()); spatialReference = AGSSpatialReference.SpRefFromWKID(ref num); } else if (dictionary4.TryGetValue("wkt", out obj4)) { string text4 = obj4.ToString(); spatialReference = AGSSpatialReference.SpRefFromWKT(ref text4); } } if (dictionary3.TryGetValue("xmin", out obj3)) { value = (decimal)obj3; } if (dictionary3.TryGetValue("xmax", out obj3)) { value3 = (decimal)obj3; } if (dictionary3.TryGetValue("ymax", out obj3)) { value4 = (decimal)obj3; } if (dictionary3.TryGetValue("ymin", out obj3)) { value2 = (decimal)obj3; } PointN pointN = new PointN(); if (spatialReference != null) { pointN.SpatialReference = spatialReference; } pointN.X = (double)value; pointN.Y = (double)value2; pointN.Z = 0.0; PointN[] array2 = new PointN[] { pointN, new PointN { SpatialReference = spatialReference, X = (double)value3, Y = (double)value2, Z = 0.0 }, new PointN { SpatialReference = spatialReference, X = (double)value, Y = (double)value4, Z = 0.0 } }; try { if (File.Exists(this.OutputFile)) { File.Delete(this.OutputFile); if (App.TempFiles.Contains(this.OutputFile)) { App.TempFiles.Remove(this.OutputFile); } } if (!this.Parent.DownloadFile(text3, this.OutputFile)) { this.OutputFile = text3; if (string.IsNullOrEmpty(this.OutputFile)) { ErrorReport.ShowErrorMessage(AfaStrings.ErrorCreatingOutputFile); return; } } } catch { this.OutputFile = text3; if (string.IsNullOrEmpty(this.OutputFile)) { ErrorReport.ShowErrorMessage(AfaStrings.ErrorCreatingOutputFile); return; } } this.UpdateForm.SetReady(false); Point3d point3d = new Point3d(pointN.X, array2[0].Y, 0.0); Point3d point3d2 = new Point3d(array2[1].X, array2[1].Y, 0.0); Point3d point3d3 = new Point3d(array2[2].X, array2[2].Y, 0.0); this.UpdateForm.V1 = point3d2 - point3d; this.UpdateForm.V2 = point3d3 - point3d; this.UpdateForm.BasePoint = point3d; this.UpdateForm.ImageURL = this.OutputFile; this.UpdateForm.SetReady(true); } } } } } catch (SystemException ex) { this.UpdateForm.SetReady(false); this._errMsg.Append(ex.Message); } }
public static string GetWKTFrom(object obj) { if (obj == null) { return(null); } string result; try { string text = ""; IAGSObject iAGSObject = obj as IAGSObject; if (iAGSObject != null) { if (iAGSObject.Properties.ContainsKey("Full Extent")) { Extent extent = iAGSObject.Properties["Full Extent"] as Extent; text = extent.SpatialReference; } else if (iAGSObject.Properties.ContainsKey("Initial Extent")) { Extent extent2 = iAGSObject.Properties["Initial Extent"] as Extent; text = extent2.SpatialReference; } else if (iAGSObject.Properties.ContainsKey("WKT")) { text = iAGSObject.Properties["WKT"].ToString(); } else if (iAGSObject.Properties.ContainsKey("WKID")) { text = iAGSObject.Properties["WKID"].ToString(); } else if (iAGSObject.Properties.ContainsKey("WKID")) { text = iAGSObject.Properties["WKID"].ToString(); } } SpatialReference spatialReference = obj as SpatialReference; if (spatialReference != null) { result = AGSSpatialReference.GetSpRefString(spatialReference); } else { Extent extent3 = obj as Extent; if (extent3 != null) { result = extent3.SpatialReference; } else { result = text; } } } catch { result = ""; } return(result); }