コード例 #1
0
        public void ActivateRecord(Geometry geometry)
        {
            QueuedTask.Run(() =>
            {
                try
                {
                    var layers = MapView.Active.Map.GetLayersAsFlattenedList();
                    var pfL    = layers.FirstOrDefault(l => l is ParcelLayer) as ParcelLayer;
                    // if there is no fabric in the map then exit
                    if (pfL == null)
                    {
                        return;
                    }

                    var recordsLayer = MapView.Active.Map.FindLayers("Records").FirstOrDefault() as BasicFeatureLayer;
                    if (recordsLayer == null)
                    {
                        ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Records Layer is not found.", "Error", System.Windows.MessageBoxButton.OK, MessageBoxImage.Exclamation);
                        return;
                    }
                    RowCursor rowCursor = null;
                    // define a spatial query filter
                    var spatialQueryFilter = new SpatialQueryFilter
                    {
                        // passing the search geometry to the spatial filter
                        FilterGeometry = geometry,
                        // define the spatial relationship between search geometry and feature class
                        SpatialRelationship = SpatialRelationship.Intersects
                    };
                    // apply the spatial filter to the feature layer in question
                    rowCursor = recordsLayer.Search(spatialQueryFilter);

                    RowHandle rowHandle = null;
                    var featName        = string.Empty;
                    if (rowCursor.MoveNext())
                    {
                        var row   = rowCursor.Current;
                        rowHandle = new RowHandle(row);
                        featName  = Convert.ToString(row["NAME"]);
                    }

                    if (rowHandle != null)
                    {
                        // Reference the parcel record and set it as the active record
                        var parcelRecord = new ParcelRecord(rowHandle.Token);
                        pfL.SetActiveRecord(parcelRecord);

                        ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Record activated:  " + featName, "Info", System.Windows.MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
                catch (Exception exc)
                {
                    // Catch any exception found and display in a message box
                    ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Exception caught: " + exc.Message);
                    return;
                }
            });
        }
コード例 #2
0
        protected async void CreateNewRecord()
        {
            #region Create a new record
            await QueuedTask.Run(async() =>
            {
                Dictionary <string, object> RecordAttributes = new Dictionary <string, object>();
                var layers              = MapView.Active.Map.GetLayersAsFlattenedList();
                var recordsLayer        = layers.FirstOrDefault(l => l.Name == "Records" && l is FeatureLayer);
                var myParcelFabricLayer = layers.FirstOrDefault(l => l is ParcelLayer) as ParcelLayer;
                var spatRef             = recordsLayer.Map.SpatialReference;

                var editOper = new EditOperation()
                {
                    Name            = "Create Parcel Fabric Record",
                    ProgressMessage = "Create Parcel Fabric Record...",
                    ShowModalMessageAfterFailure = true,
                    SelectNewFeatures            = false,
                    SelectModifiedFeatures       = false
                };

                string sNewRecordName = "myNewRecord";
                Polygon newPolygon    = null;
                newPolygon            = PolygonBuilder.CreatePolygon(spatRef);
                if (newPolygon != null)
                {
                    RecordAttributes.Add("Name", sNewRecordName);
                    var editRowToken = editOper.CreateEx(recordsLayer, newPolygon, RecordAttributes);
                    RecordAttributes.Clear();
                    if (!await editOper.ExecuteAsync())
                    {
                        return;
                    }

                    //Default Guid
                    var defGuid = new Guid("dddddddd-dddd-dddd-dddd-dddddddddddd");
                    var defOID  = -1;
                    var guid    = editRowToken.GlobalID.HasValue ? editRowToken.GlobalID.Value : defGuid;
                    var lOid    = editRowToken.ObjectID.HasValue ? editRowToken.ObjectID.Value : defOID;

                    if (guid == defGuid | lOid == defOID)
                    {
                        return;
                    }

                    ParcelRecord parcelRecord = new ParcelRecord(myParcelFabricLayer.Map, sNewRecordName, guid, lOid);
                    await myParcelFabricLayer.SetActiveRecord(parcelRecord);
                }
            });

            #endregion
        }
コード例 #3
0
ファイル: ParcelShape.cs プロジェクト: alexi-t/KWI.Viewer
        public ParcelShape(ParcelRecord parcel, int parcelSize, GeoCord parcelXSize, GeoCord parcelYSize, int parcelIndex)
        {
            _parcel           = parcel;
            _parcelScreenSize = parcelSize;
            _parcelWidth      = parcelXSize;
            _parcelHeight     = parcelYSize;

            _parcel.LoadChilds();

            if (_parcel.DividedWrapper)
            {
                var parcelInfo = _parcel.Childs.OfType <ParcelInformationRecord>().FirstOrDefault();
                parcelInfo.LoadChilds();
                foreach (var dividedParcel in parcelInfo.Childs.OfType <ParcelRecord>())
                {
                    dividedParcel.LoadChilds();
                    _parcelX = dividedParcel.ParcelLong;
                    _parcelY = dividedParcel.ParcelLat;

                    _dividedParcels.Add(dividedParcel);
                }
            }
            else if (_parcel.IsPartOfIntegrated)
            {
                var blockWidth        = _parcel.FindParentOfType <LevelRecord>().ParcelsCountLong;
                var blockHeight       = _parcel.FindParentOfType <LevelRecord>().ParcelsCountLat;
                var posBlockRelativeY = parcelIndex / blockWidth;
                var posBlockRelativeX = parcelIndex % blockWidth;
                _integratedOffsetX = posBlockRelativeX - _parcel.X;
                _integratedOffsetY = posBlockRelativeY - _parcel.Y;
                _parcelX           = _parcel.ParcelLong + parcelXSize.Multiply(_integratedOffsetX);
                _parcelY           = _parcel.ParcelLat + parcelYSize.Multiply(_integratedOffsetY);
            }
            else
            {
                _parcelX = parcel.ParcelLong;
                _parcelY = parcel.ParcelLat;
            }
        }
コード例 #4
0
        protected async void SetActiveRecord()
        {
            #region Set the active record
            await QueuedTask.Run(async() =>
            {
                var layers = MapView.Active.Map.GetLayersAsFlattenedList();
                var myParcelFabricLayer = layers.FirstOrDefault(l => l is ParcelLayer) as ParcelLayer;
                var recordsLayer        = layers.FirstOrDefault(l => l.Name == "Records" && l is FeatureLayer);
                string sExistingRecord  = "MyRecordName";

                var pFeatClass          = (recordsLayer as FeatureLayer).GetFeatureClass();
                QueryFilter queryFilter = new QueryFilter
                {
                    WhereClause = "Name = '" + sExistingRecord + "'"
                };
                Guid guid = new Guid();
                long lOID = -1;

                using (RowCursor rowCursor = pFeatClass.Search(queryFilter, false))
                {
                    while (rowCursor.MoveNext())
                    {
                        using (Row row = rowCursor.Current)
                        {
                            guid     = row.GetGlobalID();
                            long oid = row.GetObjectID();
                        }
                    }
                }

                var parcelRecord = new ParcelRecord(myParcelFabricLayer.Map, sExistingRecord, guid, lOID);
                await myParcelFabricLayer.SetActiveRecord(parcelRecord);
            });

            #endregion
        }
コード例 #5
0
ファイル: ParcelShape.cs プロジェクト: alexi-t/KWI.Viewer
        private void ExtractShapes(ParcelRecord parcel, out List <Tuple <Brush, Point[]> > backgrounds, out List <Tuple <Pen, Point[]> > backgroundLines)
        {
            backgrounds     = new List <Tuple <Brush, Point[]> >();
            backgroundLines = new List <Tuple <Pen, Point[]> >();
            var backgroundFrame = parcel.Childs.OfType <BackgroundFrameRecord>().FirstOrDefault();

            if (backgroundFrame != null)
            {
                foreach (var bgElementInfo in backgroundFrame.Childs.OfType <BgElementInformation>())
                {
                    bgElementInfo.LoadChilds();
                    foreach (var bgUnit in bgElementInfo.Childs.OfType <BackgroundUnit>())
                    {
                        bgUnit.LoadChilds();

                        foreach (var area in bgUnit.Childs.OfType <MinimunGraphicsDataRecord>())
                        {
                            int nominator = 1;
                            if (area.MultConst > 1)
                            {
                                nominator = (int)Math.Pow(2, area.MultConst);
                            }
                            var x = area.StartX;
                            var y = area.StartY;
                            if (parcel.IsPartOfIntegrated)
                            {
                                x += (area.IntegratedX - _integratedOffsetX) * 4096;
                                y += (area.IntegratedY - _integratedOffsetY) * 4096;
                            }
                            var points = new List <Point> {
                                new Point(x, y)
                            };
                            bool penUp = false;
                            foreach (var offset in area.Offsets)
                            {
                                if (offset.X == 0 && offset.Y == 0)
                                {
                                    break;
                                }
                                x = x + offset.X / nominator;
                                y = y + offset.Y / nominator;
                                points.Add(new Point(x, y));
                            }
                            if (bgUnit.Type == Format.Typing.Graphics.ShapeType.Line)
                            {
                                if (points.Any(p => (p.X >= 0 && p.X <= 4096) || (p.Y >= 0 && p.Y <= 4096)))
                                {
                                    backgroundLines.Add(new Tuple <Pen, Point[]>(GetBgColor(bgElementInfo.DisplayType).pen, points.ToArray()));
                                }
                            }
                            if (bgUnit.Type == Format.Typing.Graphics.ShapeType.Area)
                            {
                                if (points.Any(p => (p.X >= 0 && p.X <= 4096) || (p.Y >= 0 && p.Y <= 4096)))
                                {
                                    backgrounds.Add(new Tuple <Brush, Point[]>(GetBgColor(bgElementInfo.DisplayType).brush, points.ToArray()));
                                }
                            }
                        }
                    }
                }
            }
        }