Beispiel #1
0
 private void Start()
 {
     gameManager     = FindObjectOfType <GameManager>();
     foesManager     = FindObjectOfType <FoesManager>();
     parameters      = gameManager.parameters;
     tilesReferences = parameters.tilesReferences;
 }
Beispiel #2
0
        public MapElementActions(SinglePlayerMenuActions parent, MapParameters parameters)
        {
            this.parent     = parent;
            this.parameters = parameters;

            Initialize();
        }
Beispiel #3
0
        /// <summary>
        /// Gets a map tile with spatial filter boundaries drawn on it
        /// </summary>
        /// <param name="parameters">Map parameters such as bounding box, tile size, zoom level etc.</param>
        /// <param name="filterPolygons">List of filter polygons</param>
        /// <param name="boundaryType">Type of filter boundary which determines the color</param>
        /// <returns>A bitmap</returns>
        public byte[] GetFilterBoundaryBitmap(MapParameters parameters, List <List <WGSPoint> > filterPolygons, FilterBoundaryType boundaryType)
        {
            byte[] geofenceImage = null;

            if (filterPolygons != null && filterPolygons.Any())
            {
                using (Image <Rgba32> bitmap = new Image <Rgba32>(parameters.mapWidth, parameters.mapHeight))
                {
                    foreach (var polygonPoints in filterPolygons)
                    {
                        if (polygonPoints != null && polygonPoints.Any())
                        {
                            int color = 0;
                            switch (boundaryType)
                            {
                            case FilterBoundaryType.Alignment:
                                color = DEFAULT_ALIGNMENT_BOUNDARY_COLOR;
                                break;

                            case FilterBoundaryType.Design:
                                color = DEFAULT_DESIGN_BOUNDARY_COLOR;
                                break;

                            default:
                                color = DEFAULT_CUSTOM_BOUNDARY_COLOR;
                                break;
                            }
                            DrawGeofence(parameters, bitmap, $"{boundaryType} Filter Boundary", polygonPoints, color, true);
                        }
                    }
                    geofenceImage = bitmap.BitmapToByteArray();
                }
            }
            return(geofenceImage);
        }
 private void Start()
 {
     random       = new Random(gameManager.seed);
     mapGenerator = gameManager.mapGenerator;
     grid         = gameManager.grid;
     parameters   = gameManager.parameters;
 }
Beispiel #5
0
        /// <summary>
        /// Gets a map tile with the project boundary drawn on it.
        /// </summary>
        /// <param name="parameters">Map parameters such as bounding box, tile size, zoom level etc.</param>
        /// <param name="project">The project to draw the boundary for</param>
        /// <returns>A bitmap</returns>
        public byte[] GetProjectBitmap(MapParameters parameters, ProjectData project)
        {
            log.LogInformation($"GetProjectBitmap: project {project.ProjectUID}");

            const int PROJECT_BOUNDARY_COLOR = 0x0080FF; //Note: packed is abgr order
            const int STROKE_TRANSPARENCY    = 0x73;     //0.45 of FF
            Rgba32    PROJECT_BOUNDARY_RGBA  = new Rgba32((uint)((STROKE_TRANSPARENCY << 24) | PROJECT_BOUNDARY_COLOR));
            const int PROJECT_OUTLINE_WIDTH  = 4;

            byte[] projectImage = null;

            if (project != null)
            {
                using (Image <Rgba32> bitmap = new Image <Rgba32>(parameters.mapWidth, parameters.mapHeight))
                {
                    var      projectPoints = project.ProjectGeofenceWKT.GeometryToPoints();
                    PointF[] pixelPoints   = TileServiceUtils.LatLngToPixelOffset(projectPoints, parameters.pixelTopLeft, parameters.numTiles);

                    bitmap.Mutate(ctx => ctx.DrawPolygon(PROJECT_BOUNDARY_RGBA, PROJECT_OUTLINE_WIDTH, pixelPoints));

                    projectImage = bitmap.BitmapToByteArray();
                }
            }

            return(projectImage);
        }
