public void ReadCoordinateSystem() { var k3CompleteJson = GetJson("Item", "K3A_20200508102646_28267_00027320_L1G"); ValidateJson(k3CompleteJson); StacItem k3Complete = StacConvert.Deserialize <StacItem>(k3CompleteJson); k3Complete.ProjectionExtension().SetCoordinateSystem(4326); Assert.Equal("GEOGCS[\"WGS 84\", DATUM[\"WGS_1984\", SPHEROID[\"WGS 84\", 6378137, 298.257223563, AUTHORITY[\"EPSG\", \"7030\"]], AUTHORITY[\"EPSG\", \"6326\"]], PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\", \"8901\"]], UNIT[\"degree\", 0.01745329251994328, AUTHORITY[\"EPSG\", \"9122\"]], AUTHORITY[\"EPSG\", \"4326\"]]", k3Complete.ProjectionExtension().Wkt2); ValidateJson(StacConvert.Serialize(k3Complete)); }
public void SetCoordinateSystem() { var k3CompleteJson = GetJson("Item", "K3A_20200508102646_28267_00027320_L1G"); ValidateJson(k3CompleteJson); StacItem k3Complete = StacConvert.Deserialize <StacItem>(k3CompleteJson); k3Complete.ProjectionExtension().SetCoordinateSystem(ProjNet.CoordinateSystems.GeocentricCoordinateSystem.WGS84); string k3newProjJson = StacConvert.Serialize(k3Complete); var expectedJson = GetJson("Item", "K3A_20200508102646_28267_00027320_L1G_newproj"); ValidateJson(expectedJson); JsonAssert.AreEqual(expectedJson, k3newProjJson); }
public Dictionary <string, StacAsset> SelectOverviewCombinationAssets(StacItem stacItem) { Dictionary <string, StacAsset> overviewAssets = stacItem.Assets .Where(a => a.Value.Roles != null) .Where(a => a.Value.Roles.Contains("overview") || a.Value.Roles.Contains("visual")) .Where(a => a.Key == "overview-trc") .Where(a => TITILER_VALID_TYPE.Contains(a.Value.MediaType?.MediaType)) .Take(1) .ToDictionary(a => a.Key, a => a.Value); if (overviewAssets.Count == 1) { return(overviewAssets); } overviewAssets = stacItem.Assets.Where(a => a.Value.Roles != null) .Where(a => a.Value.Roles.Contains("overview") || a.Value.Roles.Contains("visual")) .OrderBy(a => a.Value.GetProperty <long>("size")) .Where(a => TITILER_VALID_TYPE.Contains(a.Value.MediaType?.MediaType)) .Take(1) .ToDictionary(a => a.Key, a => a.Value); if (overviewAssets.Count == 1) { return(overviewAssets); } var projext = stacItem.ProjectionExtension(); overviewAssets = stacItem.Assets .Where(a => a.Key.Equals("red", StringComparison.InvariantCultureIgnoreCase) || a.Key.Equals("green", StringComparison.InvariantCultureIgnoreCase) || a.Key.Equals("blue", StringComparison.InvariantCultureIgnoreCase)) .Where(a => TITILER_VALID_TYPE.Contains(a.Value.MediaType?.MediaType)) .OrderByDescending(a => a.Key) .ToDictionary(a => a.Key, a => a.Value); if (overviewAssets.Count == 3 && projext.IsDeclared) { return(overviewAssets); } var eoStacExtension = stacItem.EoExtension(); if (eoStacExtension.IsDeclared) { overviewAssets = stacItem.Assets.Where(a => { var bands = a.Value.GetProperty <EoBandObject[]>("eo:bands"); if (bands == null) { return(false); } return(bands.Any(band => OVERVIEW_NAMES.ToList().Contains(band.CommonName.ToString()))); }) .Where(a => TITILER_VALID_TYPE.Contains(a.Value.MediaType?.MediaType)) .OrderByDescending(a => a.Value.GetProperty <EoBandObject[]>("eo:bands").First().CommonName.ToString()) .Take(3) .ToDictionary(a => a.Key, a => a.Value); } if (overviewAssets.Count >= 1 && projext != null) { return(overviewAssets); } overviewAssets = stacItem.Assets .Where(a => a.Key == "overview") .Where(a => TITILER_VALID_TYPE.Contains(a.Value.MediaType?.MediaType)) .ToDictionary(a => a.Key, a => a.Value); if (overviewAssets.Count == 1) { return(overviewAssets); } overviewAssets = stacItem.Assets .Where(a => a.Key == "composite") .Where(a => TITILER_VALID_TYPE .Contains(a.Value.MediaType?.MediaType)).ToDictionary(a => a.Key, a => a.Value); if (overviewAssets.Count == 1) { return(overviewAssets); } if (eoStacExtension != null) { overviewAssets = stacItem.Assets.Where(a => { var bands = a.Value.GetProperty <EoBandObject[]>("eo:bands"); if (bands == null) { return(false); } return(bands.Any(band => OVERVIEW_NAMES.ToList().Contains(band.CommonName.ToString()))); }) .Where(a => TITILER_VALID_TYPE.Contains(a.Value.MediaType?.MediaType)) .ToDictionary(a => a.Key, a => a.Value); } if (overviewAssets.Count >= 1) { return(overviewAssets); } return(new Dictionary <string, StacAsset>()); }