< Summary

Class:DCL.Helpers.MapUtils
Assembly:MapRenderer
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/MapRenderer/MapUtils.cs
Covered lines:28
Uncovered lines:2
Coverable lines:30
Total lines:55
Line coverage:93.3% (28 of 30)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
MapUtils()0%110100%
GetTileFromLocalPosition(...)0%2100%
GetTileToLocalPosition(...)0%110100%
GetMarketPlaceThumbnailUrl(...)0%77095.65%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/MapRenderer/MapUtils.cs

#LineLine coverage
 1using UnityEngine;
 2
 3namespace DCL.Helpers
 4{
 5    public static class MapUtils
 6    {
 17        public static readonly Vector2Int WORLD_PARCELS_OFFSET_MIN = new Vector2Int(-150, -150);
 18        public static readonly Vector2Int WORLD_PARCELS_OFFSET_MAX = new Vector2Int(175, 175); //NOTE(Brian): We use 175
 19        public static readonly Vector2Int CHUNK_SIZE = new Vector2Int(1020, 1020);
 110        public static readonly int PARCEL_SIZE = 20;
 11
 012        public static Vector2Int GetTileFromLocalPosition(Vector3 position) { return new Vector2Int((int)(position.x / P
 13
 14        public static Vector3 GetTileToLocalPosition(float x, float y)
 15        {
 116            x -= WORLD_PARCELS_OFFSET_MIN.x;
 117            y -= WORLD_PARCELS_OFFSET_MIN.y;
 18
 119            Vector3 result = new Vector3(x * PARCEL_SIZE, y * PARCEL_SIZE, 0);
 120            return result;
 21        }
 22
 23        public static string GetMarketPlaceThumbnailUrl(Vector2Int[] parcels, int width, int height, int sizeFactor)
 24        {
 525            string parcelsStr = "";
 526            Vector2Int min = new Vector2Int(int.MaxValue, int.MaxValue);
 527            Vector2Int max = new Vector2Int(int.MinValue, int.MinValue);
 28            Vector2Int coord;
 29
 2030            for (int i = 0; i < parcels.Length; i++)
 31            {
 532                coord = parcels[i];
 533                parcelsStr += string.Format("{0},{1}", coord.x, coord.y);
 534                if (i < parcels.Length - 1)
 035                    parcelsStr += ";";
 36
 537                if (coord.x < min.x)
 538                    min.x = coord.x;
 539                if (coord.y < min.y)
 540                    min.y = coord.y;
 541                if (coord.x > max.x)
 542                    max.x = coord.x;
 543                if (coord.y > max.y)
 544                    max.y = coord.y;
 45            }
 46
 547            int centerX = (int)(min.x + (max.x - min.x) * 0.5f);
 548            int centerY = (int)(min.y + (max.y - min.y) * 0.5f);
 549            int sceneMaxSize = Mathf.Clamp(Mathf.Max(max.x - min.x, max.y - min.y), 1, int.MaxValue);
 550            int size = sizeFactor / sceneMaxSize;
 51
 552            return $"https://api.decentraland.org/v1/map.png?width={width}&height={height}&size={size}&center={centerX},
 53        }
 54    }
 55}