Example #1
0
        private Symbol ChooseSymbol(ESRI.ArcGIS.Client.Geometry.Geometry geometry)
        {
            Symbol symbol = null;

            switch (geometry.GetType().Name)
            {
            case "Point":
            case "MapPoint":
                if (string.IsNullOrEmpty(widgetConfig.SymbolImage))
                {
                    symbol = this.CurrentApp.Resources[SymbolResources.SIMPLE_MARKER] as SimpleMarkerSymbol;
                }
                else
                {
                    symbol = new PictureMarkerSymbol()
                    {
                        Source = new BitmapImage(new Uri(widgetConfig.SymbolImage, UriKind.Relative)), Width = 28, Height = 28
                    };
                }
                break;

            case "Polyline":
                symbol = this.CurrentApp.Resources[SymbolResources.SIMPLE_LINE] as SimpleLineSymbol;
                break;

            case "Polygon": symbol = this.CurrentApp.Resources[SymbolResources.SIMPLE_FILL] as SimpleFillSymbol;
                break;
            }

            return(symbol);
        }
        /// <summary>
        /// Create zone geometry.
        /// </summary>
        /// <param name="zone">Zone for creating geometry.</param>
        /// <returns>Created geometry.</returns>
        private ESRI.ArcGIS.Client.Geometry.Geometry _CreateGeometry(Zone zone)
        {
            ESRI.ArcGIS.Client.Geometry.Geometry geometry = null;

            if (zone.Geometry != null)
            {
                if (zone.Geometry is ESRI.ArcLogistics.Geometry.Point?)
                {
                    ESRI.ArcLogistics.Geometry.Point?point = zone.Geometry as ESRI.ArcLogistics.Geometry.Point?;
                    geometry = new ESRI.ArcGIS.Client.Geometry.MapPoint(point.Value.X, point.Value.Y);
                }
                else
                {
                    int?spatialReference = null;
                    if (ParentLayer != null)
                    {
                        spatialReference = ParentLayer.SpatialReferenceID;
                    }

                    geometry = MapHelpers.ConvertToArcGISPolygon(
                        zone.Geometry as ESRI.ArcLogistics.Geometry.Polygon, spatialReference);
                }
            }
            else
            {
                geometry = null;
            }

            return(geometry);
        }
