Closed AbelHeinsbroek closed 4 months ago
One possible improvement would be to send an array with indices and only returning the requested node/link indices, or, if an empty array is passed, return all values for all indices.
@AbelHeinsbroek can you please resolve the conflicts so we can merge your contribution into dev.
There is a problem, as noted by compiler warnings, with the newly added functions ENgetnodevalues
and ENgetlinkvalues
for the legacy API. The code for ENgetnodevalues
in epanet2.c is:
int DLLEXPORT ENgetnodevalues(int property, EN_API_FLOAT_TYPE *values)
{
return EN_getnodevalues(_defaultProject, property, values);
}
whereEN_API_FLOAT_TYPE
is defined as a 4-byte float. However the EN_getnodevalues
function being called expects to see a pointer to an 8-byte double as the type for its values
argument. As a result some type of memory corruption will occur. The fix is to rewrite ENgetnodevalues
as:
int DLLEXPORT ENgetnodevalues(int property, EN_API_FLOAT_TYPE *values)
{
int i, errcode = 0;
EN_API_FLOAT_TYPE value;
for (i = 1; i <= _defaultProject->network.Nnodes; i++)
{
errcode = ENgetnodevalue(i, property, &value);
values[i-1] = value;
if (errcode != 0) return errcode;
}
return 0;
}
The same problem and fix applies to ENgetlinkvalues
.
Adds methods for batch requesting node and link property values, see #785 for details.