Beispiel #6
0
        [InlineData(4096, 4096, false, 4096, 4096, 1.5269, 1.1341, -1.4009, 1.1341)]//tile larger than bbox
        public void TestZeroAreaBoundingBoxes(int tileWidth, int tileHeight, bool addMargin, int expectedWidth, int expectedHeight,
                                              double expectedMinLat, double expectedMinLng, double expectedMaxLat, double expectedMaxLng)
        {
            var            minLat = 0.63137;  //36.175°
            var            minLng = -2.00748; //-115.020°
            var            maxLat = 0.63137;  //36.178°
            var            maxLng = -2.00748; //-115.018°
            MapBoundingBox bbox   = new MapBoundingBox
            {
                minLat = minLat,
                minLng = minLng,
                maxLat = maxLat,
                maxLng = maxLng
            };

            var service = new BoundingBoxService(loggerFactory);
            //numTiles = 1048576 for Z10
            MapParameters parameters = new MapParameters
            {
                bbox      = bbox,
                numTiles  = 1048576,
                zoomLevel = 10,
                mapWidth  = tileWidth,
                mapHeight = tileHeight,
                addMargin = addMargin
            };

            service.AdjustBoundingBoxToFit(parameters);
            parameters.mapWidth.Should().Be(expectedWidth);
            parameters.mapHeight.Should().Be(expectedHeight);
            parameters.bbox.minLat.Should().BeApproximately(expectedMinLat, 0.0001);
            parameters.bbox.minLng.Should().BeApproximately(expectedMinLng, 0.0001);
            parameters.bbox.maxLat.Should().BeApproximately(expectedMaxLat, 0.0001);
            parameters.bbox.maxLng.Should().BeApproximately(expectedMaxLng, 0.0001);
        }
        public SvcAppSPGlymaSession(GlymaSessionConfiguration configuration)
        {
            _configuration = configuration;
            _sessionId = Guid.Empty;

            _session = new MapSession(this);
            _parameters = new MapParameters(this);
        }
Beispiel #8
0
        public SvcAppSPGlymaSession(GlymaSessionConfiguration configuration)
        {
            _configuration = configuration;
            _sessionId     = Guid.Empty;

            _session    = new MapSession(this);
            _parameters = new MapParameters(this);
        }
Beispiel #9
0
    // Start is called before the first frame update
    void Start()
    {
        attackingFoes = new List <Transform>();
        mapDrawer     = FindObjectOfType <MapDrawer>();
        gameManager   = FindObjectOfType <GameManager>();

        parameters = gameManager.parameters;
    }
Beispiel #10
0
        public WebAppSPGlymaSession(string callingUrl)
        {
            _callingUrl = callingUrl;
            _sessionId  = Guid.Empty;

            _session    = new MapSession(this);
            _parameters = new MapParameters(this);
        }
        public SvcAppSPGlymaSession(GlymaSessionConfiguration configuration, Guid sessionId)
        {
            _configuration = configuration;
            _sessionId = sessionId;

            _session = new MapSession(this, _sessionId);

            _parameters = new MapParameters(this);
        }
Beispiel #12
0
        public SvcAppSPGlymaSession(GlymaSessionConfiguration configuration, Guid sessionId)
        {
            _configuration = configuration;
            _sessionId     = sessionId;

            _session = new MapSession(this, _sessionId);

            _parameters = new MapParameters(this);
        }
Beispiel #13
0
        public WebAppSPGlymaSession(string callingUrl, Guid sessionId)
        {
            _callingUrl = callingUrl;
            _sessionId  = sessionId;

            _session = new MapSession(this, _sessionId);

            _parameters = new MapParameters(this);
        }
Beispiel #14
0
 public void Init(MapParameters mapParameters)
 {
     if (mapParameters == null || !mapParameters.Set)
     {
         return;
     }
     InitMode   = mapParameters.InitMode;
     StartPoint = DatabaseService.GetInstance().GetPoint(mapParameters.StartId);
     EndPoint   = DatabaseService.GetInstance().GetPoint(mapParameters.EndId);
 }
Beispiel #15
0
        public WebAppSPGlymaSession(string callingUrl, Guid?domainId, Guid?rootMapId, params IRight[] requiredRights)
        {
            _callingUrl = callingUrl;
            _sessionId  = Guid.Empty;

            if (!IsAuthorised(domainId, rootMapId, requiredRights))
            {
                throw new UnauthorizedAccessException("This user does not have the required privileges for this task.");
            }

            _session    = new MapSession(this);
            _parameters = new MapParameters(this);
        }
