コード例 #1
0
        private void btnOpenClose_Click(object sender, EventArgs e)
        {
            if (_opened)
            {
                if (_commandItem != null)
                {
                    ArcMap.Application.CurrentTool = _commandItem;
                    _commandItem = null;
                }

                DoClosePoint(false);
            }
            else
            {
                Measurement measurement = Measurement.Get(_entityId);

                if ((measurement != null) && (!measurement.IsPointMeasurement))
                {
                    _frmGlobespotter.DisableMeasurementSeries();
                }

                _frmGlobespotter.OpenMeasurementPoint(_entityId, _pointId);
                _commandItem = ArcMap.Application.CurrentTool;
                ArcUtils.SetToolActiveInToolBar("esriEditor.EditTool");
            }
        }
コード例 #2
0
 public virtual void UpdateColor(Color color, int?year)
 {
     if (year == null)
     {
         Color = color;
         ArcUtils.SetColorToLayer(Layer, color);
         Refresh();
     }
 }
コード例 #3
0
        // =========================================================================
        // Static Functions
        // =========================================================================
        private static IDockableWindow GetDocWindow()
        {
            IApplication    application = ArcMap.Application;
            ICommandItem    tool        = application.CurrentTool;
            const string    windowName  = "IntegrationArcMap_GsFrmMeasurement";
            IDockableWindow result      = ArcUtils.GetDocWindow(windowName);

            application.CurrentTool = tool;
            return(result);
        }
コード例 #4
0
        // =========================================================================
        // Functions (Public)
        // =========================================================================
        public void UpdateObservation(string imageId, double x, double y, double z)
        {
            IPoint point = ArcUtils.GsToMapPoint(x, y, z);

            if (_observations.ContainsKey(imageId))
            {
                _observations[imageId] = new[] { point.X, point.Y, point.Z };
            }
            else
            {
                _observations.Add(imageId, new[] { point.X, point.Y, point.Z });
            }
        }
コード例 #5
0
        public override void UpdateColor(Color color, int?year)
        {
            if (year != null)
            {
                var  doYear   = (int)year;
                int  calcYear = doYear * 4;
                bool update   = false;

                for (int i = calcYear; i < (calcYear + 4); i++)
                {
                    update = (YearToColor.ContainsKey(i)) || update;
                }

                if (update)
                {
                    string classValue = string.Format("{0}, {1}, {2}", doYear, false, true);

                    for (int j = calcYear; j < calcYear + 4; j++)
                    {
                        if (YearToColor.ContainsKey(j))
                        {
                            YearToColor[j] = color;
                        }
                    }

                    ArcUtils.SetColorToLayer(Layer, color, classValue);

                    if (YearPip.Contains(calcYear))
                    {
                        classValue = string.Format("{0}, {1}, {2}", doYear, true, true);
                        ISymbol symbol = ArcUtils.GetPipSymbol(SizeLayer, color);
                        ArcUtils.SetSymbolToLayer(Layer, symbol, classValue);
                    }

                    if (YearForbidden.Contains(calcYear))
                    {
                        classValue = string.Format("{0}, {1}, {2}", doYear, false, false);
                        ISymbol symbol = ArcUtils.GetForbiddenSymbol(SizeLayer, color);
                        ArcUtils.SetSymbolToLayer(Layer, symbol, classValue);

                        if (YearPip.Contains(calcYear))
                        {
                            classValue = string.Format("{0}, {1}, {2}", doYear, true, false);
                            ArcUtils.SetSymbolToLayer(Layer, symbol, classValue);
                        }
                    }

                    Refresh();
                }
            }
        }
コード例 #6
0
        // IncludedAngle calculates the included angle subtended by the
        // arc. The result is in radians and by definition is a clockwise
        // turning angle consistent with the clockwise direction of arcs in
        // SVL
        public double IncludedAngle()
        {
            switch (TransitDirection)
            {
            case NFFLineworkArcTransitDirection.atdUnknown:
            case NFFLineworkArcTransitDirection.atdStartToEnd:
                return(ArcUtils.CalcIncludedAngle(X1, Y1, X2, Y2, CX, CY, true));

            case NFFLineworkArcTransitDirection.atdEndToStart:
                return(ArcUtils.CalcIncludedAngle(X2, Y2, X1, Y1, CX, CY, false));

            default:
                throw new TRexException("Unknown transit direction");
            }
        }
