Example #1
0
        public async Task <Measurement> StartMeasurement(Geometry geometry, Measurement measurement, bool sketch, long?objectId, VectorLayer vectorLayer)
        {
            if (GlobeSpotterConfiguration.MeasurePermissions)
            {
                bool measurementExists          = false;
                ArcGISGeometryType geometryType = geometry?.GeometryType ?? ArcGISGeometryType.Unknown;

                if (geometryType == ArcGISGeometryType.Point || geometryType == ArcGISGeometryType.Polygon ||
                    geometryType == ArcGISGeometryType.Polyline)
                {
                    if (measurement?.IsGeometryType(geometryType) ?? false)
                    {
                        measurementExists = true;
                        measurement.OpenMeasurement();
                    }
                    else
                    {
                        measurement?.RemoveMeasurement();
                    }

                    if (!measurementExists)
                    {
                        CloseOpenMeasurement();
                        _lastObjectId    = objectId;
                        _lastVectorLayer = vectorLayer;
                        _lastSketch      = sketch;
                        await CreateMeasurement(geometryType);
                    }
                }
            }

            return(measurement);
        }
Example #2
0
        public async Task CreateMeasurement(ArcGISGeometryType geometryType)
        {
            if (Api != null)
            {
                MeasurementGeometryType measurementGeometryType = MeasurementGeometryType.Unknown;

                switch (geometryType)
                {
                case ArcGISGeometryType.Point:
                    if (GlobeSpotterConfiguration.MeasurePoint)
                    {
                        measurementGeometryType = MeasurementGeometryType.Point;
                    }

                    break;

                case ArcGISGeometryType.Polyline:
                    if (GlobeSpotterConfiguration.MeasureLine)
                    {
                        measurementGeometryType = MeasurementGeometryType.LineString;
                    }

                    break;

                case ArcGISGeometryType.Polygon:
                    if (GlobeSpotterConfiguration.MeasurePolygon)
                    {
                        measurementGeometryType = MeasurementGeometryType.Polygon;
                    }

                    break;
                }

                if (measurementGeometryType != MeasurementGeometryType.Unknown)
                {
                    ModulestreetSmart streetSmartModule = ModulestreetSmart.Current;
                    ViewerList        viewerList        = streetSmartModule.ViewerList;
                    IPanoramaViewer   panoramaViewer    = viewerList.ActiveViewer;

                    if (panoramaViewer != null)
                    {
                        if (Count == 0)
                        {
                            Measurement measurement = new Measurement(null, null, DrawPoint, Api)
                            {
                                ObjectId    = _lastObjectId,
                                VectorLayer = _lastVectorLayer
                            };

                            Add(new Guid().ToString(), measurement);
                            measurement.Open();
                        }

                        //if (_lastSketch)
                        //{
                        Measurement measurement2 = this.ElementAt(0).Value;
                        measurement2.VectorLayer = _lastVectorLayer;
                        measurement2.SetSketch();
                        //}

                        IMeasurementOptions options = MeasurementOptionsFactory.Create(measurementGeometryType);
                        Api.StartMeasurementMode(panoramaViewer, options);
                    }
                }
            }
        }