Hi all,
Recently been attempting to set the location-based base_data during model generation using the C# library. Currently on version 2.14.11 to version match with RFEM 6 6.14.0011. I am able to successfully set the string-based location data such as Country/Street/Zip/City, but whenever I try to set latitude/longitude/altitude using the API it fails to do so. All the values show up as 0.000 instead of the desired value.
I thought maybe it would require just the latitude & longitude, and everything else blank which would then lead to the other fields being auto-populated, but this wasn't the case either. I tried setting it before model generation, after model generation, and also in multiple phases but with no luck. I can only assume that currently the API has a limitation when it comes to setting the lat/long, or I've missed a method that is required to ensure it calculates.
Any help or pointers would be greatly appreciated!
Thank you!
Hi JamesSolar,
it seems that we have an issue here (Bug ID=700241). The dev team is informed, I guess this will be fixed within the next versions.
Happy coding.
Best regards
Robert Milrath
Hi James,
Latitude and longitude need to be provided in radians, not degrees.
The following example demonstrates setting the location data:
using Rfem = Dlubal.Api.Rfem;
using Common = Dlubal.Api.Common;
ApplicationRfem? rfemApp = null;
try
{
rfemApp = new ApplicationRfem();
var appInfo = rfemApp.get_application_info();
Console.WriteLine(appInfo);
// Create a new model
Common.ModelId modelId = rfemApp.create_model("model_base_data");
Console.WriteLine($"Created model: {modelId.Guid}");
// Get the model's base data
Rfem.BaseData baseData = rfemApp.get_base_data();
// Make sure the location container exists before writing to it
baseData.Location ??= new Rfem.BaseData.Types.Location();
// Set the geographic location.
// Altitude is specified in meters.
// Latitude and longitude are specified in radians.
baseData.Location.Altitude = 300.0;
baseData.Location.Latitude = DegreesToRadians(49.4521);
baseData.Location.Longitude = DegreesToRadians(11.0767);
baseData.Location.TownCity = "Leipzig";
// Transfer the modified base data back to the model
rfemApp.set_base_data(baseData);
Console.WriteLine(
$"Base data set - altitude: {baseData.Location.Altitude} m, " +
$"latitude: {baseData.Location.Latitude} rad, " +
$"longitude: {baseData.Location.Longitude} rad");
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
finally
{
rfemApp?.close_connection();
}
static double DegreesToRadians(double degrees)
{
return degrees * Math.PI / 180.0;
}
Regards
Thanks sincerely for your response, Tomas.
Got it working successfully with your help!