コード例 #7
0
        private void OnContentChanged()
        {
            try
            {
                Color = ArcUtils.GetColorFromLayer(_layer);

                if (LayerChangedEvent != null)
                {
                    LayerChangedEvent(this);
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message, "CycloMediaLayer.OnContentChanged");
            }
        }
コード例 #8
0
        public override void SaveToFile(StreamWriter writer, DistanceUnitsType OutputUnits)
        {
            GetStartEndAnglesRadius(out double start_angle, out double end_angle, out double radius);

            double IncAngle   = ArcUtils.CalcIncludedAngle(X1, Y1, X2, Y2, CX, CY, Clockwise);
            bool   ItsACircle = (start_angle == end_angle) && SingleArcEdgePoint;

            if (ItsACircle)
            {
                DXFUtils.WriteDXFRecord(writer, 0, "CIRCLE");
            }
            else
            {
                DXFUtils.WriteDXFRecord(writer, 0, "ARC");
            }

            base.SaveToFile(writer, OutputUnits);

            DXFUtils.WriteXYZToDXF(writer, 0, CX, CY, CZ, OutputUnits);
            DXFUtils.WriteDXFRecord(writer, DXFConsts.ArcRadiusId, DXFUtils.NoLocaleFloatToStrF(DXFUtils.DXFDistance(radius, OutputUnits), 6));

            if (!ItsACircle)
            {
                start_angle = start_angle / (Math.PI / 180);
                end_angle   = end_angle / (Math.PI / 180);

                if (IncAngle < 0)
                {
                    MinMax.Swap(ref start_angle, ref end_angle);
                }
                if (start_angle < 0)
                {
                    start_angle = start_angle + 360;
                }
                if (end_angle < start_angle)
                {
                    end_angle = end_angle + 360;
                }

                // Write the two angles to the DXF file
                DXFUtils.WriteDXFAngle(writer, DXFConsts.ArcStartAngleId, start_angle);
                DXFUtils.WriteDXFAngle(writer, DXFConsts.ArcEndAngleId, end_angle);
            }

            DXFUtils.WriteDXFRecord(writer, DXFConsts.DxfThicknessId, Thickness.ToString());
        }
コード例 #9
0
        public override void UpdateColor(Color color, int?year)
        {
            if (year != null)
            {
                var doYear = (int)year;

                if (YearToColor.ContainsKey(doYear))
                {
                    string classValue = string.Format("{0}, {1}, {2}", doYear, false, true);
                    YearToColor[doYear] = color;
                    ArcUtils.SetColorToLayer(Layer, color, classValue);

                    if (YearPip.Contains(doYear))
                    {
                        classValue = string.Format("{0}, {1}, {2}", doYear, true, true);
                        ISymbol symbol = ArcUtils.GetPipSymbol(SizeLayer, color);
                        ArcUtils.SetSymbolToLayer(Layer, symbol, classValue);
                    }

                    if (YearForbidden.Contains(doYear))
                    {
                        classValue = string.Format("{0}, {1}, {2}", doYear, false, false);
                        ISymbol symbol = ArcUtils.GetForbiddenSymbol(SizeLayer, color);
                        ArcUtils.SetSymbolToLayer(Layer, symbol, classValue);

                        if (YearPip.Contains(doYear))
                        {
                            classValue = string.Format("{0}, {1}, {2}", doYear, true, false);
                            ArcUtils.SetSymbolToLayer(Layer, symbol, classValue);
                        }
                    }

                    Refresh();
                }
            }
        }