Beispiel #16
0
        /// <summary>
        /// Gets a map tile with the geoJson boundary drawn on it.
        /// </summary>
        /// <param name="parameters">Map parameters such as bounding box, tile size, zoom level etc.</param>
        /// <param name="points">The points from the geoJson</param>
        /// <returns></returns>
        public byte[] GetGeoJsonBitmap(MapParameters parameters, List <WGSPoint> points)
        {
            byte[] geofenceImage = null;

            if (points != null && points.Any())
            {
                using (Image <Rgba32> bitmap = new Image <Rgba32>(parameters.mapWidth, parameters.mapHeight))
                {
                    DrawGeofence(parameters, bitmap, "Geofence GeoJson", points, GEOJSON_BOUNDARY_COLOR, true);
                    geofenceImage = bitmap.BitmapToByteArray();
                }
            }
            return(geofenceImage);
        }
Beispiel #17
0
        /// <summary>
        /// Gets a map tile with geofences drawn on it.
        /// </summary>
        /// <param name="parameters">Map parameters such as bounding box, tile size, zoom level etc.</param>
        /// <param name="sites">List of geofences for the customer</param>
        /// <returns>A bitmap</returns>
        private byte[] GetGeofencesBitmap(MapParameters parameters, IEnumerable <GeofenceData> sites, bool isSites)
        {
            log.LogInformation("GetGeofencesBitmap");

            const int DEFAULT_SITE_COLOR = 0x0055FF;

            byte[] sitesImage = null;

            if (sites != null && sites.Any())
            {
                // Exclude sites that are too small to be displayed in the current viewport.
                double viewPortArea = Math.Abs(parameters.bbox.minLatDegrees - parameters.bbox.maxLatDegrees) * Math.Abs(parameters.bbox.minLngDegrees - parameters.bbox.maxLngDegrees);
                double minArea      = viewPortArea / 10000;

                using (Image <Rgba32> bitmap = new Image <Rgba32>(parameters.mapWidth, parameters.mapHeight))
                {
                    foreach (var site in sites)
                    {
                        log.LogDebug($"GetGeofencesBitmap examining site {site.GeofenceUID}");
                        //Old geofences may not have AreaSqMeters set.
                        if (site.AreaSqMeters > 0 && site.AreaSqMeters < minArea)
                        {
                            log.LogDebug($"GetGeofencesBitmap excluding site {site.GeofenceUID} due to area");
                            continue;
                        }

                        var sitePoints = site.GeometryWKT.GeometryToPoints().ToList();

                        //Exclude site if outside bbox
                        bool outside = TileServiceUtils.Outside(parameters.bbox, sitePoints);

                        if (outside)
                        {
                            log.LogDebug($"GetGeofencesBitmap excluding site {site.GeofenceUID} outside bbox");
                        }
                        else
                        {
                            int  siteColor   = site.FillColor > 0 ? site.FillColor : (isSites ? DEFAULT_SITE_COLOR : DEFAULT_CUSTOM_BOUNDARY_COLOR);
                            bool transparent = isSites ? site.IsTransparent : true;
                            DrawGeofence(parameters, bitmap, site.GeofenceUID.ToString(), sitePoints, siteColor, transparent);
                        }
                    }

                    sitesImage = bitmap.BitmapToByteArray();
                }
            }

            return(sitesImage);
        }
