public void Grid500KmToGeoJsonTest()
        {
            new GridImportTest().StoreSsb500KmTest();

            var grid     = SqlServer.GetGrid(RutenettType.SSB500KM, new Collection <int>(), new Collection <int>(), "", "", 3857, 0);
            var gridJson = GeoJsonConverter.GridToGeoJson(grid, false);

            Assert.True(gridJson.Length > 10000); // 10479
        }
        public void Grid1KmToGeoJsonTest()
        {
            new GridImportTest().StoreSsb001KmTest();

            var grid     = SqlServer.GetGrid(RutenettType.SSB001KM, new Collection <int>(), new Collection <int>(), "", "", 3857, 0);
            var gridJson = GeoJsonConverter.GridToGeoJson(grid, false);

            Assert.IsNotEmpty(gridJson);
            Assert.AreEqual(152909657, gridJson.Length);
        }
        public object GetGrid([FromBody] GridFilterRequest gridFilterRequest)
        {
            var gridType    = RutenettType.Undefined;
            var areaType    = AreaType.Undefined;
            var areaRequest = false;

            if (gridFilterRequest == null)
            {
                throw new Exception("Type rutenett er ikke spesifisert.");
            }

            switch (gridFilterRequest.GridType)
            {
            case "Undefined":
                gridType = RutenettType.Undefined;
                break;

            case "SSB0250M":
                gridType = RutenettType.SSB0250M;
                break;

            case "SSB0500M":
                gridType = RutenettType.SSB0500M;
                break;

            case "SSB001KM":
                gridType = RutenettType.SSB001KM;
                break;

            case "SSB002KM":
                gridType = RutenettType.SSB002KM;
                break;

            case "SSB005KM":
                gridType = RutenettType.SSB005KM;
                break;

            case "SSB010KM":
                gridType = RutenettType.SSB010KM;
                break;

            case "SSB025KM":
                gridType = RutenettType.SSB025KM;
                break;

            case "SSB050KM":
                gridType = RutenettType.SSB050KM;
                break;

            case "SSB100KM":
                gridType = RutenettType.SSB100KM;
                break;

            case "SSB250KM":
                gridType = RutenettType.SSB250KM;
                break;

            case "SSB500KM":
                gridType = RutenettType.SSB500KM;
                break;

            case "Kommune":
                areaType    = AreaType.Kommune;
                areaRequest = true;
                break;

            case "Fylke":
                areaType    = AreaType.Fylke;
                areaRequest = true;
                break;

            default:
                throw new Exception("Ukjent rutenett '" + gridFilterRequest.GridType + "'.");
            }

            if (areaRequest)
            {
                var areaGrid = SqlServer.GetAreas(areaType, gridFilterRequest.GridLayerTypeId);
                return(GeoJsonConverter.AreasToGeoJson(areaGrid, gridFilterRequest.GridLayerTypeId != 0));
            }

            var grid = SqlServer.GetGrid(
                gridType,
                gridFilterRequest.Municipalities,
                gridFilterRequest.Counties,
                gridFilterRequest.Geometry,
                gridFilterRequest.BoundingBox,
                gridFilterRequest.EpsgCode,
                gridFilterRequest.GridLayerTypeId
                );

            return(GeoJsonConverter.GridToGeoJson(grid, gridFilterRequest.GridLayerTypeId != 0));
        }