コード例 #10
0
        public void UpdatePoint(PointMeasurementData measurementData, int index)
        {
            _index = index;
            bool notCreated = NotCreated;
            MeasurementPointS measurementPoint = measurementData.measurementPoint;
            double            x = measurementPoint.x;
            double            y = measurementPoint.y;
            double            z = measurementPoint.z;

            _point = ArcUtils.GsToMapPoint(x, y, z);

            IActiveView            activeView = ArcUtils.ActiveView;
            var                    display    = activeView.ScreenDisplay;
            IDisplayTransformation dispTrans  = display.DisplayTransformation;
            double                 size       = dispTrans.FromPoints(PointSize);
            double                 xmin       = x - size;
            double                 xmax       = x + size;
            double                 ymin       = y - size;
            double                 ymax       = y + size;

            _oldEnvelope = _envelope;

            foreach (var observation in _observations)
            {
                double[] obs = observation.Value;

                if (obs.Length >= 2)
                {
                    double xdir = (_point.X - obs[0]) / 2;
                    double ydir = (_point.Y - obs[1]) / 2;
                    xmin = Math.Min(xmin, _point.X + xdir);
                    ymin = Math.Min(ymin, _point.Y + ydir);
                    xmax = Math.Max(xmax, obs[0]);
                    ymax = Math.Max(ymax, obs[1]);
                }
            }

            _envelope = new EnvelopeClass {
                XMin = xmin, XMax = xmax, YMin = ymin, YMax = ymax
            };
            var avEvents = ArcUtils.ActiveViewEvents;

            if (avEvents != null)
            {
                if (!notCreated)
                {
                    avEvents.AfterDraw -= AvEventsAfterDraw;
                }

                avEvents.AfterDraw += AvEventsAfterDraw;
            }

            IEditor3 editor = ArcUtils.Editor;
            var      sketch = editor as IEditSketch3;

            if ((sketch != null) && (_measurement != null))
            {
                IGeometry geometry = sketch.Geometry;
                int       nrPoints;
                var       ptColl = _measurement.ToPointCollection(geometry, out nrPoints);

                if ((ptColl != null) && _measurement.IsSketch)
                {
                    if (_intId <= nrPoints)
                    {
                        IPoint pointC = ptColl.Point[_intId - 1];

                        if (!IsSame(pointC))
                        {
                            ISketchOperation2 sketchOp = new SketchOperationClass();
                            sketchOp.Start(editor);
                            IPoint point = new PointClass {
                                X = _point.X, Y = _point.Y, Z = _point.Z, M = _index, ZAware = sketch.ZAware
                            };

                            if (_measurement.IsPointMeasurement)
                            {
                                sketch.Geometry = point;
                            }
                            else
                            {
                                ptColl.UpdatePoint((_intId - 1), point);

                                if ((_intId == 1) && ((nrPoints + 1) == ptColl.PointCount))
                                {
                                    ptColl.UpdatePoint((ptColl.PointCount - 1), point);
                                }

                                sketch.Geometry = ptColl as IGeometry;
                            }

                            geometry = sketch.Geometry;

                            if (geometry != null)
                            {
                                sketchOp.Finish(geometry.Envelope, esriSketchOperationType.esriSketchOperationGeneral, geometry);
                            }
                        }
                    }
                    else
                    {
                        ISketchOperation2 sketchOp = new SketchOperationClass();
                        sketchOp.Start(editor);
                        IPoint point = new PointClass {
                            X = _point.X, Y = _point.Y, Z = _point.Z, M = _index, ZAware = sketch.ZAware
                        };
                        int nrPoints2 = ptColl.PointCount;

                        switch (nrPoints2)
                        {
                        case 0:
                            ptColl.AddPoint(point);

                            if (geometry is IPolygon4)
                            {
                                ptColl.AddPoint(point);
                            }
                            break;

                        case 1:
                            ptColl.AddPoint(point);
                            break;

                        default:
                            if (_intId <= (nrPoints + 1))
                            {
                                object point1 = ((_intId - 1) == nrPoints2) ? Type.Missing : (_intId - 1);
                                object point2 = Type.Missing;
                                ptColl.AddPoint(point, ref point1, ref point2);
                            }

                            break;
                        }

                        sketch.Geometry = ptColl as IGeometry;
                        geometry        = sketch.Geometry;

                        if (geometry != null)
                        {
                            sketchOp.Finish(geometry.Envelope, esriSketchOperationType.esriSketchOperationGeneral, geometry);
                        }
                    }
                }
                else
                {
                    if (geometry is IPoint)
                    {
                        if (geometry.IsEmpty)
                        {
                            if ((!double.IsNaN(_point.X)) && (!double.IsNaN(_point.Y)))
                            {
                                if (!_added)
                                {
                                    IApplication application = ArcMap.Application;
                                    ICommandItem tool        = application.CurrentTool;
                                    ICommand     command     = tool.Command;

                                    if (!(command is IEditTool))
                                    {
                                        _added = true;
                                        var    editorZ = editor as IEditorZ;
                                        double zOffset = 0.0;

                                        if (editorZ != null)
                                        {
                                            zOffset         = editorZ.ZOffset;
                                            editorZ.ZOffset = _point.Z;
                                        }

                                        ISketchOperation2 sketchOp = new SketchOperationClass();
                                        sketchOp.Start(editor);
                                        IPoint point = new PointClass {
                                            X = _point.X, Y = _point.Y, Z = _point.Z, M = _index, ZAware = sketch.ZAware
                                        };
                                        sketch.Geometry = point;
                                        geometry        = sketch.Geometry;
                                        sketchOp.Finish(geometry.Envelope, esriSketchOperationType.esriSketchOperationGeneral, geometry);
                                        sketch.FinishSketch();

                                        if (editorZ != null)
                                        {
                                            editorZ.ZOffset = zOffset;
                                        }

                                        _added = false;
                                    }
                                }
                            }
                        }
                        else
                        {
                            var pointC = geometry as IPoint;

                            if (!IsSame(pointC))
                            {
                                if ((!double.IsNaN(_point.X)) && (!double.IsNaN(_point.Y)))
                                {
                                    ISketchOperation2 sketchOp = new SketchOperationClass();
                                    sketchOp.Start(editor);
                                    IPoint point = new PointClass {
                                        X = _point.X, Y = _point.Y, Z = _point.Z, M = _index, ZAware = sketch.ZAware
                                    };
                                    sketch.Geometry = point;
                                    geometry        = sketch.Geometry;
                                    sketchOp.Finish(geometry.Envelope, esriSketchOperationType.esriSketchOperationGeneral, geometry);
                                }
                            }
                        }
                    }
                }
            }

            Update();
        }