Example #3
0
        protected override void ChangeMap()
        {
            if (base._map != null)
            {
                int i;
                if (int.TryParse(_hiddenServiceName.ToCharArray()[_hiddenServiceName.Length - 1].ToString(), out i))//if last char of _hiddenServiceName is int
                {
                    ServiceManager.DeleteService(_port, _hiddenServiceName);
                }
                else
                {
                    _hiddenServiceName = _hiddenServiceName + ServiceManager.PortEntities[_port].ServiceProvider.Services.Count(service => service.Key.Contains(_hiddenServiceName)).ToString();//INTERNALDOWNLOAD0,INTERNALDOWNLOAD1...
                }
                _pbsService = new PBSService(_hiddenServiceName, "", _port, SelectedDatasourceType, "", false, true, true, VisualStyle.None, null);

                ServiceManager.PortEntities[_port].ServiceProvider.Services.Add(_pbsService.ServiceName, _pbsService);
                _map.Layers.RemoveAt(0);
                BaiduTileLayer l = new BaiduTileLayer()
                {
                    baseUrl = _pbsService.UrlArcGIS
                };
                _map.Layers.Insert(0, l);
                Util.Envelope initial = _pbsService.DataSource.TilingScheme.InitialExtent;
                initalExtend = new ESRI.ArcGIS.Client.Geometry.Envelope(initial.XMin, initial.YMin, initial.XMax, initial.YMax);
            }
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="zone">Zone to show.</param>
        private ZoneGraphicObject(Zone zone)
            : base(zone)
        {
            _zone = zone;
            _zone.PropertyChanged += new PropertyChangedEventHandler(_ZonePropertyChanged);

            ESRI.ArcGIS.Client.Geometry.Geometry geometry = _CreateGeometry(zone);
            Geometry = geometry;

            Attributes.Add(SymbologyContext.FILL_ATTRIBUTE_NAME, null);

            _CreateSymbol();
        }
Example #5
0
        /// <summary>
        /// Create barrier geometry.
        /// </summary>
        /// <param name="barrier">Barrier.</param>
        /// <returns>Barrier geometry.</returns>
        private ESRI.ArcGIS.Client.Geometry.Geometry _CreateGeometry(Barrier barrier)
        {
            ESRI.ArcGIS.Client.Geometry.Geometry geometry = null;

            if (barrier.Geometry != null)
            {
                int?spatialReference = null;
                if (ParentLayer != null)
                {
                    spatialReference = ParentLayer.SpatialReferenceID;
                }

                if (barrier.Geometry is ESRI.ArcLogistics.Geometry.Point)
                {
                    ESRI.ArcLogistics.Geometry.Point point = (ESRI.ArcLogistics.Geometry.Point)barrier.Geometry;

                    // Project point from WGS84 to Web Mercator if spatial reference of map is Web Mercator
                    if (ParentLayer != null && ParentLayer.SpatialReferenceID != null)
                    {
                        point = WebMercatorUtil.ProjectPointToWebMercator(point, spatialReference.Value);
                    }

                    geometry = new ESRI.ArcGIS.Client.Geometry.MapPoint(point.X, point.Y);
                }
                else if (barrier.Geometry is ESRI.ArcLogistics.Geometry.Polygon)
                {
                    geometry = MapHelpers.ConvertToArcGISPolygon(
                        barrier.Geometry as ESRI.ArcLogistics.Geometry.Polygon, spatialReference);
                }
                else if (barrier.Geometry is ESRI.ArcLogistics.Geometry.Polyline)
                {
                    geometry = MapHelpers.ConvertToArcGISPolyline(
                        barrier.Geometry as ESRI.ArcLogistics.Geometry.Polyline, spatialReference);
                }
                else
                {
                    System.Diagnostics.Debug.Assert(false);
                }

                _SetSymbol();
            }
            else
            {
                geometry = null;
            }

            return(geometry);
        }
        public async Task QueryForFeatures(client.Geometry.Geometry buffer)
        {
            //Reset the list of TeamsNearby before re-populating them later in the method
            TeamsNearby.Clear();

            //Set up the query and query result
            Query query = new Query("", buffer, true);

            if (TeamDataSrc != null)
            {
                //Run the query and check the result
                QueryResult result = await TeamDataSrc.ExecuteQueryAsync(query);

                if ((result == null) || (result.Canceled) || (result.Features == null))
                {
                    return;
                }

                // Get the array of Oids from the query results.
                var resultOids = from resultFeature in result.Features select System.Convert.ToInt32(resultFeature.Attributes[TeamDataSrc.ObjectIdFieldName]);

                // For each graphic feature in featureLayer, use its OID to find the graphic feature from the result set.
                // Note that though the featureLayer's graphic feature and the result set's feature graphic feature share the same properties,
                // they are indeed different objects
                foreach (client.Graphic team in TeamFeatureLayer.Graphics)
                {
                    int featureOid;
                    int.TryParse(team.Attributes[TeamDataSrc.ObjectIdFieldName].ToString(), out featureOid);

                    //If feature has been selected in previous session, unselect it
                    if (team.Selected)
                    {
                        team.UnSelect();
                    }

                    //If the feature is in the query result set, select it
                    //Also add them to the TeamsNearby list so we can send SMS later
                    if ((resultOids.Contains(featureOid)))
                    {
                        team.Select();
                        TeamsNearby.Add(team);
                    }
                }
            }
        }
        public async Task QueryForFeatures(client.Geometry.Geometry bufferPolygon)
        {
            //Set up the query and query result
            Query query = new Query("", bufferPolygon, true);

            //Run the query and check the result
            QueryResult result = await TargetDataSource.ExecuteQueryAsync(query);

            if ((result == null) || (result.Canceled) || (result.Features == null) || (result.Features.Count < 1))
            {
                return;
            }

            // Get the array of OIDs from the query results.
            var resultOids = from resultFeature in result.Features select Convert.ToInt32(resultFeature.Attributes[TargetDataSource.ObjectIdFieldName]);

            // Get the feature layer in the map for the data source.
            client.FeatureLayer featureLayer = mapWidget.FindFeatureLayer(TargetDataSource);
            if (featureLayer == null)
            {
                return;
            }

            // For each graphic feature in featureLayer, use its OID to find the graphic feature from the result set.
            // Note that though the featureLayer's graphic feature and the result set's feature graphic feature share the same properties,
            // they are indeed different objects
            foreach (client.Graphic feature in featureLayer.Graphics)
            {
                int featureOid;
                int.TryParse(feature.Attributes[TargetDataSource.ObjectIdFieldName].ToString(), out featureOid);

                //If feature has been selected in previous session, unselect it
                if (feature.Selected)
                {
                    feature.UnSelect();
                }

                //If the feature is in the query result set, select it
                if ((resultOids.Contains(featureOid)))
                {
                    feature.Select();
                }
            }
        }
    public async Task QueryForFeatures(client.Geometry.Geometry bufferPolygon)
    {
      //Set up the query and query result
      Query query = new Query("", bufferPolygon, true);
      DataSource ds = OperationsDashboard.Instance.DataSources.Where(d => d.Id == TargetDataSourceId).FirstOrDefault();
      if (ds != null)
      {
          //Run the query and check the result
          QueryResult result = await ds.ExecuteQueryAsync(query);
          if ((result == null) || (result.Canceled) || (result.Features == null) || (result.Features.Count < 1))
              return;

          // Get the array of OIDs from the query results.
          var resultOids = from resultFeature in result.Features select System.Convert.ToInt32(resultFeature.Attributes[ds.ObjectIdFieldName]);

          // Find the map layer in the map widget that contains the target data source.
          MapWidget mapW = MapWidget.FindMapWidget(ds);
          if (mapW != null)
          {
              // Get the feature layer in the map for the data source.
              client.FeatureLayer featureLayer = mapW.FindFeatureLayer(ds);

              // For each graphic feature in featureLayer, use its OID to find the graphic feature from the result set.
              // Note that though the featureLayer's graphic feature and the result set's feature graphic feature share the same properties,
              // they are indeed different objects
              foreach (client.Graphic feature in featureLayer.Graphics)
              {
                  int featureOid;
                  int.TryParse(feature.Attributes[ds.ObjectIdFieldName].ToString(), out featureOid);

                  //If feature has been selected in previous session, unselect it
                  if (feature.Selected)
                      feature.UnSelect();

                  //If the feature is in the query result set, select it
                  if ((resultOids.Contains(featureOid)))
                      feature.Select();
              }
          }

      }
   
    }
Example #9
0
        /// <summary>
        /// React on barrier property changes.
        /// </summary>
        /// <param name="sender">Ignored.</param>
        /// <param name="e">Event args.</param>
        private void _BarrierPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == Barrier.PropertyNameGeometry)
            {
                // if barrier position changed - show barrier in new place
                ESRI.ArcGIS.Client.Geometry.Geometry geometry = _CreateGeometry(_barrier);

                Geometry = geometry;

                _Refresh();
            }
            else if (e.PropertyName.Equals(Barrier.PropertyNameStartDate) ||
                     e.PropertyName.Equals(Barrier.PropertyNameFinishDate))
            {
                // if layer has context, then refresh view.
                if (_objectContext != null)
                {
                    _Refresh();
                }
            }
        }