Beispiel #18
0
        /// <summary>
        /// Gets a map tile with load/dump locations drawn on it.
        /// </summary>
        /// <param name="parameters">Map parameters such as bounding box, tile size, zoom level etc.</param>
        /// <param name="loadDumpLocations">List of Load/Dump locations</param>
        /// <returns>A bitmap</returns>
        public byte[] GetLoadDumpBitmap(MapParameters parameters, List <LoadDumpLocation> loadDumpLocations)
        {
            log.LogInformation($"GetLoadDumpBitmap");

            //Note: packed is abgr order
            const uint LOAD_COLOR = 0xFF008F01; //Green 0x018F00
            const uint DUMP_COLOR = 0xFFFF3304; //Blue 0x0433FF
            Rgba32     LOAD_RGBA  = new Rgba32(LOAD_COLOR);
            Rgba32     DUMP_RGBA  = new Rgba32(DUMP_COLOR);
            var        loadPen    = new Pen <Rgba32>(LOAD_RGBA, 1);
            var        dumpPen    = new Pen <Rgba32>(DUMP_RGBA, 1);

            byte[] loadDumpImage = null;
            if (loadDumpLocations != null && loadDumpLocations.Any())
            {
                using (Image <Rgba32> bitmap = new Image <Rgba32>(parameters.mapWidth, parameters.mapHeight))
                {
                    IEnumerable <WGSPoint> loads = loadDumpLocations
                                                   .Select(x => new WGSPoint(x.loadLatitude.LatDegreesToRadians(), x.loadLongitude.LonDegreesToRadians())).ToList();
                    PointF[] pixelPoints = TileServiceUtils.LatLngToPixelOffset(loads, parameters.pixelTopLeft, parameters.numTiles);
                    foreach (var p in pixelPoints)
                    {
                        //Coloring one pixel doesn't show up well therefore do rectangle of 4 pixels
                        var x    = (int)p.X;
                        var y    = (int)p.Y;
                        var rect = new RectangleF(x, y, 2, 2);
                        bitmap.Mutate(ctx => ctx.Draw(loadPen, rect));
                        //bitmap[(int) p.X, (int) p.Y] = LOAD_RGBA;
                    }

                    IEnumerable <WGSPoint> dumps = loadDumpLocations
                                                   .Select(x => new WGSPoint(x.dumpLatitude.LatDegreesToRadians(), x.dumpLongitude.LonDegreesToRadians())).ToList();
                    pixelPoints = TileServiceUtils.LatLngToPixelOffset(dumps, parameters.pixelTopLeft, parameters.numTiles);
                    foreach (var p in pixelPoints)
                    {
                        var x    = (int)p.X;
                        var y    = (int)p.Y;
                        var rect = new RectangleF(x, y, 2, 2);
                        bitmap.Mutate(ctx => ctx.Draw(dumpPen, rect));
                        //bitmap[(int) p.X, (int) p.Y] = DUMP_RGBA;
                    }

                    loadDumpImage = bitmap.BitmapToByteArray();
                }
            }

            return(loadDumpImage);
        }
Beispiel #19
0
        private void WebMapOpen_Click(object sender, RoutedEventArgs e)
        {
            string mapId = ((Button)sender)?.Tag?.ToString();

            if (string.IsNullOrWhiteSpace(mapId))
            {
                return; //TODO: Log this
            }

            var parameters = new MapParameters()
            {
                MapId = mapId
            };

            this.Frame.Navigate(typeof(MapViewer), parameters);
        }
Beispiel #20
0
        /// <summary>
        /// Generates a randomized Map object based on the map generator's properties.
        /// </summary>
        public static Map GenerateMap(MapParameters mapParams)
        {
            if (mapParams == null)
            {
                throw new System.ArgumentNullException("mapParams");
            }

            return(MapBuilder
                   .InitializeRandomMap(mapParams.Length, mapParams.Width, mapParams.InitialDensity, mapParams.Seed)
                   .Smooth()
                   .RemoveSmallFloorRegions(mapParams.MinFloorSize)
                   .ExpandRegions(mapParams.FloorExpansion)
                   .ConnectFloors(tunnelRadius: BASE_TUNNEL_RADIUS + mapParams.FloorExpansion)
                   .SmoothOnlyWalls()
                   .RemoveSmallWallRegions(mapParams.MinWallSize)
                   .ApplyBorder(mapParams.BorderSize));
        }
Beispiel #21
0
        public void OverlayTilesReturnsTileForEmptyList()
        {
            var mapParameters = new MapParameters {
                mapWidth = 4, mapHeight = 4
            };
            var result = TileServiceUtils.OverlayTiles(mapParameters, new Dictionary <TileOverlayType, byte[]>());

            byte[] expectedResult = null;
            using (Image <Rgba32> bitmap = new Image <Rgba32>(mapParameters.mapWidth, mapParameters.mapHeight))
            {
                expectedResult = bitmap.BitmapToByteArray();
            }

            for (int i = 0; i < expectedResult.Length; i++)
            {
                Assert.Equal(expectedResult[i], result[i]);
            }
        }