コード例 #11
0
 public static void RemoveFromMenu()
 {
     ArcUtils.RemoveCommandItem(MenuItem, CommandItem);
 }
コード例 #12
0
 public static void AddToMenu()
 {
     ArcUtils.AddCommandItem(MenuItem, CommandItem, 1);
 }
コード例 #13
0
        protected void SaveAsPolyLine(StreamWriter writer, DistanceUnitsType OutputUnits)
        {
            if (Entities.Count == 0)
            {
                return;
            }

            // Get the height of the first vertex in the polyline. If the polyline is not
            // to be written out as a 3D polyline, this height will be the height of all the
            // vertices in the polyline.
            var PolyLineHeight = Entities[0].GetInitialHeight();

            DXFUtils.WriteDXFRecord(writer, 0, "POLYLINE");

            base.SaveToFile(writer, OutputUnits);

            DXFUtils.WriteDXFRecord(writer, DXFConsts.DxfThicknessId, Thickness.ToString());

            DXFUtils.WriteDXFRecord(writer, 6, "CONTINUOUS");

            var PolylineFlags = 0;

            if (Closed)
            {
                PolylineFlags |= 0x01;
            }

            // Determine if the polyline contains any arc entities (ie: intervals with 'bulges')
            var HasArcs = false;

            foreach (var entity in Entities)
            {
                if (entity is DXFArcEntity)
                {
                    HasArcs = true;
                    break;
                }
            }

            var Output3DVertices = Is3D();

            if (HasArcs && PolyLineHeight != Consts.NullDouble)
            // We have to write out a 30 record to specify the
            // height of all the entities in the polyline.
            {
                DXFUtils.WriteDXFRecord(writer, 30, DXFUtils.NoLocaleFloatToStrF(DXFUtils.DXFDistance(PolyLineHeight, OutputUnits), 6));
                Output3DVertices = false;
            }

            if (Output3DVertices)
            {
                PolylineFlags |= 0x08;
            }
            DXFUtils.WriteDXFRecord(writer, DXFConsts.PolyLineFlagsId, PolylineFlags.ToString());

            DXFUtils.WriteDXFRecord(writer, DXFConsts.EntitiesFollowId, "1");
            DXFUtils.WriteXYZToDXF(writer, 0, 0, 0, Consts.NullDouble, OutputUnits);

            for (int I = 0; I < Entities.Count; I++)
            {
                DXFUtils.WriteDXFRecord(writer, 0, "VERTEX");
                DXFUtils.WriteDXFRecord(writer, DXFConsts.LayerNameId, DXFUtils.DXFiseLayerName(Layer));

                if (Entities[I] is DXFLineEntity lineEntity)
                {
                    DXFUtils.WriteXYZToDXF(writer, 0, lineEntity.X1, lineEntity.Y1, HasArcs ? Consts.NullDouble : lineEntity.Z1, OutputUnits);
                }

                if (Entities[I] is DXFArcEntity arcEntity)
                {
                    DXFUtils.WriteXYZToDXF(writer, 0, arcEntity.X1, arcEntity.Y1, Consts.NullDouble, OutputUnits);

                    // Write out the bulge for the arc
                    var IncAngle = ArcUtils.CalcIncludedAngle(arcEntity.X1, arcEntity.Y1, arcEntity.X2, arcEntity.Y2, arcEntity.CX, arcEntity.CY, arcEntity.Clockwise);
                    var Bulge    = Math.Tan(IncAngle / 4);
                    DXFUtils.WriteDXFRecord(writer, DXFConsts.ArcBulgeId, DXFUtils.NoLocaleFloatToStrF(Bulge, 6));
                }

                if (Output3DVertices)
                {
                    DXFUtils.WriteDXFRecord(writer, DXFConsts.VertexFlagsId, "32");
                }
            }

            // Write out last vertex
            DXFUtils.WriteDXFRecord(writer, 0, "VERTEX");

            DXFUtils.WriteDXFRecord(writer, DXFConsts.LayerNameId, DXFUtils.DXFiseLayerName(Layer));
            if (Entities[Entities.Count - 1] is DXFArcEntity arcEntityEnd)
            {
                DXFUtils.WriteXYZToDXF(writer, 0, arcEntityEnd.X2, arcEntityEnd.Y2, Consts.NullDouble, OutputUnits);
            }
            else if (Entities[Entities.Count - 1] is DXFLineEntity lineEntity)
            {
                DXFUtils.WriteXYZToDXF(writer, 0, lineEntity.X2, lineEntity.Y2, HasArcs ? Consts.NullDouble : lineEntity.Z2, OutputUnits);
            }

            if (Output3DVertices)
            {
                DXFUtils.WriteDXFRecord(writer, DXFConsts.VertexFlagsId, "32");
            }

            DXFUtils.WriteDXFRecord(writer, 0, "SEQEND");
        }