Example #10
0
        private void RSSTitleLink_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            if (sender is SimpleLinkButton)
            {
                if (selectedRssItemPanel != null)
                {
                    TextBlock oldRssDesc = selectedRssItemPanel.FindName("RssDescription") as TextBlock;
                    oldRssDesc.Visibility = Visibility.Collapsed;

                    HyperlinkButton oldRssLink = selectedRssItemPanel.FindName("RssHyperlink") as HyperlinkButton;
                    oldRssLink.Visibility = Visibility.Collapsed;
                }

                SimpleLinkButton titleLink    = sender as SimpleLinkButton;
                StackPanel       rssItemStack = titleLink.Parent as StackPanel;
                selectedRssItemPanel = rssItemStack;

                TextBlock textRssDesc = rssItemStack.FindName("RssDescription") as TextBlock;
                if (textRssDesc != null)
                {
                    textRssDesc.Visibility = Visibility.Visible;
                }
                HyperlinkButton btnRssLink = rssItemStack.FindName("RssHyperlink") as HyperlinkButton;
                if (btnRssLink != null)
                {
                    btnRssLink.Visibility = Visibility.Visible;
                }

                ESRI.ArcGIS.Client.Geometry.Geometry geometry = titleLink.Tag as ESRI.ArcGIS.Client.Geometry.Geometry;
                this.MapControl.ZoomTo(GeometryTool.ExpandGeometryExtent(geometry, 0.10));

                /* If other widgets need to know the SelectedGraphic */
                this.SelectedGraphic          = new Graphic();
                this.SelectedGraphic.Geometry = geometry;
                this.SelectedGraphic.Attributes.Add("Title", titleLink.Text);
                this.SelectedGraphic.Attributes.Add("Description", textRssDesc.Text);
                this.SelectedGraphic.Attributes.Add("Link", btnRssLink.NavigateUri.AbsoluteUri);
            }
        }
