Skip to content

Commit

Permalink
[Photometry] fixed parsing of integers that might have decimal points…
Browse files Browse the repository at this point in the history
… (local vs invariant number format)
  • Loading branch information
luithefirst committed Dec 2, 2024
1 parent ee455ab commit 66ff97a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
3 changes: 3 additions & 0 deletions src/Aardvark.Data.Photometry/IESParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public static IESData Parse(String filePath)
}
}

/// <summary>
/// Read everything expect the luminous intensity distribution values.
/// </summary>
public IESData ParseMeta(String filePath)
{
using (var stream = new FileStream(filePath, FileMode.Open))
Expand Down
6 changes: 5 additions & 1 deletion src/Aardvark.Data.Photometry/LDTData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public enum LDTItype

/// <summary>
/// Holds the data represented in an EULUMDATA luminaire data file
/// http://www.helios32.com/Eulumdat.htm
/// https://docs.agi32.com/PhotometricToolbox/Content/Open_Tool/eulumdat_file_format.htm
/// https://paulbourke.net/dataformats/ldt/
/// </summary>
public class LDTData
{
Expand All @@ -90,6 +91,9 @@ public static LDTData FromString(string data)
return FromStream(stream);
}

/// <summary>
/// Read everything expect the luminous intensity distribution values.
/// </summary>
public static LDTData ParseMeta(string filename)
{
return new LDTParser().ParseMeta(filename);
Expand Down
18 changes: 9 additions & 9 deletions src/Aardvark.Data.Photometry/LDTParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ private LDTData ReadMeta(StreamReader sr)
// 11-15
ldt.FileName = sr.ReadLine();
ldt.DateUser = sr.ReadLine();
ldt.LengthLuminaire = ReadIntLine(sr);
ldt.WidthLuminaire = ReadIntLine(sr);
ldt.HeightLuminare = ReadIntLine(sr);
ldt.LengthLuminaire = (int)ReadDoubleLine(sr); // NOTE: allow decimal value, but take integer
ldt.WidthLuminaire = (int)ReadDoubleLine(sr); // NOTE: allow decimal points, but take integer
ldt.HeightLuminare = (int)ReadDoubleLine(sr); // NOTE: allow decimal points, but take integer
// 16-20
ldt.LengthLuminousArea = ReadIntLine(sr);
ldt.WidthLuminousArea = ReadIntLine(sr);
ldt.HeightLuminousAreaC0 = ReadIntLine(sr);
ldt.HeightLuminousAreaC90 = ReadIntLine(sr);
ldt.HeightLuminousAreaC180 = ReadIntLine(sr);
ldt.LengthLuminousArea = (int)ReadDoubleLine(sr); // NOTE: allow decimal points, but take integer
ldt.WidthLuminousArea = (int)ReadDoubleLine(sr); // NOTE: allow decimal points, but take integer
ldt.HeightLuminousAreaC0 = (int)ReadDoubleLine(sr); // NOTE: allow decimal points, but take integer
ldt.HeightLuminousAreaC90 = (int)ReadDoubleLine(sr); // NOTE: allow decimal points, but take integer
ldt.HeightLuminousAreaC180 = (int)ReadDoubleLine(sr); // NOTE: allow decimal points, but take integer
// 21-25
ldt.HeightLuminousAreaC270 = ReadIntLine(sr);
ldt.HeightLuminousAreaC270 = (int)ReadDoubleLine(sr); // NOTE: allow decimal points, but take integer
ldt.DownwardFluxFraction = ReadDoubleLine(sr);
ldt.LightOutputRatioLuminaire = ReadDoubleLine(sr);
ldt.ConversionIntensity = ReadDoubleLine(sr);
Expand Down
3 changes: 3 additions & 0 deletions src/Aardvark.Data.Photometry/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 5.3.11
- Improved robustness of parsing attributes that might have decimal points

### 5.3.10
- Updated to NET 8 and Aardvark.Base 5.3
- Fixed BuildEquidistantMatrix in case there is full 360° measurement data (#4855)
Expand Down
2 changes: 1 addition & 1 deletion src/Aardvark.Data.Photometry/TextParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected static double ParseDouble(String s)

protected static int ParseInt(String s)
{
return (int)Decimal.Parse(s); // NOTE use decimal parsing to not crash with floating point values (could report warning)
return int.Parse(s);
}

protected String[] StringSplit(String s)
Expand Down

0 comments on commit 66ff97a

Please sign in to comment.