コード例 #14
0
 public override BoundingWorldExtent3D BoundingBox() => ArcUtils.ArcBoundingRectangle(X1, Y1, X2, Y2, CX, CY, true, true); // ###Check??? ClockwiseCoordSystem : Boolean;
コード例 #15
0
        protected override void PostEntryStep()
        {
            const string objectId   = "RecordedAt";
            const string object2Id  = "PIP";
            const string object3Id  = "IsAuthorized";
            IActiveView  activeView = ArcUtils.ActiveView;
            IEnvelope    envelope   = activeView.Extent;

            ISpatialFilter spatialFilter = new SpatialFilterClass
            {
                Geometry      = envelope,
                GeometryField = FeatureClass.ShapeFieldName,
                SpatialRel    = esriSpatialRelEnum.esriSpatialRelContains,
                SubFields     = string.Format("{0},{1},{2}", objectId, object2Id, object3Id)
            };

            var      existsResult = FeatureClass.Search(spatialFilter, false);
            IFeature feature;
            var      added          = new List <int>();
            var      pipAdded       = new List <int>();
            var      forbiddenAdded = new List <int>();

            while ((feature = existsResult.NextFeature()) != null)
            {
                // ReSharper disable UseIndexedProperty
                int    imId     = existsResult.FindField(objectId);
                object value    = feature.get_Value(imId);
                var    dateTime = (DateTime)value;
                int    year     = dateTime.Year;

                if (!YearToColor.ContainsKey(year))
                {
                    YearToColor.Add(year, Color.Transparent);
                    added.Add(year);
                }

                int    pipId    = existsResult.FindField(object2Id);
                object pipValue = feature.get_Value(pipId);

                if (pipValue != null)
                {
                    bool pip = bool.Parse((string)pipValue);

                    if (pip && (!YearPip.Contains(year)))
                    {
                        YearPip.Add(year);
                        pipAdded.Add(year);
                    }
                }

                int    forbiddenId    = existsResult.FindField(object3Id);
                object forbiddenValue = feature.get_Value(forbiddenId);
                // ReSharper restore UseIndexedProperty

                if (forbiddenValue != null)
                {
                    bool forbidden = !bool.Parse((string)forbiddenValue);

                    if (forbidden && (!YearForbidden.Contains(year)))
                    {
                        YearForbidden.Add(year);
                        forbiddenAdded.Add(year);
                    }
                }
            }

            var geoFeatureLayer = Layer as IGeoFeatureLayer;

            if (geoFeatureLayer != null)
            {
                IFeatureRenderer featureRenderer = geoFeatureLayer.Renderer;
                var uniqueValueRenderer          = featureRenderer as IUniqueValueRenderer;

                if (uniqueValueRenderer != null)
                {
                    foreach (var value in added)
                    {
                        // ReSharper disable CSharpWarnings::CS0612
                        // ReSharper disable CSharpWarnings::CS0618

                        var symbol = new SimpleMarkerSymbol
                        {
                            Color = Converter.ToRGBColor(Color.Transparent),
                            Size  = SizeLayer
                        };

                        // ReSharper restore CSharpWarnings::CS0618
                        // ReSharper restore CSharpWarnings::CS0612
                        var    markerSymbol = symbol as ISymbol;
                        string classValue   = string.Format("{0}, {1}, {2}", value, false, true);
                        uniqueValueRenderer.AddValue(classValue, string.Empty, markerSymbol);

                        // ReSharper disable UseIndexedProperty
                        string label = value.ToString(CultureInfo.InvariantCulture);
                        uniqueValueRenderer.set_Label(classValue, label);
                        // ReSharper restore UseIndexedProperty
                    }

                    foreach (var value in pipAdded)
                    {
                        var rotationRenderer = uniqueValueRenderer as IRotationRenderer;

                        if (rotationRenderer != null)
                        {
                            rotationRenderer.RotationField = "PIP1Yaw";
                            rotationRenderer.RotationType  = esriSymbolRotationType.esriRotateSymbolGeographic;
                        }

                        Color   color      = YearToColor.ContainsKey(value) ? YearToColor[value] : Color.Transparent;
                        ISymbol symbol     = ArcUtils.GetPipSymbol(SizeLayer, color);
                        string  classValue = string.Format("{0}, {1}, {2}", value, true, true);
                        uniqueValueRenderer.AddValue(classValue, string.Empty, symbol);

                        // ReSharper disable UseIndexedProperty
                        string label = string.Format("{0} (Detail images)", value);
                        uniqueValueRenderer.set_Label(classValue, label);
                        // ReSharper restore UseIndexedProperty
                        activeView.ContentsChanged();
                    }

                    foreach (var value in forbiddenAdded)
                    {
                        Color   color      = YearToColor.ContainsKey(value) ? YearToColor[value] : Color.Transparent;
                        ISymbol symbol     = ArcUtils.GetForbiddenSymbol(SizeLayer, color);
                        string  classValue = string.Format("{0}, {1}, {2}", value, false, false);
                        uniqueValueRenderer.AddValue(classValue, string.Empty, symbol);

                        // ReSharper disable UseIndexedProperty
                        string label = string.Format("{0} (No Authorization)", value);
                        uniqueValueRenderer.set_Label(classValue, label);
                        // ReSharper restore UseIndexedProperty

                        if (pipAdded.Contains(value))
                        {
                            classValue = string.Format("{0}, {1}, {2}", value, true, false);
                            uniqueValueRenderer.AddValue(classValue, string.Empty, symbol);

                            // ReSharper disable UseIndexedProperty
                            label = string.Format("{0} (Detail images, No Authorization)", value);
                            uniqueValueRenderer.set_Label(classValue, label);
                            // ReSharper restore UseIndexedProperty
                        }

                        activeView.ContentsChanged();
                    }
                }
            }

            foreach (var value in added)
            {
                FrmGlobespotter.UpdateColor(this, value);
            }
        }
