private static KeyValuePair<string, Resolution> ToResolution(Generated.TileMatrix tileMatrix, int[] ordinateOrder, double metersPerUnit = 1, ScaleSet ss = null) { // Get the coordinates var coords = tileMatrix.TopLeftCorner.Trim().Split(' '); // Try to get units per pixel from passed scale set var unitsPerPixel = tileMatrix.ScaleDenominator*ScaleHint/metersPerUnit; if (unitsPerPixel == 0 || double.IsNaN(unitsPerPixel)) { if (ss == null) throw new ArgumentNullException(); unitsPerPixel = ss[tileMatrix.ScaleDenominator].GetValueOrDefault(0d); } return new KeyValuePair<string, Resolution>(tileMatrix.Identifier.Value, new Resolution ( tileMatrix.Identifier.Value, unitsPerPixel, tileMatrix.TileWidth, tileMatrix.TileHeight, Convert.ToDouble(coords[ordinateOrder[0]], CultureInfo.InvariantCulture), Convert.ToDouble(coords[ordinateOrder[1]], CultureInfo.InvariantCulture), tileMatrix.MatrixWidth, tileMatrix.MatrixHeight, tileMatrix.ScaleDenominator)); }
private static KeyValuePair <string, Resolution> ToResolution(Generated.TileMatrix tileMatrix, int[] ordinateOrder, double metersPerUnit = 1, ScaleSet ss = null) { // Get the coordinates var coords = tileMatrix.TopLeftCorner.Trim().Split(' '); // Try to get units per pixel from passed scale set var unitsPerPixel = tileMatrix.ScaleDenominator * ScaleHint / metersPerUnit; if (unitsPerPixel == 0 || double.IsNaN(unitsPerPixel)) { if (ss == null) { throw new ArgumentNullException(); } unitsPerPixel = ss[tileMatrix.ScaleDenominator].GetValueOrDefault(0d); } return(new KeyValuePair <string, Resolution>(tileMatrix.Identifier.Value, new Resolution { Id = tileMatrix.Identifier.Value, UnitsPerPixel = unitsPerPixel, ScaleDenominator = tileMatrix.ScaleDenominator, Left = Convert.ToDouble(coords[ordinateOrder[0]], CultureInfo.InvariantCulture), Top = Convert.ToDouble(coords[ordinateOrder[1]], CultureInfo.InvariantCulture), MatrixWidth = tileMatrix.MatrixWidth, MatrixHeight = tileMatrix.MatrixHeight, TileWidth = tileMatrix.TileWidth, TileHeight = tileMatrix.TileHeight })); }
private static KeyValuePair <string, Resolution> ToResolution(TileMatrix tileMatrix, int[] ordinateOrder, double metersPerUnit = 1, ScaleSet ss = null) { // Get the coordinates var coords = tileMatrix.TopLeftCorner.Trim().Split(' '); // Try to get units per pixel from passed scale set var unitsPerPixel = tileMatrix.ScaleDenominator * ScaleHint / metersPerUnit; // ReSharper disable once CompareOfFloatsByEqualityOperator if (unitsPerPixel == 0 || double.IsNaN(unitsPerPixel)) { if (ss == null) { throw new ArgumentNullException(); } unitsPerPixel = ss[tileMatrix.ScaleDenominator].GetValueOrDefault(0d); } return(new KeyValuePair <string, Resolution>(tileMatrix.Identifier.Value, new Resolution ( tileMatrix.Identifier.Value, unitsPerPixel, tileMatrix.TileWidth, tileMatrix.TileHeight, Convert.ToDouble(coords[ordinateOrder[0]], CultureInfo.InvariantCulture), Convert.ToDouble(coords[ordinateOrder[1]], CultureInfo.InvariantCulture), (int)tileMatrix.MatrixWidth, (int)tileMatrix.MatrixHeight, tileMatrix.ScaleDenominator))); }
private static KeyValuePair<string, Resolution> ToResolution(Generated.TileMatrix tileMatrix, int[] ordinateOrder, double metersPerUnit = 1, ScaleSet ss = null) { // Get the coordinates var coords = tileMatrix.TopLeftCorner.Trim().Split(' '); // Try to get units per pixel from passed scale set var unitsPerPixel = tileMatrix.ScaleDenominator*ScaleHint/metersPerUnit; if (unitsPerPixel == 0 || double.IsNaN(unitsPerPixel)) { if (ss == null) throw new ArgumentNullException(); unitsPerPixel = ss[tileMatrix.ScaleDenominator].GetValueOrDefault(0d); } // the top left point can be provided as (x, y) or (y, x) to take care of this problem ordinateOrder is used return new KeyValuePair<string, Resolution>(tileMatrix.Identifier.Value, new Resolution ( tileMatrix.Identifier.Value, unitsPerPixel, tileMatrix.TileWidth, tileMatrix.TileHeight, Convert.ToDouble(coords[ordinateOrder[1]], //the top coordinate of the top left corner this is the y coordinate of a point which is usually given in the form (x, y) CultureInfo.InvariantCulture), Convert.ToDouble(coords[ordinateOrder[0]], //the left coordinate of the top left corner this is the x coordinate of a point which is usually given in the form (x, y) CultureInfo.InvariantCulture), tileMatrix.MatrixWidth, tileMatrix.MatrixHeight, tileMatrix.ScaleDenominator)); }