public void MustCreateDto() { var mapPoint = new MapPoint(_name, _latitude, _longitude); var dto = new MapPointDTO(mapPoint); Assert.Equal(_name, dto.Name); Assert.Equal(_latitude, dto.Latitude); Assert.Equal(_longitude, dto.Longitude); }
public async Task <ActionResult> Create(MapPointDTO mapPointDTO) { var mapPoint = mapPointDTO.ToEntity(); if (!mapPoint.IsValid) { return(BadRequest(mapPoint.ValidationResult)); } await _mapPointService.AddAsync(mapPoint); return(CreatedAtAction("Get", new { Id = mapPoint.Id }, new MapPointDTO(mapPoint))); }
public void MustCreateFromDto() { var dto = new MapPointDTO { Name = _name, Latitude = _latitude, Longitude = _longitude }; var mapPoint = dto.ToEntity(); Assert.Equal(_name, mapPoint.Name); Assert.Equal(_latitude, mapPoint.Latitude); Assert.Equal(_longitude, mapPoint.Longitude); }
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); }
public Guid AddMapdData(MapPointDTO mapPoint) { Database.MapPoint tosave = new Database.MapPoint() { Latitude = mapPoint.Latitude, Longitude = mapPoint.Longitude, MetaData = mapPoint.MetaData }; try { repository.Insert(tosave); return(tosave.Id); } catch (Exception e) { throw new Exception("Could not save map point"); } }
public List <BusinessRuleRegionDTO> GetAllRegions() { var res = new List <BusinessRuleRegionDTO>(); var entities = _operationDB.Regions.Where(x => x.IsDeleted == false && x.RegionTypeId == (int)RegionType.NORMAL).ToList(); if (entities != null && entities.Any()) { foreach (var item in entities) { var model = new BusinessRuleRegionDTO() { RegionId = item.RegionId, RegionName = item.RegionName, RegionTypes = (int)RegionType.NORMAL }; if (item.RegionPoints != null && item.RegionPoints != "") { var points = new List <MapPointDTO>(); var allPoints = item.RegionPoints.Split(';'); if (allPoints != null && allPoints.Any()) { foreach (var point in allPoints) { var latLonPair = point.Split('&'); if (latLonPair != null && latLonPair.Count() == 2) { var mapPoint = new MapPointDTO { Latitude = double.Parse(latLonPair[0]), Longitude = double.Parse(latLonPair[1]) }; points.Add(mapPoint); } } } model.RegionPoints = points; } res.Add(model); } } return(res); }
public async Task <ActionResult <UserDTO> > UpdateMapPoint(Guid mapPointId, MapPointDTO mapPointDTO) { if (mapPointId == null || mapPointId == Guid.Empty) { return(StatusCode(500, $"{nameof(mapPointId)} can't be empty.")); } if (mapPointDTO.Id != null && mapPointDTO.Id != Guid.Empty && mapPointDTO.Id != mapPointId) { return(StatusCode(500, $"{nameof(mapPointId)} invalid.")); } var mapPoint = mapPointDTO.ToEntity(); mapPoint.Id = mapPointId; await _mapPointService.UpdateAsync(mapPoint); return(Ok(new MapPointDTO(mapPoint))); }
public BusinessRuleRegionDTO GetRegionById(int regionId) { var entity = _operationDB.Regions.FirstOrDefault(x => x.IsDeleted == false && x.RegionId == regionId); if (entity != null) { var model = new BusinessRuleRegionDTO() { RegionId = entity.RegionId, RegionName = entity.RegionName, RegionTypes = (int)RegionType.NORMAL }; if (entity.RegionPoints != null && entity.RegionPoints != "") { var points = new List <MapPointDTO>(); var allPoints = entity.RegionPoints.Split(';'); if (allPoints != null && allPoints.Any()) { foreach (var point in allPoints) { var latLonPair = point.Split('&'); if (latLonPair != null && latLonPair.Count() == 2) { var mapPoint = new MapPointDTO { Latitude = double.Parse(latLonPair[0]), Longitude = double.Parse(latLonPair[1]) }; points.Add(mapPoint); } } } model.RegionPoints = points; } return(model); } return(new BusinessRuleRegionDTO()); }
public virtual IActionResult AddMappingPoint([FromBody] MapPointDTO mapPoint) { return(new ObjectResult((mapPointService.AddMapdData(mapPoint)))); }