コード例 #16
0
        // =========================================================================
        // Private Functions
        // =========================================================================
        private void AddObs(Bitmap bitmap, FrmGlobespotter frmGlobespotter, int entityId, int pointId,
                            MeasurementObservation observation)
        {
            if (_entityId != entityId)
            {
                _lastPointIdUpd = null;
            }

            string               imageId      = observation.imageId;
            GsExtension          extension    = GsExtension.GetExtension();
            CycloMediaGroupLayer groupLayer   = extension.CycloMediaGroupLayer;
            IMappedFeature       locationInfo = groupLayer.GetLocationInfo(imageId);
            var    recordingInfo = locationInfo as Recording;
            double stdX          = (recordingInfo == null) ? 0 : (recordingInfo.LongitudePrecision ?? 0);
            double stdY          = (recordingInfo == null) ? 0 : (recordingInfo.LatitudePrecision ?? 0);
            double stdZ          = (recordingInfo == null) ? 0 : (recordingInfo.HeightPrecision ?? 0);
            string std           = string.Format("{0:0.00} {1:0.00} {2:0.00}", stdX, stdY, stdZ);

            if ((_entityId != entityId) || (_pointId != pointId))
            {
                ClearForm(false);
                _entityId           = entityId;
                _pointId            = pointId;
                _measurementPoint   = null;
                _measurementPointS  = null;
                txtNumber.Text      = string.Empty;
                txtPosition.Text    = string.Empty;
                txtPositionStd.Text = string.Empty;
                RelO.Image          = null;
                SetOpenClose(false);
            }

            Measurement measurement = Measurement.Get(_entityId);

            if (measurement != null)
            {
                _measurementPointS = measurement[_pointId];
                _measurementPointS.UpdateObservation(imageId, observation.x, observation.y, observation.z);
                txtNumber.Text = _measurementPointS.M.ToString(_ci);

                if (measurement.IsPointMeasurement)
                {
                    SetOpenClose(true);

                    if (_commandItem == null)
                    {
                        _commandItem = ArcMap.Application.CurrentTool;
                        ArcUtils.SetToolActiveInToolBar("esriEditor.EditTool");
                    }
                }
            }

            if (bitmap != null)
            {
                _bitmapImageId.Add(imageId);
                _idBitmap.Add(bitmap);
            }

            bool add = true;

            foreach (ListViewItem item in lvObservations.Items)
            {
                var obs = item.Tag as MeasurementObservation;

                if (obs != null)
                {
                    if (obs.imageId == imageId)
                    {
                        add = false;
                    }
                }
            }

            if (add)
            {
                _frmGlobespotter = frmGlobespotter;
                var items        = new[] { imageId, std, "X" };
                var listViewItem = new ListViewItem(items)
                {
                    Tag = observation
                };
                lvObservations.Items.Add(listViewItem);
                DrawObservations();
                RedrawObservationList();
            }
        }
