ENC fails to load with error message "Invalid argument" and additional message "ENC resource path does not exist."

368
3
Jump to solution
a month ago
KennSebesta
New Contributor III

Using the CPP version of the AddExchangeSet example, I try to load an ENC which fails at the point of loading the ENCLayer (code snippet below). When I print the `additionalMessage` error, I get "ENC resource path does not exist."

 

 

EncLayer* encLayer = new EncLayer(new EncCell(encDataset, this), this);
connect(encLayer, &EncLayer::doneLoading, this, [encLayer, this](Error e)
{
  if (!e.isEmpty())
  {
    qDebug() << e.message() << ": " << e.additionalMessage();
    return;
  }

  m_mapView->setViewpointGeometry(encLayer->fullExtent());
});

 

 

This same ENC works with the sample given by @LucasDanzinger in https://community.esri.com/t5/arcgis-runtime-sdk-for-qt/trouble-getting-my-widget-to-display-an-enc/... , so it's a known good source.

What is different between these two examples, and what does "ENC resource path does not exist." refer to?

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
KennSebesta
New Contributor III

Answered my own question. The following hardcoded line in the github example points toward an incorrect directory:

 

EncEnvironmentSettings::setResourcePath(defaultDataPath() + "/ArcGIS/Runtime/Data/ENC/hydrography");

 

Presumably, this was once correct in a prior version of the SDK, but as of v100.11 the hydography folder hs moved.

Simply removing the offending line allows the ENC to load correctly. Likewise so does pointing the path in the right direction.

I'm not completely sure what that line is even supposed to do, as it is not commented and when it is correctly pointed to the hydography folder installed with the SDK it doesn't seem to have any immediate impact.

Suggestions:

*) Within the example code, check for the presence of the folder, and return an error.

*) Improve the the example code with a comment which explains what this line does.

*) Most importantly, in the SDK code, print the name of the resource which isn't found. Since the SDK code knows precisely what it was unable to find, it should communicate that to us instead of dropping the file and/or path information. A fundamentally good pattern is that error messages should contain the maximum of information possible and they should not drop time-saving, salient information.

View solution in original post

0 Kudos
3 Replies
KennSebesta
New Contributor III

Answered my own question. The following hardcoded line in the github example points toward an incorrect directory:

 

EncEnvironmentSettings::setResourcePath(defaultDataPath() + "/ArcGIS/Runtime/Data/ENC/hydrography");

 

Presumably, this was once correct in a prior version of the SDK, but as of v100.11 the hydography folder hs moved.

Simply removing the offending line allows the ENC to load correctly. Likewise so does pointing the path in the right direction.

I'm not completely sure what that line is even supposed to do, as it is not commented and when it is correctly pointed to the hydography folder installed with the SDK it doesn't seem to have any immediate impact.

Suggestions:

*) Within the example code, check for the presence of the folder, and return an error.

*) Improve the the example code with a comment which explains what this line does.

*) Most importantly, in the SDK code, print the name of the resource which isn't found. Since the SDK code knows precisely what it was unable to find, it should communicate that to us instead of dropping the file and/or path information. A fundamentally good pattern is that error messages should contain the maximum of information possible and they should not drop time-saving, salient information.

View solution in original post

0 Kudos
LucasDanzinger
Esri Frequent Contributor

Hello,

 

Thanks for the suggestion. Looks like we need to clarify some things in the sample and API. The intention is that samples that require offline data will mention so in the README, such as in this section - https://github.com/Esri/arcgis-runtime-samples-qt/tree/main/ArcGISRuntimeSDKQt_CppSamples/Layers/Add... 

 

I think what it comes down to is that in order to use ENC data, you need to set the path to your hydrography dataset on disk. If you have the SDK installed and you do not explicitly call the setter, the API will try and find it from the SDK install location (https://developers.arcgis.com/qt/cpp/api-reference/esri-arcgisruntime-encenvironmentsettings.html#se...). This is what happens when you comment out the setResourcePath call, hence why things begin to work. However, the sample is also written to be run as a standalone app on a system without the SDK installed, which is why we specify the different path, but I see now how it causes some confusing behavior. 

 

Thanks for the feedback. Glad you got things working

0 Kudos
KennSebesta
New Contributor III

Thanks, that makes perfect sense. I think what tripped me up is not knowing what "good" looked like in the context of that example. An ENC being simply a geo-referenced dataset, it wasn't clear that successfully loading it was going to lead to a visualization. So when I ran the example and nothing happened, I was wondering, "Is this right? Is this wrong?"

In order that others not suffer the same problem, I would strongly suggest that the example includes all files required to run it, esp. a sample ENC dataset. I was really struggling with the program because I didn't even realize things were going wrong, until I found https://community.esri.com/t5/arcgis-runtime-sdk-for-qt/trouble-getting-my-widget-to-display-an-enc/.... This was a canonically good example which included everything required[*] to run and so I was able to get stuff sorted out. 

[*] taking into consideration your comment that the system automatically looks for the hydrology files in the SDK.

0 Kudos