Ejemplo n.º 1
0
        public List <GraphicDTO> GetDriveTimePolygons(MapPointDTO point)
        {
            try
            {
                var res    = new List <GraphicDTO>();
                var config = new ConfigurationModule.ConfigurationModule();
                config.Initialize();
                var           identify              = new IdentifyModule.IdentifyModule(config, null);
                var           spcRef                = new SpatialReference(4326);
                SymbolCreator _symbolCreator        = new SymbolCreator(config);
                var           networkAnalysisModule = new NetworkAnalysisModule.NetworkAnalysisModule(identify, config);
                // point.Extent.Extent
                var     mobileAssetIdentifyLayerConfig = config.IdentifyConfig.MapServices.SelectMany(x => x.Layers).FirstOrDefault(x => x.ID == 1);
                var     actionConfig = mobileAssetIdentifyLayerConfig.Actions.FirstOrDefault(x => x.Type == ActionType.ServiceArea.ToString());
                var     timeRanges   = actionConfig.TimeRanges.Select(x => Convert.ToDouble(x.Time)).ToArray();
                Graphic g            = new Graphic();
                g.Geometry = new MapPoint(point.Longitude, point.Latitude, spcRef);
                List <Feature> serviceAreaPolygons    = networkAnalysisModule.GetServiceArea(spcRef, g, timeRanges).Result;
                var            polygonHighlightConfig = config.ZoomAndHighlightConfig.Highlight.Symbols.Polygon;
                if (serviceAreaPolygons != null && serviceAreaPolygons.Any())
                {
                    for (int i = 0; i < serviceAreaPolygons.Count; i++)
                    {
                        var polygonColor = actionConfig.TimeRanges[i].Color;
                        var symbol       = _symbolCreator.CreatePolygonSymbol(polygonColor, polygonHighlightConfig.OutlineColor, polygonHighlightConfig.Thickness);

                        //var graphic = new Graphic()
                        //{
                        //    Symbol = symbol,
                        //    Geometry = serviceAreaPolygons[i].Geometry
                        //};
                        var grpDto = new GraphicDTO();
                        grpDto.polygonObject = serviceAreaPolygons[i].Geometry.ToJson();
                        grpDto.symbolObject  = symbol.ToJson();
                        res.Add(grpDto);
                    }
                }
                return(res);
            }
            catch (Exception ex)
            {
            }
            return(null);
        }
Ejemplo n.º 2
0
        public List <AssetsDetailsViewDTO> GetAssets(List <MapPointDTO> mapPoints)
        {
            try
            {
                var res    = new List <AssetsDetailsViewDTO>();
                var points = new List <Esri.ArcGISRuntime.Geometry.MapPoint>();
                foreach (var item in mapPoints)
                {
                    points.Add(new Esri.ArcGISRuntime.Geometry.MapPoint(item.Longitude, item.Latitude, new Esri.ArcGISRuntime.Geometry.SpatialReference(4326)));
                }
                var config = new ConfigurationModule.ConfigurationModule();
                config.Initialize();

                //config.IdentifyConfig
                var x       = new IdentifyModule.IdentifyModule(config, null);
                var options = new Infrastructure.CommonEvents.IdentifyServiceParameters();
                options.MapSpatialReference = new Esri.ArcGISRuntime.Geometry.SpatialReference(4326);
                options.IdentifyGeometry    = new Esri.ArcGISRuntime.Geometry.Polygon(points, options.MapSpatialReference);
                var list = x.Identify(options).Result;

                if (list != null)
                {
                    foreach (var item in list)
                    {
                        var asset = new AssetsDetailsViewDTO();
                        asset.SerialNo = item.ReturnFeature != null && item.ReturnFeature.Attributes != null && item.ReturnFeature.Attributes.ContainsKey("CH_No") && item.ReturnFeature.Attributes["CH_No"] != null ? item.ReturnFeature.Attributes["CH_No"].ToString() : item.DisplayFieldValue;
                        asset.Name     = item.ReturnFeature != null && item.ReturnFeature.Attributes != null && item.ReturnFeature.Attributes.ContainsKey("CH_No") && item.ReturnFeature.Attributes["CH_No"] != null ? item.ReturnFeature.Attributes["CH_No"].ToString() : item.DisplayFieldValue;

                        res.Add(asset);
                    }
                }
                return(res);
            }
            catch (Exception ex)
            {
            }
            return(null);
        }