Example #11
0
        private void CacheSnapObjects(ESRI.ArcGIS.Client.Geometry.Geometry geometryObject, double snapDistance)
        {
            // For the given geometry (line or circle), find all the features that fall within the snapDistance.
            // First we need to issue a buffer in this method. GeometryService_LineBufferCompleted will
            // do the feature query.

            _snapObjects.Clear();
            GeometryService geometryServiceScaleRotate = new GeometryService(_xmlConfiguation.GeometryServerUrl);

            if (geometryServiceScaleRotate == null)
            {
                return;
            }

            geometryServiceScaleRotate.BufferCompleted += GeometryService_LineBufferCompleted;
            geometryServiceScaleRotate.Failed          += GeometryService_Failed;
            geometryServiceScaleRotate.CancelAsync();

            Graphic clickGraphic = new Graphic();

            clickGraphic.Symbol   = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol;
            clickGraphic.Geometry = geometryObject;

            // Input spatial reference for buffer operation defined by first feature of input geometry array
            clickGraphic.Geometry.SpatialReference = ParcelMap.SpatialReference;

            // If buffer spatial reference is GCS and unit is linear, geometry service will do geodesic buffering
            ESRI.ArcGIS.Client.Tasks.BufferParameters bufferParams = new ESRI.ArcGIS.Client.Tasks.BufferParameters()
            {
                BufferSpatialReference = ParcelMap.SpatialReference,
                OutSpatialReference    = ParcelMap.SpatialReference,
            };
            bufferParams.Distances.Add(snapDistance);
            bufferParams.Features.Add(clickGraphic);

            System.Diagnostics.Debug.WriteLine("Async: Buffering potential candidates for snapping.");
            geometryServiceScaleRotate.BufferAsync(bufferParams, snapDistance);
        }
Example #12
0
        public static string Encode(ESRI.ArcGIS.Client.Geometry.Geometry geo, int precision)
        {
            var bl = Encode(geo.Extent.YMin, geo.Extent.XMin, precision);
            var tl = Encode(geo.Extent.YMin, geo.Extent.XMax, precision);
            var br = Encode(geo.Extent.YMax, geo.Extent.XMin, precision);
            var tr = Encode(geo.Extent.YMax, geo.Extent.XMax, precision);

            var    list  = (bl + "," + tl + "," + br + "," + tr).Split(',');
            string match = string.Empty;

            for (int i = 0; i < precision; i++)
            {
                for (int j = 0; j < list.Length - 1; j++)
                {
                    if (list[j][i] != list[j + 1][i])
                    {
                        return(match);
                    }
                }
                match += list[0][i];
            }

            return(match);
        }
Example #13
0
        /// <summary>
        /// Check rectangle intersects with geometry.
        /// </summary>
        /// <param name="frame">Rectangle.</param>
        /// <param name="geometry">Geometry to check.</param>
        /// <returns>True if intersects</returns>
        public static bool IsIntersects(ESRI.ArcGIS.Client.Geometry.Envelope frame, ESRI.ArcGIS.Client.Geometry.Geometry geometry)
        {
            bool isIntersects = false;

            if (geometry is ESRI.ArcGIS.Client.Geometry.MapPoint)
            {
                ESRI.ArcGIS.Client.Geometry.MapPoint point = (ESRI.ArcGIS.Client.Geometry.MapPoint)geometry;
                if (frame.Extent.Intersects(point.Extent))
                {
                    isIntersects = true;
                }
            }
            else if (geometry is ESRI.ArcGIS.Client.Geometry.Polyline)
            {
                ESRI.ArcGIS.Client.Geometry.Polyline polyline = (ESRI.ArcGIS.Client.Geometry.Polyline)geometry;
                if (frame.Extent.Intersects(polyline.Extent))
                {
                    foreach (ESRI.ArcGIS.Client.Geometry.PointCollection points in polyline.Paths)
                    {
                        ESRI.ArcGIS.Client.Geometry.MapPoint prevPoint = null;
                        foreach (ESRI.ArcGIS.Client.Geometry.MapPoint point in points)
                        {
                            if (prevPoint != null)
                            {
                                if (_IsSegmentIntersectRectangle(frame.XMin, frame.YMin, frame.XMax, frame.YMax,
                                                                 point.X, point.Y, prevPoint.X, prevPoint.Y))
                                {
                                    isIntersects = true;
                                    break;
                                }
                            }

                            prevPoint = point;
                        }

                        if (isIntersects)
                        {
                            break;
                        }
                    }
                }
            }
            else if (geometry is ESRI.ArcGIS.Client.Geometry.Polygon)
            {
                ESRI.ArcGIS.Client.Geometry.Polygon polygon = (ESRI.ArcGIS.Client.Geometry.Polygon)geometry;
                if (frame.Extent.Intersects(polygon.Extent))
                {
                    foreach (ESRI.ArcGIS.Client.Geometry.PointCollection points in polygon.Rings)
                    {
                        ESRI.ArcGIS.Client.Geometry.MapPoint prevPoint = null;
                        foreach (ESRI.ArcGIS.Client.Geometry.MapPoint point in points)
                        {
                            if (prevPoint != null)
                            {
                                if (_IsSegmentIntersectRectangle(frame.XMin, frame.YMin, frame.XMax, frame.YMax,
                                                                 point.X, point.Y, prevPoint.X, prevPoint.Y))
                                {
                                    isIntersects = true;
                                    break;
                                }
                            }

                            prevPoint = point;
                        }

                        if (isIntersects)
                        {
                            break;
                        }
                    }
                }
            }
            else
            {
                Debug.Assert(false);
            }

            return(isIntersects);
        }