< 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:27
Uncovered lines:6
Coverable lines:33
Total lines:63
Line coverage:81.8% (27 of 33)
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%2100%
GetTileCenterToLocalPosition(...)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        {
 016            x -= WORLD_PARCELS_OFFSET_MIN.x;
 017            y -= WORLD_PARCELS_OFFSET_MIN.y;
 18
 019            Vector3 result = new Vector3(x * PARCEL_SIZE, y * PARCEL_SIZE, 0);
 020            return result;
 21        }
 22
 23        public static Vector3 GetTileCenterToLocalPosition(float x, float y)
 24        {
 125            x -= WORLD_PARCELS_OFFSET_MIN.x;
 126            y -= WORLD_PARCELS_OFFSET_MIN.y;
 27
 128            return new Vector3((x * PARCEL_SIZE)+(PARCEL_SIZE/2), (y * PARCEL_SIZE) + (PARCEL_SIZE / 2), 0);
 29        }
 30
 31        public static string GetMarketPlaceThumbnailUrl(Vector2Int[] parcels, int width, int height, int sizeFactor)
 32        {
 533            string parcelsStr = "";
 534            Vector2Int min = new Vector2Int(int.MaxValue, int.MaxValue);
 535            Vector2Int max = new Vector2Int(int.MinValue, int.MinValue);
 36            Vector2Int coord;
 37
 2038            for (int i = 0; i < parcels.Length; i++)
 39            {
 540                coord = parcels[i];
 541                parcelsStr += string.Format("{0},{1}", coord.x, coord.y);
 542                if (i < parcels.Length - 1)
 043                    parcelsStr += ";";
 44
 545                if (coord.x < min.x)
 546                    min.x = coord.x;
 547                if (coord.y < min.y)
 548                    min.y = coord.y;
 549                if (coord.x > max.x)
 550                    max.x = coord.x;
 551                if (coord.y > max.y)
 552                    max.y = coord.y;
 53            }
 54
 555            int centerX = (int)(min.x + (max.x - min.x) * 0.5f);
 556            int centerY = (int)(min.y + (max.y - min.y) * 0.5f);
 557            int sceneMaxSize = Mathf.Clamp(Mathf.Max(max.x - min.x, max.y - min.y), 1, int.MaxValue);
 558            int size = sizeFactor / sceneMaxSize;
 59
 560            return $"https://api.decentraland.org/v1/map.png?width={width}&height={height}&size={size}&center={centerX},
 61        }
 62    }
 63}