/// <summary> /// jzd保存进入map /// </summary> /// <param name="jzd"></param> public static void SaveMap(IList <JZD> jzds) { IFeatureClass featureClass = GetJZDLayer().FeatureClass; Dictionary <int, Clazz> dic = ArcGisService.GetTitleClzz <JZD>(featureClass.Fields, false); dic.Remove(-1); IFeatureCursor featureCursor = featureClass.Insert(true); IFeatureBuffer featureBuffer = featureClass.CreateFeatureBuffer(); foreach (JZD jzd in jzds) { if (jzd.Point == null) { featureBuffer.Shape = jzd.Feature.ShapeCopy; } else { IPoint point = new PointClass(); point.PutCoords(jzd.Point.X, jzd.Point.Y); featureBuffer.Shape = point; } SetFeatureBufferValue(featureBuffer, dic, jzd); featureCursor.InsertFeature(featureBuffer); } }
private async void HandleDelete() { var confirm = await DisplayAlert("Delete", "Are you sure you want to delete this bin record?", "No", "Yes"); if (!confirm) { var response = await ArcGisService.DeleteBin(viewModel.ArcGISFeature); switch (response) { case ArcCrudEnum.Success: await DisplayAlert("", "Bin successfully deleted", "Ok"); //activityIndicator_edit.Off(); await Navigation.PopToRootAsync(); break; case ArcCrudEnum.Failure: await DisplayAlert("Error", "Error occurred", "Ok"); //activityIndicator_edit.Off(); break; case ArcCrudEnum.Exception: await DisplayAlert("Error", "Failed to connect to online services. Please try again", "Ok"); //activityIndicator_edit.Off(); break; } } }
public void TestFindAddressResults() { IGeospatialService service = new ArcGisService(GeospatialUrl); var street = "1411 Nw Flanders St"; var city = "Portland"; var state = string.Empty; var zip = "97209"; var results = service.FindAddressResults(street, city, state, zip); Assert.IsNotNull(results); Assert.IsTrue(results.Candidates.Count > 1); //URL Encoding issues street = street + " #A"; results = service.FindAddressResults(street, city, state, zip); Assert.IsNotNull(results); Assert.IsTrue(results.Candidates.Count > 1); //Invalid address street = "55555 Nw SomethingMadeUP St"; city = "Fake"; zip = "97200"; results = service.FindAddress(street, city, state, zip); Assert.IsNotNull(results); Assert.IsTrue(results.Candidates.Count == 0); }
private async Task EditAsync() { var response = await ArcGisService.EditBin(viewModel); switch (response) { case ArcCrudEnum.Success: await DisplayAlert("", "Bin successfully edited", "Ok"); activityIndicator_save.Off(); activityIndicatorCapacity_save.Off(); viewModel.New = false; viewModel.Edit = false; Save.Text = "Edit"; Cancel.Text = "Delete"; //disable stacks SetGeneralPage(); SetCapcityPage(); break; case ArcCrudEnum.Failure: await DisplayAlert("Error", "Error occurred", "Ok"); activityIndicator_save.Off(); activityIndicatorCapacity_save.Off(); break; case ArcCrudEnum.Exception: await DisplayAlert("Error", "Failed to connect to online services. Please try again", "Ok"); activityIndicatorCapacity_save.Off(); activityIndicator_save.Off(); break; } }
/// <summary> /// 保存进入map /// </summary> /// <param name="jzxs"></param> public static void SaveJZXMap(IList <JZX> jzxs) { IFeatureLayer layer = ArcGisManager.ArcGisUtils.GetFeatureLayer(JZXLayerName); foreach (JZX jzx in jzxs) { ArcGisService.AddFeature(jzx, jzx.Polyline, layer.FeatureClass); } }
public static IList <JZD> FeatureToList(IList <IFeature> features) { if (Utils.CheckListExists(features)) { return(ArcGisService.ObjToFeature <JZD>(features, ArcGisService.GetTitleClzz <JZD>(features[0].Fields))); } else { return(null); } }
public static void AddJzdFeature(object obj, IPoint geometry, IFeatureClass featureClass) { Dictionary <int, Clazz> dic = ArcGisService.GetTitleClzz(obj, featureClass.Fields); IFeatureCursor featureCursor = featureClass.Insert(true); IFeatureBuffer featureBuffer = featureClass.CreateFeatureBuffer(); IPoint point = new PointClass(); point.PutCoords(geometry.X, geometry.Y); featureBuffer.Shape = point; SetFeatureBufferValue(featureBuffer, dic, obj); featureCursor.InsertFeature(featureBuffer); }
public async void ConnectToArcGIS() { var loginResult = await ArcGisService.Authenticate("clint.kautz", "Demopassword12"); // if login successful, load main menu if (loginResult == ArcCrudEnum.Success) { GlobalSettings.EmployeeNum = "123"; } // if login unsuccessful, set info message else if (loginResult == ArcCrudEnum.Failure) { } }
private async Task SaveAsync() { ArcCrudEnum addResult = await ArcGisService.AddBin(viewModel); switch (addResult) { case ArcCrudEnum.Success: await DisplayAlert("Success!", "New bin successfully added", "Ok"); activityIndicator_save.Off(); activityIndicatorCapacity_save.Off(); viewModel.New = false; viewModel.Edit = false; Save.Text = "Edit"; Cancel.Text = "Delete"; Cancel.IsEnabled = true; //disable stacks SetGeneralPage(); SetCapcityPage(); break; case ArcCrudEnum.Failure: await DisplayAlert("Error", "Error occurred, try again", "Ok"); activityIndicator_save.Off(); activityIndicatorCapacity_save.Off(); break; case ArcCrudEnum.Exception: await DisplayAlert("Error", "Failed to connect to online services. Please try again", "Ok"); activityIndicator_save.Off(); activityIndicatorCapacity_save.Off(); break; } }
/// <summary> /// 修改界址点 /// </summary> /// <param name="jzd"></param> public static void Update(IList <JZD> jzds) { ArcGisService.UpdateFeate(jzds, ArcGisService.GetTitleClzz <JZD>(GetJZDLayer().FeatureClass.Fields, false)); }
public void ExportCun_GongShiTuActions(XZDM cunXZDM, string saveDir) { //IList<JTSYQ> jtsyqs = null; //得到所有界址短线 IList <JZX> jzxs = JZXCustom.SetJZX(cunXZDM.JTSYQS); //从中删除本村的界址短线 for (int a = 0; a < jzxs.Count; a++) { JZX jzx = jzxs[a]; string str = jzx.BM.Substring(0, 12); if (str == cunXZDM.DJZQDM) { jzxs.RemoveAt(a); a--; } } string mxdPath = saveDir + "\\" + System.IO.Path.GetFileName(JTSYQCustom.JTSYQGSTMxd); string mdbPath = saveDir + "\\" + System.IO.Path.GetFileName(JTSYQCustom.JTSYQGSTMDB); //1、复制maxd FileUtils.CopyFile(JTSYQCustom.JTSYQGSTMxd, mxdPath); //2、复制数据库 FileUtils.CopyFile(JTSYQCustom.JTSYQZDTMdb, mdbPath); //打开工作文件 MapDocumentClass mapDocument = new MapDocumentClass(); mapDocument.Open(mxdPath, ""); AxMapControl mapControl = ArcGisUtils.axMapControl; IMap map = mapDocument.Map[0]; mapControl.Map = map; //3、设置数据源,数据源是相对路径,不需要设置 //4、复制 本村的界址线shap JTSYQCustom.SaveMap(cunXZDM.JTSYQS); //设置本村的界址点标注 JTSYQCustom.SaveJTSYQBZMap(map, cunXZDM.JTSYQS); JZXCustom.SaveJZXMap(jzxs); JZXCustom.SaveJZXBZMap(map, jzxs); double scale = 100.0; // mapControl.Extent = JTSYQCustom.SetExtent(cunXZDM.JTSYQS); ArcGisUtils.axMapControl.Extent = JTSYQCustom.GetLayer().AreaOfInterest; double num = (double)((int)((map.MapScale + 30.0) / scale) * scale + scale); //mapControl.MapScale = 329; ArcGisUtils.ChangeMapScale(mapDocument, num); //5、替换文字内容, Dictionary <string, XMLObject> xmlObjectDic = XMLRead.XmlToObjects(JTSYQCustom.XZDM_Reflect, true); XMLObject xmlObject = new XMLObject { Column = "BLC", Deafult = "1:" + num }; xmlObjectDic.Add("BLC", xmlObject); ArcGisService.ReplaceText(cunXZDM, xmlObjectDic, mapDocument); //使用的xml缓存,必须移除 xmlObjectDic.Remove("BLC"); //6、工程文件保留 mapDocument.Save(); mapDocument.Close(); ArcGisUtils.Refresh(); }
public void ExportZu_ZhongDiTu(JTSYQ jtsyqGroup, string saveDir) { IList <JZX> jzxs = JZXCustom.SetJZX(jtsyqGroup.GroupJTSYQ); string mxdPath = saveDir + "\\" + System.IO.Path.GetFileName(JTSYQCustom.JTSYQZDTMxd); string mdbPath = saveDir + "\\" + System.IO.Path.GetFileName(JTSYQCustom.JTSYQZDTMdb); //1、复制maxd FileUtils.CopyFile(JTSYQCustom.JTSYQZDTMxd, mxdPath); //2、复制数据库 FileUtils.CopyFile(JTSYQCustom.JTSYQZDTMdb, mdbPath); //打开工作文件 MapDocumentClass mapDocument = new MapDocumentClass(); mapDocument.Open(mxdPath, ""); AxMapControl mapControl = ArcGisUtils.axMapControl; IMap map = mapDocument.Map[0]; mapControl.Map = map; //3、设置数据源,数据源是相对路径,不需要设置 //4、复制shap JTSYQCustom.SaveMap(jtsyqGroup.GroupJTSYQ); JTSYQCustom.SaveJTSYQBZMap(map, jtsyqGroup.GroupJTSYQ); IList <JZD> jzds = JZDCustom.SaveMap(jtsyqGroup); JZXCustom.SaveJZXMap(jzxs); JZXCustom.SaveJZXBZMap(map, jzxs); JZDCustom.SaveJZDBZMap(map, jzds); double scale = 100.0; mapControl.Extent = JTSYQCustom.SetExtent(jtsyqGroup.GroupJTSYQ); double num = (double)((int)((map.MapScale + 30.0) / scale) * scale + scale); //mapControl.MapScale = 329; ArcGisUtils.ChangeMapScale(mapDocument, num); //5、替换文字内容, int index = 0; for (int a = 0; a > -1; a++) { string tufu = jtsyqGroup.TuFu; if (Utils.IsStrNull(tufu)) { MessageBox.Show("你还没有生成图幅号!!!:" + jtsyqGroup.QLR); ArcGisUtils.Refresh(); return; } index = tufu.IndexOf("、", index + 1); if (index == -1) { break; } if (a % 2 != 0) { jtsyqGroup.TuFu = tufu.Insert(index + 1, "\n"); } } Dictionary <string, XMLObject> xmlObjectDic = XMLRead.XmlToObjects(JTSYQCustom.JTSYQ_Reflect, true); XMLObject xmlObject = new XMLObject { Column = "BLC", Deafult = "1:" + num }; xmlObjectDic.Add("BLC", xmlObject); ArcGisService.ReplaceText(jtsyqGroup, xmlObjectDic, mapDocument); //使用的xml缓存,必须移除 xmlObjectDic.Remove("BLC"); //6、工程文件保留 mapDocument.Save(); mapDocument.Close(); ArcGisUtils.Refresh(); }
public async Task <bool> ValdiateAsync() { Errors = new Dictionary <int, string>(); bool valid = true; //Binstance = this.MapToBin(); ViewModelMapBinType(); //ViewModelMapYTY(); if (string.IsNullOrWhiteSpace(Binstance.Identifier)) { Errors.Add(0, "Identifier is required"); valid = false; } else if (New) { var result = await ArcGisService.IdentifierAvailable(Binstance.Identifier.ToLower()); switch (result) { case IdentifierAvailableEnum.Available: break; case IdentifierAvailableEnum.NotAvailable: Errors.Add(0, "Identifier already in use"); valid = false; break; case IdentifierAvailableEnum.Exception: Errors.Add(0, "Cannot connect to online services to verify identifier. Please try again"); valid = false; break; } } if (Binstance.BinType == BinTypeEnum.NotFound) { Errors.Add(1, "Bin Type is required"); valid = false; } else { switch (Binstance.BinType) { case BinTypeEnum.FlatStructure: valid = ValidateFlatBin(valid); break; case BinTypeEnum.GravityWagon: valid = ValidateGravityBin(valid); break; case BinTypeEnum.PolygonStructure: valid = ValidatePolygonBin(valid); break; case BinTypeEnum.RoundStorage: valid = ValidateRoundBin(valid); break; } } if (New && string.IsNullOrWhiteSpace(Binstance.CreatedBy)) { Errors.Add(2, "Employee Number is required"); valid = false; } return(valid); }