Beispiel #22
0
    public Grid(MapParameters parameters, MapGenerator generator)
    {
        this.parameters = parameters;
        mapGenerator    = generator;

        nodes = new GridNode[parameters.mapSizeX - 1, parameters.mapSizeY - 1];

        for (int x = 0; x < parameters.mapSizeX - 1; x++)
        {
            float nodePosX = (x * parameters.cellSize.x) + parameters.cellSize.x;

            for (int y = 0; y < parameters.mapSizeY - 1; y++)
            {
                float nodePosY = (y * parameters.cellSize.y) + parameters.cellSize.y;

                nodes[x, y] = new GridNode(x, y, nodePosX, nodePosY);
            }
        }
    }
Beispiel #23
0
    // Start is called before the first frame update
    public MapGenerator(MapParameters parameters)
    {
        this.parameters = parameters;

        // Init the map array
        cells = new Cell[parameters.mapSizeX, parameters.mapSizeY];

        for (int x = 0; x < parameters.mapSizeX; x++)
        {
            float cellPosX = (x * parameters.cellSize.x) + (parameters.cellSize.x / 2);

            for (int y = 0; y < parameters.mapSizeY; y++)
            {
                float cellPosY = (y * parameters.cellSize.y) + (parameters.cellSize.y / 2);

                cells[x, y] = new Cell(x, y, cellPosX, cellPosY);
            }
        }
    }
Beispiel #24
0
        private async void OpenMapArea_Click(object sender, RoutedEventArgs e)
        {
            string areaId = ((Button)sender)?.Tag?.ToString();

            if (string.IsNullOrWhiteSpace(areaId))
            {
                return; //TODO: Log this
            }

            var area = this.ViewModel.MapAreasRaw.FirstOrDefault(m => m.Id == areaId);
            var path = MapAreaManager.GetOfflineMapPath(areaId);
            MobileMapPackage offlineMapPackage = await MobileMapPackage.OpenAsync(path);

            var parameters = new MapParameters()
            {
                Map = offlineMapPackage.Maps.FirstOrDefault()
            };

            this.Frame.Navigate(typeof(MapViewer), parameters);
        }
Beispiel #25
0
        private void TryZoomIn(MapParameters parameters, out int requiredWidth, out int requiredHeight, out Point pixelMin, out Point pixelMax)
        {
            pixelMin = TileServiceUtils.LatLngToPixel(parameters.bbox.minLat, parameters.bbox.minLng, parameters.numTiles);
            pixelMax = TileServiceUtils.LatLngToPixel(parameters.bbox.maxLat, parameters.bbox.maxLng, parameters.numTiles);

            requiredWidth  = (int)Math.Abs(pixelMax.x - pixelMin.x);
            requiredHeight = (int)Math.Abs(pixelMax.y - pixelMin.y);

            //See if we can zoom in - occurs when the requested tile size is much larger than the bbox
            var   zoomedWidth    = requiredWidth;
            var   zoomedHeight   = requiredHeight;
            int   zoomLevel      = parameters.zoomLevel;
            Point zoomedPixelMin = pixelMin;
            Point zoomedPixelMax = pixelMax;
            long  numTiles       = parameters.numTiles;

            //allow a 15% margin extra otherwise if the tile is only a few pixels bigger than the calculated zoom
            //we use the smaller zoom level and end up with lots of space around the data.
            //AdjustBoundingBoxToFit handles the bigger size.
            var mapWidth  = parameters.mapWidth * 1.15;
            var mapHeight = parameters.mapHeight * 1.15;

            while (zoomedWidth < mapWidth && zoomedHeight < mapHeight && zoomLevel < MAX_ZOOM_LEVEL)
            {
                parameters.zoomLevel = zoomLevel;
                parameters.numTiles  = numTiles;
                requiredWidth        = zoomedWidth;
                requiredHeight       = zoomedHeight;
                pixelMin             = zoomedPixelMin;
                pixelMax             = zoomedPixelMax;

                zoomLevel++;
                numTiles = TileServiceUtils.NumberOfTiles(zoomLevel);

                zoomedPixelMin = TileServiceUtils.LatLngToPixel(parameters.bbox.minLat, parameters.bbox.minLng, numTiles);
                zoomedPixelMax = TileServiceUtils.LatLngToPixel(parameters.bbox.maxLat, parameters.bbox.maxLng, numTiles);

                zoomedWidth  = (int)Math.Abs(zoomedPixelMax.x - zoomedPixelMin.x);
                zoomedHeight = (int)Math.Abs(zoomedPixelMax.y - zoomedPixelMin.y);
            }
        }
