private static List<ITileSchema> GetTileMatrixSets(IEnumerable<TileMatrixSet> tileMatrixSets) { // Get a set of well known scale sets. For these we don't need to have var wkss = new WellKnownScaleSets(); // Axis order registry var crsAxisOrder = new CrsAxisOrderRegistry(); // Unit of measure registry var crsUnitOfMeasure = new CrsUnitOfMeasureRegistry(); var tileSchemas = new List<ITileSchema>(); foreach (var tileMatrixSet in tileMatrixSets) { // Check if a Well-Known scale set is used, either by Identifier or WellKnownScaleSet property var ss = wkss[tileMatrixSet.Identifier.Value]; if (ss == null && !string.IsNullOrEmpty(tileMatrixSet.WellKnownScaleSet)) ss = wkss[tileMatrixSet.WellKnownScaleSet.Split(':').Last()]; // Try to parse the Crs var supportedCrs = tileMatrixSet.SupportedCRS; // Hack to fix broken crs spec supportedCrs = supportedCrs.Replace("6.18:3", "6.18.3"); CrsIdentifier crs; if (!CrsIdentifier.TryParse(supportedCrs, out crs)) { // If we cannot parse the crs, we cannot compute tile schema, thus ignore. // ToDo: Log this continue; } // Get the ordinate order for the crs (x, y) or (y, x) aka (lat, long) var ordinateOrder = crsAxisOrder[crs]; // Get the unit of measure for the crs var unitOfMeasure = crsUnitOfMeasure[crs]; // Create a new WMTS tile schema var tileSchema = new WmtsTileSchema(); // Add the resolutions foreach (var tileMatrix in tileMatrixSet.TileMatrix) { tileSchema.Resolutions.Add(ToResolution(tileMatrix, ordinateOrder, unitOfMeasure.ToMeter, ss)); } tileSchema.Extent = ToExtent(tileMatrixSet, tileSchema, ordinateOrder); // Fill in the remaining properties tileSchema.Name = tileMatrixSet.Identifier.Value; tileSchema.YAxis = YAxis.OSM; tileSchema.Srs = supportedCrs; tileSchema.SupportedSRS = crs; // record the tile schema tileSchemas.Add(tileSchema); } return tileSchemas; }
private static List <ITileSchema> GetTileMatrixSets(IEnumerable <TileMatrixSet> tileMatrixSets, BoundingBoxAxisOrderInterpretation bbaoi) { // Get a set of well known scale sets. For these we don't need to have var wkss = new WellKnownScaleSets(); // Axis order registry var crsAxisOrder = new CrsAxisOrderRegistry(); // Unit of measure registry var crsUnitOfMeasure = new CrsUnitOfMeasureRegistry(); var tileSchemas = new List <ITileSchema>(); foreach (var tileMatrixSet in tileMatrixSets) { // Check if a Well-Known scale set is used, either by Identifier or WellKnownScaleSet property var ss = wkss[tileMatrixSet.Identifier.Value]; if (ss == null && !string.IsNullOrEmpty(tileMatrixSet.WellKnownScaleSet)) { ss = wkss[tileMatrixSet.WellKnownScaleSet.Split(':').Last()]; } // Try to parse the Crs var supportedCrs = tileMatrixSet.SupportedCRS; // Hack to fix broken crs spec supportedCrs = supportedCrs.Replace("6.18:3", "6.18.3"); CrsIdentifier crs; if (!CrsIdentifier.TryParse(supportedCrs, out crs)) { // If we cannot parse the crs, we cannot compute tile schema, thus ignore. // ToDo: Log this continue; } // Get the ordinate order for the crs (x, y) or (y, x) aka (lat, long) var ordinateOrder = crsAxisOrder[crs]; // Get the unit of measure for the crs var unitOfMeasure = crsUnitOfMeasure[crs]; // Create a new WMTS tile schema var tileSchema = new WmtsTileSchema(); // Add the resolutions foreach (var tileMatrix in tileMatrixSet.TileMatrix) { tileSchema.Resolutions.Add(ToResolution(tileMatrix, ordinateOrder, unitOfMeasure.ToMeter, ss)); } tileSchema.Extent = ToExtent(tileMatrixSet, tileSchema, GetOrdinateOrder(bbaoi, ordinateOrder)); // Fill in the remaining properties tileSchema.Name = tileMatrixSet.Identifier.Value; tileSchema.YAxis = YAxis.OSM; tileSchema.Srs = supportedCrs; tileSchema.SupportedSRS = crs; // record the tile schema tileSchemas.Add(tileSchema); } return(tileSchemas); }