Esempio n. 1
0
        private void ValidateTopology(ITopology topology, IEnvelope envelope)
        {
            IPolygon           locationpolygon   = new PolygonClass();
            ISegmentCollection segmentCollection = locationpolygon as ISegmentCollection;

            segmentCollection.SetRectangle(envelope);
            IPolygon polgyon = topology.get_DirtyArea(locationpolygon);

            if (!polgyon.IsEmpty)
            {
                IEnvelope areaToValidate = polgyon.Envelope;
                IEnvelope areaValidated  = topology.ValidateTopology(areaToValidate);
            }
        }
Esempio n. 2
0
        public void ValidateTopology(ITopology topology, IEnvelope envelope)
        {
            // Get the dirty area within the provided envelope.
            IPolygon           locationPolygon   = new PolygonClass();
            ISegmentCollection segmentCollection = (ISegmentCollection)locationPolygon;

            segmentCollection.SetRectangle(envelope);
            IPolygon polygon = topology.get_DirtyArea(locationPolygon);
            // If a dirty area exists, validate the topology.    if (!polygon.IsEmpty)
            {        // Define the area to validate and validate the topology.
                IEnvelope areaToValidate = polygon.Envelope;
                IEnvelope areaValidated  = topology.ValidateTopology(areaToValidate);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Returns a polygon with a centroid at the given x and y exactly 1 acre in size
        /// </summary>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        /// <returns></returns>
        private IPolygon CreateHomesitePolygon(int X, int Y)
        {
            try
            {
                ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = (_application.Document as IMxDocument).ActiveView.ScreenDisplay;
                ESRI.ArcGIS.Geometry.IPoint        point         = screenDisplay.DisplayTransformation.ToMapPoint(X, Y);
                ITopologicalOperator topologicalOperator         = point as ITopologicalOperator;
                IGeometry            geometry = topologicalOperator.Buffer(104.3551628); // radius of circle --> envelope is 1 square acre :)
                IPolygon             polygon  = geometry as IPolygon;

                // Might be able to skip this
                ISegmentCollection segmentcollection = polygon as ISegmentCollection;
                segmentcollection.SetRectangle(polygon.Envelope);

                return(segmentcollection as IPolygon);
            } catch (Exception ex)
            {
                RS_Tools.Utilities.Utilities_MessageBox.ErrorBox(ex.Message, MB_TITLE);
            }
            return(null);
        }
        private bool AddEditArea(IServerObject serverObject, string creator, string versionName, int editCount, IEnvelope editZone, bool autoExpandZone = true)
        {
            bool          isOk        = false;
            IFeatureClass editAreasFC = null;

            try
            {
                // Open edit areas feature class in default workspace
                editAreasFC = GetEditAreaFeatureClass(serverObject);

                // Get field indices
                int creatorFIdx      = editAreasFC.FindField(_creatorFName);
                int creationDateFIdx = editAreasFC.FindField(_creationDateFName);
                int lastUpdateFIdx   = editAreasFC.FindField(_lastUpdateFName);
                int editCountFIdx    = editAreasFC.FindField(_editCountFName);
                int versionNameFIdx  = editAreasFC.FindField(_versionNameFName);

                DateTime currentTime = DateTime.Now;

                // Expand zone to make it more visible
                if (autoExpandZone)
                {
                    double expandRatio = (editCount <= 3) ? 1.5 : 1.15;
                    editZone.Expand(expandRatio, expandRatio, true);
                }

                // Check if there's an existing area
                IFeature       curFeature = null;
                IFeatureCursor fCursor    = GetEditAreas(serverObject, versionName);

                if (fCursor != null && (curFeature = fCursor.NextFeature()) != null)
                {
                    // Union the edit zones
                    IPolygon  curZone     = (IPolygon)curFeature.Shape;
                    IGeometry geometryBag = new GeometryBag();
                    geometryBag.SpatialReference = curZone.SpatialReference;
                    IGeometryCollection geometryCollection = (IGeometryCollection)geometryBag;
                    geometryCollection.AddGeometry(curZone);
                    geometryCollection.AddGeometry(editZone);

                    Polygon zoneConstructor      = new Polygon();
                    ITopologicalOperator newZone = (ITopologicalOperator)zoneConstructor;
                    newZone.ConstructUnion((IEnumGeometry)geometryCollection);

                    // Update feature values
                    curFeature.Shape = (IGeometry)newZone;
                    curFeature.Value[lastUpdateFIdx] = currentTime;
                    int curCount = (int)curFeature.Value[editCountFIdx];
                    curFeature.Value[editCountFIdx] = curCount + editCount;

                    // Store feature
                    curFeature.Store();
                    curFeature = null;
                }
                else
                {
                    // Save edit zone to feature class
                    IFeature zoneFeature = editAreasFC.CreateFeature();
                    zoneFeature.Value[creatorFIdx]      = creator;
                    zoneFeature.Value[creationDateFIdx] = currentTime;
                    zoneFeature.Value[lastUpdateFIdx]   = currentTime;
                    zoneFeature.Value[versionNameFIdx]  = versionName;
                    zoneFeature.Value[editCountFIdx]    = editCount;

                    // Set geometry
                    Polygon            editAreaPoly = new Polygon();
                    ISegmentCollection editAreaSeg  = (ISegmentCollection)editAreaPoly;
                    editAreaSeg.SetRectangle(editZone);
                    IZAware polyZAware = editAreaPoly as IZAware;
                    polyZAware.ZAware = false;
                    zoneFeature.Shape = polyZAware as IGeometry;

                    // Store feature
                    zoneFeature.Store();
                    fCursor.Flush();
                    fCursor     = null;
                    zoneFeature = null;
                }

                isOk = true;
            }
            catch (Exception e)
            {
                _serverLog.LogMessage(ServerLogger.msgType.infoStandard, _soiName + ".AddEditArea()",
                                      200, "Error while adding edit are: " + e.ToString());
            }
            finally
            {
                editAreasFC = null;
            }
            return(isOk);
        }