Beispiel #26
0
        private void DrawGeofence(MapParameters parameters, Image <Rgba32> bitmap, string uid, IEnumerable <WGSPoint> points, int color, bool isTransparent)
        {
            const byte FILL_TRANSPARENCY   = 0x40; //0.25 of FF
            const byte STROKE_TRANSPARENCY = 0x73; //0.45 of FF
            const int  SITE_OUTLINE_WIDTH  = 2;

            log.LogDebug($"DrawGeofence drawing site or boundary {uid}");
            var red   = (byte)((color & 0xFF0000) >> 16);
            var green = (byte)((color & 0x00FF00) >> 8);
            var blue  = (byte)(color & 0x0000FF);

            PointF[] pixelPoints = TileServiceUtils.LatLngToPixelOffset(points, parameters.pixelTopLeft, parameters.numTiles);
            if (!isTransparent)
            {
                var fillColor = new Rgba32(red, green, blue, FILL_TRANSPARENCY);
                bitmap.Mutate(ctx => ctx.FillPolygon(fillColor, pixelPoints));
            }
            var lineColor = new Rgba32(red, green, blue, STROKE_TRANSPARENCY);

            bitmap.Mutate(ctx => ctx.DrawPolygon(lineColor, SITE_OUTLINE_WIDTH, pixelPoints));
        }
Beispiel #27
0
        /// <summary>
        /// Overlays the collection of tiles on top of each other and returns a single tile
        /// </summary>
        /// <param name="parameters">Map parameters such as bounding box, tile size, zoom level etc.</param>
        /// <param name="tileList">The list of tiles to overlay</param>
        /// <returns>A single bitmap of the overlayed tiles</returns>
        public static byte[] OverlayTiles(MapParameters parameters, IDictionary <TileOverlayType, byte[]> tileList)
        {
            //Order for overlays:
            List <TileOverlayType> orderedOverlayTypes = new List <TileOverlayType>
            {
                TileOverlayType.BaseMap, TileOverlayType.ProjectBoundary, TileOverlayType.Geofences, TileOverlayType.GeofenceBoundary,
                TileOverlayType.ProductionData, TileOverlayType.LoadDumpData,
                TileOverlayType.FilterCustomBoundary, TileOverlayType.FilterDesignBoundary, TileOverlayType.FilterAlignmentBoundary,
                TileOverlayType.CutFillDesignBoundary, TileOverlayType.DxfLinework, TileOverlayType.Alignments
            };
            //Make an orderd list
            List <byte[]> overlays = new List <byte[]>();

            foreach (var overLayType in orderedOverlayTypes)
            {
                if (tileList.ContainsKey(overLayType))
                {
                    overlays.Add(tileList[overLayType]);
                }
            }
            return(OverlayTiles(parameters, overlays));
        }
Beispiel #28
0
        /// <summary>
        /// Overlays the collection of tiles on top of each other and returns a single tile
        /// </summary>
        /// <param name="parameters">Map parameters such as bounding box, tile size, zoom level etc.</param>
        /// <param name="tileList">The list of tiles to overlay</param>
        /// <returns>A single bitmap of the overlayed tiles</returns>
        public static byte[] OverlayTiles(MapParameters parameters, IEnumerable <byte[]> tileList)
        {
            byte[] overlayData = null;
            //Overlay the tiles. Return an empty tile if none to overlay.
            using (Image <Rgba32> bitmap = new Image <Rgba32>(parameters.mapWidth, parameters.mapHeight))
            {
                foreach (byte[] tileData in tileList)
                {
                    if (tileData != null && tileData.Length > 0)
                    {
                        using (var tileStream = new MemoryStream(tileData))
                        {
                            var image = Image.Load <Rgba32>(tileStream);
                            bitmap.Mutate(ctx => ctx.DrawImage(image, 1f));
                        }
                    }
                }
                overlayData = bitmap.BitmapToByteArray();
            }

            return(overlayData);
        }
