Find symbols within the mil2525d specification that match a keyword.
Use case
You can use support for military symbology to allow users to report changes in the field using the correct military symbols.
How to use the sample
By default, leaving the fields blank and hitting search will find all symbols.
To search for certain symbols, enter text into one or more search boxes and click 'Search for symbols'. Results are shown in a list. Pressing 'Clear' will reset the search.
How it works
- Create a symbol dictionary with the mil2525d specification by passing the string "mil2525d" and the path to a .stylx file to the
SymbolDictionary
constructor. - Create
SymbolStyleSearchParameters
. - Add members to the
names
,tags
,symbolClasses
,categories
, andkeys
list fields of the search parameters. - Search for symbols using the parameters with
DictionarySymbolStyle::searchSymbolsAsync(SymbolStyleSearchParameters)
. - Get the
Symbol
from the list of returnedSymbolStyleSearchResultListModel
s.
Relevant API
- DictionarySymbolStyle
- Symbol
- SymbolStyleSearchParameters
- SymbolStyleSearchResultListModel
Offline Data
Read more about how to set up the sample's offline data here.
Link | Local Location |
---|---|
Mil2525d Stylx File | <userhome> /ArcGIS/Runtime/Data/styles/arcade_style/mil2525d.stylx |
Additional information
This sample features the mil2525D specification. The ArcGIS Maps SDK for Qt supports other military symbology standards, including mil2525C and mil2525B(change 2). See the Military Symbology Styles overview on ArcGIS Solutions for Defense for more information about support for military symbology.
While developing, you can omit the path to the .stylx style file; the ArcGIS Maps SDK for Qt will refer to a copy installed with the SDK. For production, you should take care to deploy the proper style files and explicitly specify the path to that file when creating the symbol dictionary. See the Military Symbology Styles overview on ArcGIS Solutions for Defense for more information about support for military symbology.
Tags
CIM, defense, look up, MIL-STD-2525B, MIL-STD-2525C, MIL-STD-2525D, mil2525b, mil2525c, mil2525d, military, military symbology, search, symbology
Sample Code
// [WriteFile Name=SearchDictionarySymbolStyle, Category=Search]
// [Legal]
// Copyright 2016 Esri.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// [Legal]
#ifdef PCH_BUILD
#include "pch.hpp"
#endif // PCH_BUILD
// sample headers
#include "SearchDictionarySymbolStyle.h"
// ArcGIS Maps SDK headers
#include "DictionarySymbolStyle.h"
#include "SymbolStyleSearchParameters.h"
#include "SymbolStyleSearchResultListModel.h"
// Qt headers
#include <QFuture>
#include <QStandardPaths>
#include <QtCore/qglobal.h>
using namespace Esri::ArcGISRuntime;
// helper method to get cross platform data path
namespace
{
QString defaultDataPath()
{
QString dataPath;
#ifdef Q_OS_IOS
dataPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
#else
dataPath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
#endif
return dataPath;
}
} // namespace
using namespace Esri::ArcGISRuntime;
SearchDictionarySymbolStyle::SearchDictionarySymbolStyle(QQuickItem* parent) :
QQuickItem(parent)
{
}
SearchDictionarySymbolStyle::~SearchDictionarySymbolStyle() = default;
void SearchDictionarySymbolStyle::init()
{
qmlRegisterType<SearchDictionarySymbolStyle>("Esri.Samples", 1, 0, "SearchDictionarySymbolStyleSample");
qmlRegisterUncreatableType<QAbstractListModel>("Esri.Samples", 1, 0, "AbstractListModel", "AbstractListModel is uncreateable");
}
void SearchDictionarySymbolStyle::componentComplete()
{
QQuickItem::componentComplete();
//Get the data path
QString datapath = defaultDataPath() + "/ArcGIS/Runtime/Data/styles/arcade_style/mil2525d.stylx";
//Create the dictionary from datapath (added since 100.6)
m_dictionarySymbolStyle = DictionarySymbolStyle::createFromFile(datapath, this);
}
QAbstractListModel* SearchDictionarySymbolStyle::searchResultsListModel() const
{
return m_searchResults;
}
void SearchDictionarySymbolStyle::search(const QStringList& namesSearchParam, const QStringList& tagsSearchParam,
const QStringList& classesSearchParam,const QStringList& categoriesSearchParam,
const QStringList& keysSearchParam)
{
//Create search parameters and search with the parameters
SymbolStyleSearchParameters searchParameters;
searchParameters.setCategories(categoriesSearchParam);
searchParameters.setKeys(keysSearchParam);
searchParameters.setNames(namesSearchParam);
searchParameters.setSymbolClasses(classesSearchParam);
searchParameters.setTags(tagsSearchParam);
m_dictionarySymbolStyle->searchSymbolsAsync(searchParameters).then(this, [this](SymbolStyleSearchResultListModel* results)
{
m_searchResults = results;
emit searchResultsListModelChanged();
emit searchCompleted(results->size());
});
}