new_docker_build.sh gains Group 12 (212 GUI/Data plugins); fixes LtsUtilsGuiDds visibility (LTO-stripped exports), LtsProjectionWorkstation unity name shadow, 6 unity-off dirs (dup file-scope statics, ddsftc INTERFACE sources) and reconfigures BUILD_FILTERMANAGEMENT/BUILD_PLUGINS_SERVICEMONITOR=ON
377 lines
12 KiB
C++
Executable File
377 lines
12 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* Portal
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Norbert Thoden, NLSE, 2018-10-08
|
|
*/
|
|
|
|
|
|
// Own
|
|
#include "portal.h"
|
|
//#include <Map/situation_map_utils.h>
|
|
|
|
|
|
// Esri
|
|
#include <Portal.h>
|
|
#include <PortalItem.h>
|
|
#include <Item.h> // 300: PortalItem::name() is on the Item base
|
|
#include <PortalGroup.h>
|
|
#include <PortalItemListModel.h>
|
|
#include <PortalGroupListModel.h>
|
|
#include <BasemapListModel.h>
|
|
#include <Basemap.h>
|
|
#include <LayerListModel.h>
|
|
#include <Layer.h>
|
|
#include <PortalQueryParametersForItems.h>
|
|
#include <PortalQueryParametersForGroups.h>
|
|
#include <PortalQueryResultSetForItems.h>
|
|
#include <PortalQueryResultSetForGroups.h>
|
|
#include <Error.h>
|
|
#include <MapTypes.h> // 300: defines the LoadStatus enum (only fwd-declared in Portal.h)
|
|
|
|
// Qt
|
|
#include <QUrl>
|
|
#include <QFuture>
|
|
#include <QFutureWatcher>
|
|
|
|
|
|
namespace Esri
|
|
{
|
|
namespace ArcGISRuntime
|
|
{
|
|
|
|
QString toString(const Error &value)
|
|
{
|
|
std::ostringstream stream;
|
|
stream << "Esri::ArcGISRuntime::Error: "
|
|
<< " code=" << value.arcGISServerErrorCode().value_or(0) // 300: code() removed
|
|
<< ", domain=" << (int)value.domain()
|
|
<< ", extendedErrorType=" << (int)value.extendedErrorType()
|
|
<< ", message='" << value.message().toStdString() << "'"
|
|
<< ", additionalMessage='" << value.additionalMessage().toStdString() << "'";
|
|
return QString::fromStdString(stream.str());
|
|
}
|
|
|
|
std::ostream &operator<< (std::ostream &stream,
|
|
const Esri::ArcGISRuntime::Error &value)
|
|
{
|
|
stream << toString(value);
|
|
return stream;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
namespace SituationMap
|
|
{
|
|
|
|
|
|
|
|
|
|
class Portal::Private
|
|
{
|
|
public:
|
|
Private() = default;
|
|
~Private() = default;
|
|
|
|
|
|
Esri::ArcGISRuntime::Portal *m_portal = nullptr;
|
|
// QTimer *m_suppressTimer = nullptr;
|
|
|
|
// 300: the Portal "changed" signals (basemapsChanged/featuredGroupsChanged/
|
|
// featuredItemsChanged) and findItemsCompleted/findGroupsCompleted were removed; the
|
|
// equivalent fetch*Async()/find*Async() QFutures are watched to fire the same logging
|
|
// slots the old signals did. The watchers are parented to the Portal QObject.
|
|
QFutureWatcher<void> *m_basemapsWatcher = nullptr;
|
|
QFutureWatcher<void> *m_featuredGroupsWatcher = nullptr;
|
|
QFutureWatcher<void> *m_featuredItemsWatcher = nullptr;
|
|
QFutureWatcher<Esri::ArcGISRuntime::PortalQueryResultSetForItems*> *m_findItemsWatcher = nullptr;
|
|
QFutureWatcher<Esri::ArcGISRuntime::PortalQueryResultSetForGroups*> *m_findGroupsWatcher = nullptr;
|
|
|
|
}; // class Portal::Private
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
Portal::Portal(QObject *parent)
|
|
: BaseClass(parent)
|
|
, d(new Private)
|
|
, m_logger(getLogger("Portal"))
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
|
|
Portal::~Portal()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
delete d;
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
bool Portal::init()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
delete d->m_portal;
|
|
|
|
QUrl portalUrl(QStringLiteral("http://excgeo20.sl.defence-elec.de/arcgis")); // http://excgeo20.sl.defence-elec.de/arcgis/
|
|
// 300: Esri::ArcGISRuntime::Credential removed (replaced by the Authentication framework);
|
|
// it was only referenced by the commented-out ctor below, so the unused credential is dropped.
|
|
d->m_portal = new Esri::ArcGISRuntime::Portal(portalUrl, false);
|
|
// d->m_portal = new Esri::ArcGISRuntime::Portal(portalUrl, &credential);
|
|
|
|
// 300: Portal::errorOccurred signal removed -> load errors arrive via doneLoading(Error).
|
|
connect(d->m_portal, &Esri::ArcGISRuntime::Portal::doneLoading, this, &Portal::onPortalDoneLoading);
|
|
|
|
// 300: basemapsChanged/featuredGroupsChanged/featuredItemsChanged/homepageFeaturedContentChanged
|
|
// signals removed -> the equivalent QFutureWatchers are set up in fetchData().
|
|
|
|
d->m_portal->load();
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
return true;
|
|
}
|
|
|
|
bool Portal::fetchData()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
|
|
if (!d->m_portal || d->m_portal->loadStatus() != Esri::ArcGISRuntime::LoadStatus::Loaded)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " not loaded yet";
|
|
return false;
|
|
}
|
|
|
|
// 300: fetchBasemaps()/fetchFeaturedGroups()/fetchFeaturedItems() removed -> fetch*Async()
|
|
// return QFuture<void>; watch them to fire the same slots the old *Changed signals fired.
|
|
d->m_basemapsWatcher = new QFutureWatcher<void>(this);
|
|
connect(d->m_basemapsWatcher, &QFutureWatcher<void>::finished,
|
|
this, [this](){ onBasemapsChanged(); });
|
|
d->m_basemapsWatcher->setFuture(d->m_portal->fetchBasemapsAsync());
|
|
|
|
d->m_featuredGroupsWatcher = new QFutureWatcher<void>(this);
|
|
connect(d->m_featuredGroupsWatcher, &QFutureWatcher<void>::finished,
|
|
this, [this](){ onFeaturedGroupsChanged(); });
|
|
d->m_featuredGroupsWatcher->setFuture(d->m_portal->fetchFeaturedGroupsAsync());
|
|
|
|
d->m_featuredItemsWatcher = new QFutureWatcher<void>(this);
|
|
connect(d->m_featuredItemsWatcher, &QFutureWatcher<void>::finished,
|
|
this, [this](){ onFeaturedItemsChanged(); });
|
|
d->m_featuredItemsWatcher->setFuture(d->m_portal->fetchFeaturedItemsAsync());
|
|
|
|
// 300: fetchHomepageFeaturedContent()/homepageFeaturedContent() removed.
|
|
|
|
|
|
// findItems :
|
|
Esri::ArcGISRuntime::PortalQueryParametersForItems query;
|
|
query.setSearchString(QLatin1String("1==1"));
|
|
// query.setTypes(QList<PortalItemType>() << PortalItemType::WebMap);
|
|
|
|
// 300: findItems() + findItemsCompleted signal removed -> findItemsAsync() returns
|
|
// QFuture; watch it to fire onFindItemsCompleted with the result.
|
|
d->m_findItemsWatcher = new QFutureWatcher<Esri::ArcGISRuntime::PortalQueryResultSetForItems*>(this);
|
|
connect(d->m_findItemsWatcher,
|
|
&QFutureWatcher<Esri::ArcGISRuntime::PortalQueryResultSetForItems*>::finished,
|
|
this, [this](){ onFindItemsCompleted(d->m_findItemsWatcher->result()); });
|
|
d->m_findItemsWatcher->setFuture(d->m_portal->findItemsAsync(query));
|
|
|
|
|
|
// findGroups
|
|
QString groupsQuery(QLatin1String("1==1"));
|
|
Esri::ArcGISRuntime::PortalQueryParametersForGroups findGroupsQueryParameters(groupsQuery);
|
|
|
|
d->m_findGroupsWatcher = new QFutureWatcher<Esri::ArcGISRuntime::PortalQueryResultSetForGroups*>(this);
|
|
connect(d->m_findGroupsWatcher,
|
|
&QFutureWatcher<Esri::ArcGISRuntime::PortalQueryResultSetForGroups*>::finished,
|
|
this, [this](){ onFindGroupsCompleted(d->m_findGroupsWatcher->result()); });
|
|
d->m_findGroupsWatcher->setFuture(d->m_portal->findGroupsAsync(findGroupsQueryParameters));
|
|
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
return true;
|
|
}
|
|
|
|
|
|
void Portal::onPortalErrorOccurred(const Esri::ArcGISRuntime::Error &error)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Portal -> EsriError occured: " << error;
|
|
}
|
|
|
|
void Portal::onPortalDoneLoading(const Esri::ArcGISRuntime::Error &loadError)
|
|
{
|
|
if (loadError.isEmpty())
|
|
{
|
|
NOTICE_LOG(m_logger) << LOGFUNCTION << " Portal loaded";
|
|
fetchData();
|
|
} else {
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " Portal -> EsriError occured: " << loadError;
|
|
}
|
|
}
|
|
|
|
void Portal::onBasemapsChanged()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
NOTICE_LOG(m_logger) << LOGFUNCTION << " ***** fired";
|
|
|
|
Esri::ArcGISRuntime::BasemapListModel *model = d->m_portal->basemaps();
|
|
if (!model)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " model does not exits";
|
|
return;
|
|
}
|
|
|
|
for (int i=0; i<model->size(); ++i)
|
|
{
|
|
Esri::ArcGISRuntime::Basemap *item = model->at(i);
|
|
if (!item)
|
|
{
|
|
WARNING_LOG(m_logger) << LOGFUNCTION << " item is empty";
|
|
continue;
|
|
}
|
|
NOTICE_LOG(m_logger) << LOGFUNCTION
|
|
<< " i=" << i
|
|
<< " name = '" << item->name() << "'"
|
|
<< " url = '" << item->url().toString() << "'";
|
|
|
|
Esri::ArcGISRuntime::LayerListModel *llm = item->baseLayers();
|
|
if (!llm)
|
|
{
|
|
WARNING_LOG(m_logger) << LOGFUNCTION << " llm is empty";
|
|
continue;
|
|
}
|
|
for (int j=0; i<llm->size(); ++j)
|
|
{
|
|
Esri::ArcGISRuntime::Layer *layer = llm->at(j);
|
|
if (!layer)
|
|
{
|
|
WARNING_LOG(m_logger) << LOGFUNCTION << " layer is empty";
|
|
continue;
|
|
}
|
|
NOTICE_LOG(m_logger) << LOGFUNCTION
|
|
<< " j=" << j
|
|
<< " layer = '" << layer->name() << "'"
|
|
<< " layerType = '" << (int)layer->layerType();
|
|
} // for
|
|
|
|
} // for
|
|
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
void Portal::onFeaturedGroupsChanged()
|
|
{
|
|
NOTICE_LOG(m_logger) << LOGFUNCTION << " ***** fired";
|
|
|
|
Esri::ArcGISRuntime::PortalGroupListModel *model = d->m_portal->featuredGroups();
|
|
if (!model)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " model does not exits";
|
|
return;
|
|
}
|
|
|
|
for (int i=0; i<model->size(); ++i)
|
|
{
|
|
Esri::ArcGISRuntime::PortalGroup *item = model->at(i);
|
|
if (!item)
|
|
{
|
|
WARNING_LOG(m_logger) << LOGFUNCTION << " item is empty";
|
|
continue;
|
|
}
|
|
NOTICE_LOG(m_logger) << LOGFUNCTION
|
|
<< " i=" << i
|
|
<< " title = '" << item->title() << "'"
|
|
// << " url = '" << item->url().toString() << "'"
|
|
;
|
|
} // for
|
|
|
|
}
|
|
void Portal::onFeaturedItemsChanged()
|
|
{
|
|
NOTICE_LOG(m_logger) << LOGFUNCTION << " ***** fired";
|
|
|
|
Esri::ArcGISRuntime::PortalItemListModel *model = d->m_portal->featuredItems();
|
|
if (!model)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " model does not exits";
|
|
return;
|
|
}
|
|
|
|
for (int i=0; i<model->size(); ++i)
|
|
{
|
|
Esri::ArcGISRuntime::PortalItem *item = model->at(i);
|
|
if (!item)
|
|
{
|
|
WARNING_LOG(m_logger) << LOGFUNCTION << " item is empty";
|
|
continue;
|
|
}
|
|
NOTICE_LOG(m_logger) << LOGFUNCTION
|
|
<< " i=" << i
|
|
<< " name = '" << item->name() << "'"
|
|
<< " serviceUrl = '" << item->serviceUrl().toString() << "'";
|
|
} // for
|
|
}
|
|
void Portal::onHomepageFeatureContentChanged()
|
|
{
|
|
NOTICE_LOG(m_logger) << LOGFUNCTION << " ***** fired";
|
|
// 300: Portal::homepageFeaturedContent()/fetchHomepageFeaturedContent() removed; nothing to log.
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " (homepage featured content no longer available in ArcGIS 300)";
|
|
}
|
|
|
|
void Portal::onFindItemsCompleted(Esri::ArcGISRuntime::PortalQueryResultSetForItems *result)
|
|
{
|
|
NOTICE_LOG(m_logger) << LOGFUNCTION << " ***** fired";
|
|
Esri::ArcGISRuntime::PortalItemListModel *model = result->itemResults();
|
|
if (!model)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " model does not exits";
|
|
return;
|
|
}
|
|
|
|
for (int i=0; i<model->size(); ++i)
|
|
{
|
|
Esri::ArcGISRuntime::PortalItem *item = model->at(i);
|
|
if (!item)
|
|
{
|
|
WARNING_LOG(m_logger) << LOGFUNCTION << " item is empty";
|
|
continue;
|
|
}
|
|
NOTICE_LOG(m_logger) << LOGFUNCTION
|
|
<< " i=" << i
|
|
<< " name = '" << item->name() << "'"
|
|
<< " serviceUrl = '" << item->serviceUrl().toString() << "'";
|
|
} // for
|
|
}
|
|
|
|
void Portal::onFindGroupsCompleted(Esri::ArcGISRuntime::PortalQueryResultSetForGroups *result)
|
|
{
|
|
NOTICE_LOG(m_logger) << LOGFUNCTION << " ***** fired";
|
|
Esri::ArcGISRuntime::PortalGroupListModel *model = result->groupResults();
|
|
if (!model)
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION << " model does not exits";
|
|
return;
|
|
}
|
|
|
|
for (int i=0; i<model->size(); ++i)
|
|
{
|
|
Esri::ArcGISRuntime::PortalGroup *item = model->at(i);
|
|
if (!item)
|
|
{
|
|
WARNING_LOG(m_logger) << LOGFUNCTION << " item is empty";
|
|
continue;
|
|
}
|
|
NOTICE_LOG(m_logger) << LOGFUNCTION
|
|
<< " i=" << i
|
|
<< " title = '" << item->title() << "'"
|
|
// << " toJson() = '" << item->toJson() << "'"
|
|
;
|
|
} // for
|
|
}
|
|
|
|
} // namespace SituationMap
|