Beispiel #29
0
        public WebAppSPGlymaSession(string callingUrl, Guid sessionId, bool isParameter, MapParameter domainParameter, MapParameter rootMapParameter, params IRight[] requiredRights)
        {
            _callingUrl = callingUrl;
            _sessionId  = sessionId;

            IRight[] heightenedRightRequirement = requiredRights;

            Guid?domainId  = null;
            Guid?rootMapId = null;

            if (rootMapParameter == null || rootMapParameter.IsDelayed)
            {
                /// If they passed through a delayed rootmap ID parameter, they are going to have to be a Glyma Map Manager at the very minimum to finish this transaction.
                heightenedRightRequirement = new IRight[] { SPGlymaRightFactory.Instance.RootMapCreateRight };
            }
            else
            {
                rootMapId = rootMapParameter.Value;
            }

            if (domainParameter == null || domainParameter.IsDelayed)
            {
                /// If they passed through a delayed domain ID parameter, they are going to have to be a Glyma Project Manager at the very minimum to finish this transaction.
                heightenedRightRequirement = new IRight[] { SPGlymaRightFactory.Instance.ProjectCreateRight };
            }
            else
            {
                domainId = domainParameter.Value;
            }

            if (!IsAuthorised(domainId, rootMapId, heightenedRightRequirement))
            {
                throw new UnauthorizedAccessException("This user does not have the required privileges for this task.");
            }

            _session = new MapSession(this, _sessionId);

            _parameters = new MapParameters(this);
        }
Beispiel #30
0
        /// <summary>
        /// Gets a map tile with alignment center lines drawn on it.
        /// </summary>
        /// <param name="parameters">Map parameters such as bounding box, tile size, zoom level etc.</param>
        /// <param name="projectId">Legacy project ID</param>
        /// <param name="alignmentPointsList">Points for the project's alignment files</param>
        /// <returns>A bitmap</returns>
        public byte[] GetAlignmentsBitmap(MapParameters parameters, long projectId, List <List <WGSPoint> > alignmentPointsList)
        {
            log.LogInformation($"GetAlignmentsBitmap: project {projectId}");

            byte[] alignmentsImage = null;
            if (alignmentPointsList != null && alignmentPointsList.Any())
            {
                using (Image <Rgba32> bitmap = new Image <Rgba32>(parameters.mapWidth, parameters.mapHeight))
                {
                    foreach (var alignmentPoints in alignmentPointsList)
                    {
                        if (alignmentPoints != null && alignmentPoints.Any())
                        {
                            PointF[] pixelPoints = TileServiceUtils.LatLngToPixelOffset(alignmentPoints, parameters.pixelTopLeft, parameters.numTiles);
                            bitmap.Mutate(ctx => ctx.DrawLines(Rgba32.Red, 1, pixelPoints));
                        }
                    }
                    alignmentsImage = bitmap.BitmapToByteArray();
                }
            }
            return(alignmentsImage);
        }
        public WebAppSPGlymaSession(string callingUrl, bool isParameter, MapParameter domainParameter, MapParameter rootMapParameter, params IRight[] requiredRights)
        {
            _callingUrl = callingUrl;
            _sessionId = Guid.Empty;

            IRight[] heightenedRightRequirement = requiredRights;

            Guid? domainId = null;
            Guid? rootMapId = null;

            if (rootMapParameter == null || rootMapParameter.IsDelayed)
            {
                /// If they passed through a delayed rootmap ID parameter, they are going to have to be a Glyma Map Manager at the very minimum to finish this transaction.
                heightenedRightRequirement = new IRight[] { SPGlymaRightFactory.Instance.RootMapCreateRight };
            }
            else
            {
                rootMapId = rootMapParameter.Value;
            }

            if (domainParameter == null || domainParameter.IsDelayed)
            {
                /// If they passed through a delayed domain ID parameter, they are going to have to be a Glyma Project Manager at the very minimum to finish this transaction.
                heightenedRightRequirement = new IRight[] { SPGlymaRightFactory.Instance.ProjectCreateRight };
            }
            else
            {
                domainId = domainParameter.Value;
            }

            if (!IsAuthorised(domainId, rootMapId, heightenedRightRequirement))
            {
                throw new UnauthorizedAccessException("This user does not have the required privileges for this task.");
            }

            _session = new MapSession(this);
            _parameters = new MapParameters(this);
        }
