diff --git a/S1XViewer.HDF/Extensions.cs b/S1XViewer.HDF/Extensions.cs
index a27ba22..a41cf22 100644
--- a/S1XViewer.HDF/Extensions.cs
+++ b/S1XViewer.HDF/Extensions.cs
@@ -19,7 +19,7 @@ public static class Extensions
///
public static bool Contains(this List elements, string label)
{
- foreach(var element in elements)
+ foreach (var element in elements)
{
if (element.Name == label) return true;
}
@@ -54,10 +54,28 @@ public static bool Contains(this List elements, string lab
{
if (element != null && element.Values != null)
{
- return (T)((Array)element.Values).GetValue(0);
+ var value = ((Array)element.Values).GetValue(0) ?? "";
+
+ if (typeof(T).ToString().ToUpper().Contains("DOUBLE"))
+ {
+ if (double.TryParse(value.ToString(), out double doubleValue))
+ {
+ return (T)(object)doubleValue;
+ }
+ }
+ else if (typeof(T).ToString().ToUpper().Contains("FLOAT"))
+ {
+ if (float.TryParse(value.ToString(), out float floatValue))
+ {
+ return (T)(object)floatValue;
+ }
+ }
+
+ return (T)value;
}
return defaultValue;
}
}
}
+
diff --git a/S1XViewer.Model/S111DCF2DataParser.cs b/S1XViewer.Model/S111DCF2DataParser.cs
index 4165a04..6e458fd 100644
--- a/S1XViewer.Model/S111DCF2DataParser.cs
+++ b/S1XViewer.Model/S111DCF2DataParser.cs
@@ -76,13 +76,13 @@ public override async Task ParseAsync(string hdf5FileName, Dat
// retrieve boundingbox
var eastBoundLongitudeAttribute = hdf5S111Root.Attributes.Find("eastBoundLongitude");
- var eastBoundLongitude = eastBoundLongitudeAttribute?.Value(0f) ?? 0.0;
+ var eastBoundLongitude = eastBoundLongitudeAttribute?.Value(0f) ?? 0.0;
var northBoundLatitudeAttribute = hdf5S111Root.Attributes.Find("northBoundLatitude");
- var northBoundLatitude = northBoundLatitudeAttribute?.Value(0f) ?? 0f;
+ var northBoundLatitude = northBoundLatitudeAttribute?.Value(0f) ?? 0f;
var southBoundLatitudeAttribute = hdf5S111Root.Attributes.Find("southBoundLatitude");
- var southBoundLatitude = southBoundLatitudeAttribute?.Value(0f) ?? 0f;
+ var southBoundLatitude = southBoundLatitudeAttribute?.Value(0f) ?? 0f;
var westBoundLongitudeAttribute = hdf5S111Root.Attributes.Find("westBoundLongitude");
- var westBoundLongitude = westBoundLongitudeAttribute?.Value(0f) ?? 0f;
+ var westBoundLongitude = westBoundLongitudeAttribute?.Value(0f) ?? 0f;
var horizontalCRSAttribute = hdf5S111Root.Attributes.Find("horizontalCRS");
var horizontalCRS = horizontalCRSAttribute?.Value(4326) ?? 4326;
@@ -96,13 +96,13 @@ await Task.Run(() =>
//we've found the relevant group. Use this group to create features on by calculating its position
var minGroupParentNode = (Hdf5Element)minGroup.Parent;
var gridOriginLatitudeElement = minGroupParentNode.Attributes.Find("gridOriginLatitude");
- var gridOriginLatitude = gridOriginLatitudeElement?.Value();
+ var gridOriginLatitude = gridOriginLatitudeElement?.Value();
var gridOriginLongitudeElement = minGroupParentNode.Attributes.Find("gridOriginLongitude");
- var gridOriginLongitude = gridOriginLongitudeElement?.Value();
+ var gridOriginLongitude = gridOriginLongitudeElement?.Value();
var gridSpacingLatitudinalElement = minGroupParentNode.Attributes.Find("gridSpacingLatitudinal");
- var gridSpacingLatitudinal = gridSpacingLatitudinalElement?.Value();
+ var gridSpacingLatitudinal = gridSpacingLatitudinalElement?.Value();
var gridSpacingLongitudinalElement = minGroupParentNode.Attributes.Find("gridSpacingLongitudinal");
- var gridSpacingLongitudinal = gridSpacingLongitudinalElement?.Value();
+ var gridSpacingLongitudinal = gridSpacingLongitudinalElement?.Value();
var numPointsLatitudinalElement = minGroupParentNode.Attributes.Find("numPointsLatitudinal");
int numPointsLatitude = numPointsLatitudinalElement?.Value() ?? -1;
@@ -145,7 +145,7 @@ await Task.Run(() =>
}
}
- Progress?.Invoke(50 + ((50 / numPointsLatitude) * latIdx));
+ Progress?.Invoke(50 + (int)((50.0 / (double) numPointsLatitude) * (double) latIdx));
}
// build up featutes ard wrap 'em in datapackage
diff --git a/S1XViewer/MainWindow.xaml.cs b/S1XViewer/MainWindow.xaml.cs
index 940eff7..ebc329e 100644
--- a/S1XViewer/MainWindow.xaml.cs
+++ b/S1XViewer/MainWindow.xaml.cs
@@ -615,24 +615,10 @@ private async Task LoadHDF5File(string productStandard, string fileName, DateTim
{
if (txt != null)
{
- labelStatus.Content = $"Load time: {txt} seconds ..";
+ labelStatus.Content = $"Load time: {txt} seconds. Now rendering file (this can take a while) ..";
progressBar.Value = 0;
}
}), elapsedTime);
-
- BackgroundWorker bgw = new();
- bgw.DoWork += delegate
- {
- Task.Delay(5000).Wait();
- };
- bgw.RunWorkerCompleted += delegate
- {
- _syncContext?.Post(new SendOrPostCallback((o) =>
- {
- labelStatus.Content = "";
- }), "");
- };
- bgw.RunWorkerAsync();
}
}
@@ -994,63 +980,63 @@ private async void CreateFeatureCollection(IS1xxDataPackage dataPackage)
{
if (geoFeature is IVectorFeature vectorGeoFeature)
{
- var secondPoint = Destination((mapPoint.Y, mapPoint.X), 75, vectorGeoFeature.Orientation.OrientationValue);
- double width = 0.75;
+ var secondPoint = Destination((mapPoint.Y, mapPoint.X), 150, vectorGeoFeature.Orientation.OrientationValue);
+ double width = 1.5;
int speedBand = 1;
System.Drawing.Color color = System.Drawing.Color.FromArgb(118, 82, 226);
if (vectorGeoFeature.Speed.SpeedMaximum > 0.5 && vectorGeoFeature.Speed.SpeedMaximum <= 1.0)
{
- secondPoint = Destination((mapPoint.Y, mapPoint.X), 125, vectorGeoFeature.Orientation.OrientationValue);
- width = 1.25;
+ secondPoint = Destination((mapPoint.Y, mapPoint.X), 250, vectorGeoFeature.Orientation.OrientationValue);
+ width = 2.5;
speedBand = 2;
color = System.Drawing.Color.FromArgb(72, 152, 211);
}
else if (vectorGeoFeature.Speed.SpeedMaximum > 1.0 && vectorGeoFeature.Speed.SpeedMaximum <= 2.0)
{
- secondPoint = Destination((mapPoint.Y, mapPoint.X), 150, vectorGeoFeature.Orientation.OrientationValue);
- width = 1.25;
+ secondPoint = Destination((mapPoint.Y, mapPoint.X), 300, vectorGeoFeature.Orientation.OrientationValue);
+ width = 2.5;
speedBand = 3;
color = System.Drawing.Color.FromArgb(97, 203, 229);
}
else if (vectorGeoFeature.Speed.SpeedMaximum > 2.0 && vectorGeoFeature.Speed.SpeedMaximum <= 3.0)
{
- secondPoint = Destination((mapPoint.Y, mapPoint.X), 200, vectorGeoFeature.Orientation.OrientationValue);
- width = 2;
+ secondPoint = Destination((mapPoint.Y, mapPoint.X), 400, vectorGeoFeature.Orientation.OrientationValue);
+ width = 3;
speedBand = 4;
color = System.Drawing.Color.FromArgb(109, 188, 69);
}
else if (vectorGeoFeature.Speed.SpeedMaximum > 3.0 && vectorGeoFeature.Speed.SpeedMaximum <= 5.0)
{
- secondPoint = Destination((mapPoint.Y, mapPoint.X), 250, vectorGeoFeature.Orientation.OrientationValue);
- width = 2;
+ secondPoint = Destination((mapPoint.Y, mapPoint.X), 500, vectorGeoFeature.Orientation.OrientationValue);
+ width = 3;
speedBand = 5;
color = System.Drawing.Color.FromArgb(180, 220, 0);
}
else if (vectorGeoFeature.Speed.SpeedMaximum > 5.0 && vectorGeoFeature.Speed.SpeedMaximum <= 7.0)
{
- secondPoint = Destination((mapPoint.Y, mapPoint.X), 250, vectorGeoFeature.Orientation.OrientationValue);
- width = 2;
+ secondPoint = Destination((mapPoint.Y, mapPoint.X), 500, vectorGeoFeature.Orientation.OrientationValue);
+ width = 4;
speedBand = 6;
color = System.Drawing.Color.FromArgb(205, 193, 0);
}
else if (vectorGeoFeature.Speed.SpeedMaximum > 7.0 && vectorGeoFeature.Speed.SpeedMaximum <= 10.0)
{
- secondPoint = Destination((mapPoint.Y, mapPoint.X), 250, vectorGeoFeature.Orientation.OrientationValue);
- width = 3;
+ secondPoint = Destination((mapPoint.Y, mapPoint.X), 500, vectorGeoFeature.Orientation.OrientationValue);
+ width = 4;
speedBand = 7;
color = System.Drawing.Color.FromArgb(248, 167, 24);
}
else if (vectorGeoFeature.Speed.SpeedMaximum > 10.0 && vectorGeoFeature.Speed.SpeedMaximum <= 13.0)
{
- secondPoint = Destination((mapPoint.Y, mapPoint.X), 250, vectorGeoFeature.Orientation.OrientationValue);
- width = 3;
+ secondPoint = Destination((mapPoint.Y, mapPoint.X), 500, vectorGeoFeature.Orientation.OrientationValue);
+ width = 4;
speedBand = 8;
color = System.Drawing.Color.FromArgb(247, 162, 157);
}
else if (vectorGeoFeature.Speed.SpeedMaximum > 13.0)
{
- secondPoint = Destination((mapPoint.Y, mapPoint.X), 250, vectorGeoFeature.Orientation.OrientationValue);
- width = 4;
+ secondPoint = Destination((mapPoint.Y, mapPoint.X), 500, vectorGeoFeature.Orientation.OrientationValue);
+ width = 5;
speedBand = 9;
color = System.Drawing.Color.FromArgb(255, 30, 30);
}
@@ -1148,6 +1134,11 @@ private async void CreateFeatureCollection(IS1xxDataPackage dataPackage)
myMapView.Map.OperationalLayers.Add(collectionLayer);
myMapView.GraphicsOverlays.Add(graphicsOverlay);
myMapView.GeoViewTapped += OnMapViewTapped;
+
+ _syncContext?.Post(new SendOrPostCallback((o) =>
+ {
+ labelStatus.Content = "";
+ }), "");
}
///