AnsweredAssumed Answered

[Solved] How to get reasonable performance using ENC Layers

Question asked by TMPTMP on Nov 28, 2018
Latest reply on Nov 30, 2018 by LDanzinger-esristaff

I managed to get ENC layers working by starting from the default new C++ project and modifying as below. It works, which is great! However, as soon as the layers load, scrolling becomes impossible. I can't tell if it's slowing to a crawl or there's something about the layer interfering with the scroll but it kind of looks like it's a CPU issue. I'm using a 2018 Macbook Air, so machine performance should not be the bottleneck.

 

The SENC files seem to already be generated, and the data set is a rather small view of Providence and/or Boston harbor.

 

What's going on here and how do we fix it?

 

==========================

P.S. If anyone else is trying to get ENC working, here are the full working code sets.

 

C++ file:

// Copyright 2016 ESRI
//
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
//
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
//
// See the Sample code usage restrictions document for further information.
//

// C++ API headers
#include "Basemap.h"

// Other headers
#include "ArcGIS_QtWidgets.h"

#include "Map.h"
#include "MapGraphicsView.h"

#include "EncExchangeSet.h"
#include "EncLayer.h"
#include "EncFeature.h"
#include "EncCell.h"
#include "EncTextGroupVisibilitySettings.h"
#include "EncEnvironmentSettings.h"

using namespace Esri::ArcGISRuntime;

ArcGIS_QtWidgets::ArcGIS_QtWidgets(QWidget* parent /*=nullptr*/):
    QMainWindow(parent)
{
    // get EncDisplaySettings instance
    EncDisplaySettings* displaySettings = EncEnvironmentSettings::displaySettings();

    // set paths
    EncEnvironmentSettings::setSencDataPath("/Users/tmptmp/Documents/Charts/SENC");
    EncEnvironmentSettings::setResourcePath("/Users/tmptmp/Documents/Charts/hydrography");

    // create EncExchangeSet using paths
    encExchangeSet = new EncExchangeSet(QStringList(QStringList() << "/Users/tmptmp/Documents/Charts/ENC_ROOT_Boston_Harbor/CATALOG.031" << "/Users/tmptmp/Documents/Charts/ENC/US_REGION02/CATALOG.031"), this);

    connect(encExchangeSet, &EncExchangeSet::doneLoading, this, [this]{

        // get the list of EncDataset
        QList<EncDataset*> EncDatasets = encExchangeSet->datasets();

        // display the names of EncDataset
        for (EncDataset* EncDataset: EncDatasets)
        {

            // Create the cell and layer
            auto myEncLayer = new EncLayer(new EncCell(EncDataset));

            // Add the layer to the map
            m_map->operationalLayers()->append(myEncLayer);
            qDebug()<< "Loaded map: " << EncDataset->name();

        }

        qDebug()<< "Loaded all maps";
    });

    // Load the EncExchangeSet
    encExchangeSet->load();

    // get ENC text group visibility settings object
    EncTextGroupVisibilitySettings* encTextGroupVisibilitySettings = EncEnvironmentSettings::displaySettings()->textGroupVisibilitySettings();

    // set properties
    encTextGroupVisibilitySettings->setImportantText(false);
    encTextGroupVisibilitySettings->setNatureOfSeabed(false);

    // Create the Widget view
    m_mapView = new MapGraphicsView(this);

    connect(m_mapView, &MapGraphicsView::mousePressedAndHeld, this, [this](QMouseEvent& mouseEvent)
    {
        qDebug()<< "Mouse pressed";

      double tolerance = 5.0;
      bool returnPopupsOnly = false;
      int maximumResults = 5;
      m_mapView->identifyLayers(mouseEvent.x(), mouseEvent.y(), tolerance, returnPopupsOnly, maximumResults);
    });


    connect(m_mapView, &MapGraphicsView::identifyLayersCompleted, this, [](QUuid taskId, QList<Esri::ArcGISRuntime::IdentifyLayerResult*> identifyResults)
    {
      Q_UNUSED(taskId);
      for (int i = 0; i < identifyResults.size(); i++)
      {
        EncLayer* encLayer = dynamic_cast<EncLayer*>(identifyResults.at(i)->layerContent());
        if (encLayer)
        {
          qDebug() << "EncFeatures identified in EncLayer #" << i << ":";
          QList<GeoElement*>objects = identifyResults.at(i)->geoElements();
          for (int j = 0; j < objects.size(); j++)
          {
            EncFeature* encFeature = dynamic_cast<EncFeature*>(objects.at(j));
            if (encFeature)
            {
              qDebug() << "Found EncFeature: " << encFeature->description();
              QVariantMap map = encFeature->attributes()->attributesMap();
              qDebug() << " - Attributes: " << map;
            }
          }
        }
      }
    });

    // Create a map using the navigationVector Basemap
    m_map = new Map(Basemap::oceans(this), this);

    // Set map to map view
    m_mapView->setMap(m_map);

    // set the mapView as the central widget
    setCentralWidget(m_mapView);
}

// destructor
ArcGIS_QtWidgets::~ArcGIS_QtWidgets()
{
}

 

Header file:

// Copyright 2016 ESRI
//
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
//
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
//
// See the Sample code usage restrictions document for further information.
//

#ifndef ARCGIS_QTWIDGETS_H
#define ARCGIS_QTWIDGETS_H

namespace Esri
{
namespace ArcGISRuntime
{
class Map;
class MapGraphicsView;
}
}

#include <QMainWindow>

#include "EncExchangeSet.h"

class ArcGIS_QtWidgets : public QMainWindow
{
    Q_OBJECT
public:
    ArcGIS_QtWidgets(QWidget* parent = nullptr);
    ~ArcGIS_QtWidgets();

public slots:

private:
    Esri::ArcGISRuntime::EncExchangeSet*        encExchangeSet = nullptr;
    Esri::ArcGISRuntime::Map*                   m_map = nullptr;
    Esri::ArcGISRuntime::MapGraphicsView*       m_mapView = nullptr;
};

#endif // ARCGIS_QTWIDGETS_H

Outcomes