/// <summary> /// New page /// </summary> public PageBoundary() { /// Text message to indicate current status textMessage.TextColor = Color.White; textMessage.Text = "[Boundary]"; /// Content view of this page Content = new StackLayout() { VerticalOptions = LayoutOptions.Center, Children = { textMessage, } }; try { if (isBound != true) { if (serviceState == ServiceState.Enabled) { /// Set initial position Coordinate center; center.Latitude = 10.1234; center.Longitude = 20.1234; /// Set radius value to detect out of boundary double radius = 50.0; /// Create circle boundary /// <param name="center">The coordinates which constitute the center of the circular boundary.</param> /// <param name="radius">The radius value of the circular boundary.</param> circle = new CircleBoundary(center, radius); /// Add circle boundary to detect zone changed locator.AddBoundary(circle); /// Add ZoneChanged event locator.ZoneChanged += LocatorZoneChanged; isBound = true; } else { textMessage.Text = "[Boundary]\nService temporarily unavailable.\nPlease retry after service enabled"; } } } catch (Exception ex) { /// Exception handling textMessage.Text = "[Boundary] Exception \n" + ex.Message; } }
/// <summary> /// Button event to set location boundary /// </summary> /// <param name="sender">object</param> /// <param name="e">EventArgs</param> private void ButtonBoundaryClicked(object sender, EventArgs e) { /// Set initial position Coordinate center; center.Latitude = 10.1234; center.Longitude = 20.1234; /// Set radius value to detect out of boundary double radius = 50.0; try { if (isBound == true) { /// Cancel boundary CancelBoundary(); textMessage.Text = ""; } else { buttonBoundary.Text = "Cancel location boundary"; isBound = true; /// Create circle boundary /// <param name="center">The coordinates which constitute the center of the circular boundary.</param> /// <param name="radius">The radius value of the circular boundary.</param> circle = new CircleBoundary(center, radius); /// Add circle boundary to detect zone changed locator.AddBoundary(circle); /// Add ZoneChanged event locator.ZoneChanged += Locator_ZoneChanged; } } catch (Exception ex) { /// Exception handling textMessage.Text = "[Boundary]\n Exception : " + ex.Message; } }
public void RunQuery() { // ��ȡ��ͼӦ�ó��������̶��� MapApplication mapApi = HostMapApplicationServices.Application; ProjectModel proj = mapApi.ActiveProject; DrawingSet drawingSet = proj.DrawingSet; //������ͼ�μ��߽� proj.DrawingSet.ZoomExtents(); //ʹ��LocationCondition������һ����ѯ���� LocationCondition qryCondition = new LocationCondition (); qryCondition.LocationType = LocationType.LocationInside ; qryCondition.JoinOperator = JoinOperator .OperatorAnd ; // ����Բ�߽� CircleBoundary boundary = null; PromptPointResult pointRes = Utility.AcadEditor.GetPoint("\nѡ��ԭ��: "); if (pointRes.Status == PromptStatus.OK) { Point3d point = pointRes.Value; PromptDistanceOptions distOptions = new PromptDistanceOptions("\nѡ��뾶: "); distOptions.BasePoint = point; distOptions.UseBasePoint = true; distOptions.DefaultValue = 0.0; PromptDoubleResult doubleRes = Utility.AcadEditor.GetDistance(distOptions); if (doubleRes.Status == PromptStatus.OK) { double rad = doubleRes.Value; boundary = new CircleBoundary(new Point3d(point.X, point.Y, 0.0), rad); } } // qryCondition.Boundary = boundary; //����һ��������֧ QueryBranch qryBranch = QueryBranch.Create (); qryBranch.JoinOperator = JoinOperator.OperatorAnd; qryBranch.AppendOperand(qryCondition); ////ʹ��PropertyCondition������һ�����Բ�ѯ����(LWPOLYLINE) PropertyCondition propCondition= new PropertyCondition(); //JoinOperator.OperatorAnd, PropertyType.EntityType, ConditionOperator.ConditionEqual, "LWPOLYLINE"; propCondition.JoinOperator = JoinOperator.OperatorAnd ; propCondition.PropertyType = PropertyType.EntityType ; propCondition.ConditionOperator = ConditionOperator.ConditionEqual ; propCondition.Value = "LWPOLYLINE"; // ͨ��QueryBranch�Ĺ��캯��������һ��������ѯ��֧�� QueryBranch subBranch = new QueryBranch(JoinOperator.OperatorAnd); // ����һ�����в�ѯ�����ͷ�֧�IJ�ѯ���� subBranch.AppendOperand(propCondition); qryBranch.AppendOperand(subBranch); // ����һ����ѯ�� QueryModel qryModel = proj.CreateQuery (true); // ��ɲ�ѯ�Ķ��塣 qryModel.Define (qryBranch); //���û���ģʽ qryModel.Mode = QueryType.QueryDraw; //�����ѯ qryModel.Define(qryBranch); //ִ�в�ѯ�� qryModel.Run(); Utility.AcadEditor.WriteMessage("\n ��ɲ�ѯ ��"); }