Beispiel #32
0
 public void SetContent(MapParameters parameters)
 {
     if (!parameters.IsFolder())
     {
         ScenarioName.Content      = parameters.Basic.scenario_name;
         PlayersValue.Content      = parameters.Basic.players_value;
         MapSize.Content           = parameters.Basic.width_size.ToString() + 'x' + parameters.Basic.height_size.ToString();
         VictoryConditions.Content = parameters.Basic.victory_conditions;
         DefeatConditions.Content  = parameters.Basic.defeat_conditions;
     }
     else
     {
         string name = Path.GetFileName(parameters.Basic.scenario_name);
         if (name == Settings.Default.MAPS_DIRECTORY_NAME)
         {
             ScenarioName.Content = "...";
         }
         else
         {
             ScenarioName.Content = name;
         }
     }
 }
Beispiel #33
0
        /// <summary>
        /// Gets a map tile with DXF linework on it.
        /// </summary>
        /// <param name="parameters">Map parameters such as bounding box, tile size, zoom level etc.</param>
        /// <param name="dxfFiles">The list of DXF files to overlay tiles for</param>
        /// <returns>A bitmap</returns>
        public async Task <byte[]> GetDxfBitmap(MapParameters parameters, IEnumerable <FileData> dxfFiles)
        {
            log.LogInformation("GetDxfBitmap");

            byte[] overlayData = null;

            if (dxfFiles != null && dxfFiles.Any())
            {
                List <byte[]> tileList = new List <byte[]>();
                foreach (var dxfFile in dxfFiles)
                {
                    if (dxfFile.ImportedFileType == ImportedFileType.Linework)
                    {
                        tileList.Add(await JoinDxfTiles(parameters, dxfFile));
                    }
                }

                log.LogDebug("Overlaying DXF bitmaps");
                overlayData = TileServiceUtils.OverlayTiles(parameters, tileList);
            }

            return(overlayData);
        }
 public UpdateRelationship(MapParameters sessionMapParameters)
 {
     SessionMapParameters = sessionMapParameters;
 }
Beispiel #35
0
 public UpdateMetadata(MapParameters sessionMapParameters)
 {
     SessionMapParameters = sessionMapParameters;
 }
Beispiel #36
0
 public UpdateDescriptor(MapParameters sessionMapParameters)
 {
     SessionMapParameters = sessionMapParameters;
 }
        public WebAppSPGlymaSession(string callingUrl, Guid sessionId, Guid? domainId, Guid? rootMapId, params IRight[] requiredRights)
        {
            _callingUrl = callingUrl;
            _sessionId = sessionId;

            if (!IsAuthorised(domainId, rootMapId, requiredRights))
            {
                throw new UnauthorizedAccessException("This user does not have the required privileges for this task.");
            }

            _session = new MapSession(this, _sessionId);

            _parameters = new MapParameters(this);
        }
        public WebAppSPGlymaSession(string callingUrl)
        {
            _callingUrl = callingUrl;
            _sessionId = Guid.Empty;

            _session = new MapSession(this);
            _parameters = new MapParameters(this);
        }
        public WebAppSPGlymaSession(string callingUrl, Guid sessionId)
        {
            _callingUrl = callingUrl;
            _sessionId = sessionId;

            _session = new MapSession(this, _sessionId);

            _parameters = new MapParameters(this);
        }
Beispiel #40
0
 internal CreateDescriptor(MapParameters sessionMapParameters)
 {
     SessionMapParameters = sessionMapParameters;
 }
Beispiel #41
0
 public DeleteNode(MapParameters sessionMapParameters)
 {
     SessionMapParameters = sessionMapParameters;
 }
Beispiel #42
0
 public UpdateNode(MapParameters sessionMapParameters)
 {
     SessionMapParameters = sessionMapParameters;
 }