Hi,
I'm facing this problem.. i have my ENC charts in this path /storage/emulated/0/Android/data/com.example.enc_pt/cache/charts/VE300600/ENC_ROOT. When i'm trying to loading it, i got this error: Error loading ENC layer: Invalid argument.
In the image you can see i got bot files .000 and .031.
This how i load it:
Any help would be appreciate.
Maria.
private void loadEncExchangeSet(List<String> folders) {
Log.d("EncLoader", "Loading folders into ENC Exchange Set...");
/*for (String folder : folders) {
Log.d("EncLoader", "→ " + folder);
}*/
String pa = "/storage/emulated/0/Android/data/com.example.enc_pt/cache/charts/VE300600/ENC_ROOT/CATALOG.031";
List<String> p = Collections.singletonList(pa);
//mEncExchangeSet = new EncExchangeSet(folders);
mEncExchangeSet = new EncExchangeSet(p);
mEncExchangeSet.loadAsync();
mEncExchangeSet.addDoneLoadingListener(() -> {
if (mEncExchangeSet.getLoadStatus() == LoadStatus.LOADED) {
// add each data set's Enc cell as an ENC layer
for (EncDataset encDataset : mEncExchangeSet.getDatasets()) {
// create an ENC layer with an ENC cell using the dataset
EncLayer encLayer = new EncLayer(new EncCell(encDataset));
// add the ENC layer to the map's operational layers
mMapView.getMap().getOperationalLayers().add(encLayer);
encLayer.addDoneLoadingListener(() -> {
if (encLayer.getLoadStatus() == LoadStatus.LOADED) {
Envelope extent = encLayer.getFullExtent();
// combine extents of each layer
if (mCompleteExtent == null) {
mCompleteExtent = extent;
} else {
mCompleteExtent = GeometryEngine.combineExtents(Arrays.asList(mCompleteExtent, extent));
}
// set the view point to the extent of all enc layers
mMapView.setViewpointAsync(new Viewpoint(mCompleteExtent));
} else {
Log.d("EncLoader", "Error loading ENC layer: " + encLayer.getLoadError().getMessage());
}
});
}
} else {
String error = "Error loading ENC exchange set: " + mEncExchangeSet.getLoadError().getMessage();
Toast.makeText(this, error, Toast.LENGTH_LONG).show();
Log.e(TAG, error);
}
});
}
Hey @MaríaBencomo
Would it be because you're referencing the file directly? You may need to put this:
String pa = "/storage/emulated/0/Android/data/com.example.enc_pt/cache/charts/VE300600/ENC_ROOT";
To my knowledge it would be directory access rather than direct file access, but I would also make sure that you have correct permissions to access the folder.
Cody
Hi Maria!
Let me start by strongly encouraging you to consider moving to 200.X. It's a Kotlin first API which much better integration to modern Android.
That said, here's a few things to consider.
1. Have you handled permissions to read local data? Meaning this line in your Manifest and the supporting code to ask the user at runtime?
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
2. Can you start building your path with
getExternalFilesDir(null)
and then build the rest of your path from there?
3. Have you added the supporting hydrography data to the local device and set the resource path shown here? And have you set the SencDataPath?
If you'd like to consider an upgrade to 200.X, we've got a current sample that will show you how to Add an ENC exchange set.
Thanks!
Trevor