コード例 #17
0
        // =========================================================================
        // Functions (Public)
        // =========================================================================
        public string GetGmlFromLocation(List <RecordingLocation> recordingLocations, double distance, out Color color, SpatialReference cyclSpatialRef)
        {
            string result = WfsHeader;

            // ReSharper disable UseIndexedProperty

            if (_featureClass != null)
            {
                IGeometry         geometryBag        = new GeometryBagClass();
                var               geometryCollection = geometryBag as IGeometryCollection;
                Config            config             = Config.Instance;
                SpatialReference  spatRel            = config.SpatialReference;
                ISpatialReference gsSpatialReference = (spatRel == null) ? ArcUtils.SpatialReference : spatRel.SpatialRef;
                var               projCoord          = gsSpatialReference as IProjectedCoordinateSystem;

                if (projCoord == null)
                {
                    var geoCoord = gsSpatialReference as IGeographicCoordinateSystem;

                    if (geoCoord != null)
                    {
                        IAngularUnit unit   = geoCoord.CoordinateUnit;
                        double       factor = unit.ConversionFactor;
                        distance = distance * factor;
                    }
                }
                else
                {
                    ILinearUnit unit   = projCoord.CoordinateUnit;
                    double      factor = unit.ConversionFactor;
                    distance = distance / factor;
                }

                foreach (var recordingLocation in recordingLocations)
                {
                    double x = recordingLocation.X;
                    double y = recordingLocation.Y;

                    IEnvelope envelope = new EnvelopeClass
                    {
                        XMin             = x - distance,
                        XMax             = x + distance,
                        YMin             = y - distance,
                        YMax             = y + distance,
                        SpatialReference = gsSpatialReference
                    };

                    envelope.Project(SpatialReference);
                    geometryCollection.AddGeometry(envelope);
                }

                ITopologicalOperator unionedPolygon = new PolygonClass();
                unionedPolygon.ConstructUnion(geometryBag as IEnumGeometry);
                var polygon = unionedPolygon as IPolygon;

                ISpatialFilter spatialFilter = new SpatialFilterClass
                {
                    Geometry      = polygon,
                    GeometryField = _featureClass.ShapeFieldName,
                    SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects
                };

                var featureCursor = _featureClass.Search(spatialFilter, false);
                var featureCount  = _featureClass.FeatureCount(spatialFilter);
                var shapeId       = featureCursor.FindField(_featureClass.ShapeFieldName);
                var gmlConverter  = new GMLConverter();

                for (int i = 0; i < featureCount; i++)
                {
                    IFeature feature = featureCursor.NextFeature();

                    if (!EditFeatures.Contains(feature))
                    {
                        IFields fields      = feature.Fields;
                        var     fieldvalues = new Dictionary <string, string> {
                            { "FEATURECLASSNAME", _featureClass.AliasName }
                        };

                        for (int j = 0; j < fields.FieldCount; j++)
                        {
                            IField field = fields.Field[j];
                            string name  = field.Name;
                            int    id    = featureCursor.FindField(name);

                            string value = (id != shapeId)
                ? feature.get_Value(id).ToString()
                : _featureClass.ShapeType.ToString().Replace("esriGeometry", string.Empty);
                            fieldvalues.Add(name, value);
                        }

                        var shapeVar = feature.get_Value(shapeId);
                        var geometry = shapeVar as IGeometry;

                        if (geometry != null)
                        {
                            geometry.Project((cyclSpatialRef == null) ? gsSpatialReference : cyclSpatialRef.SpatialRef);

                            if (!HasZ)
                            {
                                var pointCollection = geometry as IPointCollection4;

                                if (pointCollection != null)
                                {
                                    for (int j = 0; j < pointCollection.PointCount; j++)
                                    {
                                        IPoint point = pointCollection.Point[j];

                                        if (point != null)
                                        {
                                            point.Z = double.NaN;
                                        }

                                        pointCollection.ReplacePoints(j, 1, 1, point);
                                    }

                                    shapeVar = pointCollection as IGeometry;
                                }
                                else
                                {
                                    var point = geometry as IPoint;

                                    if (point != null)
                                    {
                                        point.Z  = double.NaN;
                                        shapeVar = point;
                                    }
                                }
                            }
                        }

                        gmlConverter.ESRIGeometry = shapeVar;
                        string gml = gmlConverter.GML;
                        gml = gml.Replace("<Polygon>", string.Format("<Polygon srsDimension=\"{0}\" >", HasZ ? 3 : 2));
                        gml = gml.Replace("<LineString>", string.Format("<LineString srsDimension=\"{0}\" >", HasZ ? 3 : 2));
                        gml = gml.Replace("<point>", string.Format("<point srsDimension=\"{0}\" >", HasZ ? 3 : 2));
                        gml = gml.Replace("point", "Point");
                        gml = gml.Replace(",1.#QNAN", string.Empty);
                        gml = gml.Replace("<", "<gml:");
                        gml = gml.Replace("<gml:/", "</gml:");
                        string fieldValueStr = fieldvalues.Aggregate(string.Empty,
                                                                     (current, fieldvalue) => string.Format("{0}<{1}>{2}</{1}>", current, fieldvalue.Key, fieldvalue.Value));
                        result = string.Format("{0}<gml:featureMember><xs:Geometry>{1}{2}</xs:Geometry></gml:featureMember>", result,
                                               fieldValueStr, gml);
                    }
                }
            }

            // ReSharper restore UseIndexedProperty
            color      = ArcUtils.GetColorFromLayer(_layer);
            GmlChanged = (_color != color);
            _color     = color;
            string newGml = string.Concat(result, WfsFinished);

            GmlChanged = ((newGml != _gml) || GmlChanged);
            return(_gml = newGml);
        }