27 #include "../../../color/ColorBar.h" 28 #include "../../../common/Globals.h" 29 #include "../../../common/STLUtils.h" 30 #include "../../../dataaccess/datasource/DataSource.h" 31 #include "../../../dataaccess/query/SQLVisitor.h" 32 #include "../../../dataaccess/dataset/DataSet.h" 33 #include "../../../dataaccess/dataset/DataSetType.h" 34 #include "../../../dataaccess/query/OrderByItem.h" 35 #include "../../../dataaccess/utils/Utils.h" 36 #include "../../../fe/Filter.h" 37 #include "../../../fe/Utils.h" 38 #include "../../../geometry/GeometryProperty.h" 39 #include "../../../maptools/Enums.h" 40 #include "../../../maptools/GroupingAlgorithms.h" 41 #include "../../../maptools/Grouping.h" 42 #include "../../../maptools/Utils.h" 43 #include "../../../maptools/QueryEncoder.h" 44 #include "../../../maptools/QueryLayer.h" 45 #include "../../../se.h" 46 #include "../../../se/Symbolizer.h" 47 #include "../../../se/SymbolizerColorFinder.h" 48 #include "../../../se/Style.h" 49 #include "../../../se/Utils.h" 50 #include "../colorbar/ColorBar.h" 51 #include "../colorbar/ColorCatalogWidget.h" 52 #include "../se/LineSymbolizerWidget.h" 53 #include "../se/PointSymbolizerWidget.h" 54 #include "../se/PolygonSymbolizerWidget.h" 55 #include "../se/SymbologyPreview.h" 57 #include "ui_GroupingWidgetForm.h" 63 #include <QDialogButtonBox> 64 #include <QMessageBox> 65 #include <QFileDialog> 69 #include <boost/algorithm/string.hpp> 70 #include <boost/filesystem.hpp> 71 #include <boost/lexical_cast.hpp> 72 #include <boost/property_tree/json_parser.hpp> 74 #define MAX_SLICES 200 76 #define NO_TITLE "No Value" 104 m_ui(new
Ui::GroupingWidgetForm),
109 QGridLayout* l =
new QGridLayout(
m_ui->m_colorBarWidget);
110 l->setContentsMargins(0,0,0,0);
138 if (
m_ui->m_importGroupBox->isChecked())
140 QVariant varLayer =
m_ui->m_layersComboBox->itemData(
m_ui->m_layersComboBox->currentIndex(), Qt::UserRole);
150 std::string attr =
m_ui->m_attrComboBox->currentText().toUtf8().data();
151 int attrIdx =
m_ui->m_attrComboBox->currentIndex();
152 int attrType =
m_ui->m_attrComboBox->itemData(attrIdx).toInt();
154 int index =
m_ui->m_typeComboBox->currentIndex();
155 int type =
m_ui->m_typeComboBox->itemData(index).toInt();
159 group->setPropertyType(attrType);
161 group->setNumSlices(
m_ui->m_slicesSpinBox->value());
163 group->setPrecision(
m_ui->m_precSpinBox->value());
165 group->setStdDeviation(
m_ui->m_stdDevDoubleSpinBox->value());
167 group->setSummary(
m_ui->m_summaryComboBox->currentText().toUtf8().data());
181 std::string prefixName = tr(
"Grouping Style: ").toUtf8().data();
182 std::string* styleName =
new std::string(prefixName +
m_ui->m_typeComboBox->currentText().toUtf8().data());
183 style->setName(styleName);
186 QString descInfo = QObject::tr(
"Grouping Information") +
":\n";
188 descInfo += QObject::tr(
"\tProperty: ") +
m_ui->m_attrComboBox->currentText() +
"\n";
189 descInfo += QObject::tr(
"\tNum Slices: ") + QString::number(
m_ui->m_slicesSpinBox->value()) +
"\n";
190 descInfo += QObject::tr(
"\tPrecision: ") + QString::number(
m_ui->m_precSpinBox->value()) +
"\n";
191 descInfo += QObject::tr(
"\tStd Deviation: ") + QString::number(
m_ui->m_stdDevDoubleSpinBox->value()) +
"\n";
192 descInfo += QObject::tr(
"\tSumary: ") +
m_ui->m_summaryComboBox->currentText();
195 descStyle->
setTitle(descInfo.toUtf8().data());
196 style->setDescription(descStyle);
198 style->removeRules();
200 for (std::size_t t = 0; t <
m_rules.size(); ++t)
205 std::string descStr = GetRuleDescription(rule, ds);
210 style->push_back(rule);
232 m_ui->m_slicesSpinBox->setMinimum(1);
234 m_ui->m_slicesSpinBox->setValue(5);
235 m_ui->m_slicesSpinBox->setSingleStep(1);
238 m_ui->m_stdDevDoubleSpinBox->setMinimum(0.25);
239 m_ui->m_stdDevDoubleSpinBox->setMaximum(1.0);
240 m_ui->m_stdDevDoubleSpinBox->setValue(0.5);
241 m_ui->m_stdDevDoubleSpinBox->setSingleStep(0.25);
244 m_ui->m_precSpinBox->setMinimum(1);
246 m_ui->m_precSpinBox->setValue(6);
247 m_ui->m_precSpinBox->setSingleStep(1);
250 #if (QT_VERSION >= 0x050000) 251 m_ui->m_tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
253 m_ui->m_tableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
263 m_ui->m_tableWidget->setRowCount(0);
265 int index =
m_ui->m_typeComboBox->currentIndex();
266 int type =
m_ui->m_typeComboBox->itemData(index).toInt();
271 list.append(tr(
"Symbol"));
272 list.append(tr(
"Title"));
273 list.append(tr(
"Min"));
274 list.append(tr(
"Max"));
276 m_ui->m_tableWidget->setColumnCount(4);
277 m_ui->m_tableWidget->setHorizontalHeaderLabels(list);
282 list.append(tr(
"Symbol"));
283 list.append(tr(
"Title"));
284 list.append(tr(
"Value"));
286 m_ui->m_tableWidget->setColumnCount(3);
287 m_ui->m_tableWidget->setHorizontalHeaderLabels(list);
310 for(std::size_t t = 0; t <
m_rules.size(); ++t)
318 int newrow =
m_ui->m_tableWidget->rowCount();
319 m_ui->m_tableWidget->insertRow(newrow);
323 const std::vector<te::se::Symbolizer*>& ss = ruleItem->
getSymbolizers();
326 QTableWidgetItem* item =
new QTableWidgetItem(icon,
"");
327 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
328 m_ui->m_tableWidget->setItem(newrow, 0, item);
333 QTableWidgetItem* item =
new QTableWidgetItem(QString::fromUtf8((*ruleItem->
getName()).c_str()));
334 item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);
335 m_ui->m_tableWidget->setItem(newrow, 1, item);
340 if (count != 0 && count != static_cast<int>(
m_rules.size()) - 1)
342 double pos = (1. / (
m_rules.size() - 1)) * count;
360 std::string ruleName = *ruleItem->
getName();
367 std::string valueMin;
368 std::string valueMax;
373 QTableWidgetItem* item =
new QTableWidgetItem(QString::fromUtf8(valueMin.c_str()));
374 item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);
375 m_ui->m_tableWidget->setItem(newrow, 2, item);
380 QTableWidgetItem* item =
new QTableWidgetItem(QString::fromUtf8(valueMax.c_str()));
381 item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsEditable);
382 m_ui->m_tableWidget->setItem(newrow, 3, item);
394 QTableWidgetItem* item =
new QTableWidgetItem(QString::fromUtf8(value.c_str()));
395 item->setFlags(Qt::ItemIsEnabled);
396 m_ui->m_tableWidget->setItem(newrow, 2, item);
411 #if (QT_VERSION >= 0x050000) 412 m_ui->m_tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
414 m_ui->m_tableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
448 for (
int i = 0; i <
m_ui->m_typeComboBox->count(); ++i)
450 if (type ==
m_ui->m_typeComboBox->itemData(i).toInt())
452 m_ui->m_typeComboBox->setCurrentIndex(i);
463 for (
int i = 0; i <
m_ui->m_attrComboBox->count(); ++i)
465 if (attrName ==
m_ui->m_attrComboBox->itemText(i).toUtf8().data())
467 m_ui->m_attrComboBox->setCurrentIndex(i);
475 m_ui->m_precSpinBox->setValue((
int)prec);
480 m_ui->m_slicesSpinBox->setValue((
int)slices);
485 m_ui->m_stdDevDoubleSpinBox->setValue((
double)stdDev);
491 for (
size_t t = 0; t < style->
getRules().size(); ++t)
505 int reply = QMessageBox::question(
this, tr(
"Edit Legend"), tr(
"Manual changes will be lost. Continue?"), QMessageBox::Yes | QMessageBox::Cancel);
507 if(reply != QMessageBox::Yes)
511 int index =
m_ui->m_typeComboBox->currentIndex();
513 int type =
m_ui->m_typeComboBox->itemData(index).toInt();
514 int slices =
m_ui->m_slicesSpinBox->value();
515 int prec =
m_ui->m_precSpinBox->value();
516 double stdDev =
m_ui->m_stdDevDoubleSpinBox->value();
518 std::string attr =
m_ui->m_attrComboBox->currentText().toUtf8().data();
519 int attrIdx =
m_ui->m_attrComboBox->currentIndex();
520 int attrType =
m_ui->m_attrComboBox->itemData(attrIdx).toInt();
533 std::vector<double> vec;
548 std::vector<double> vec;
563 std::vector<double> vec;
580 std::vector<std::string> vec;
603 int type =
m_ui->m_typeComboBox->itemData(idx).toInt();
607 m_ui->m_slicesSpinBox->setEnabled(
true);
608 m_ui->m_precSpinBox->setEnabled(
true);
609 m_ui->m_stdDevDoubleSpinBox->setEnabled(
false);
613 m_ui->m_slicesSpinBox->setEnabled(
true);
614 m_ui->m_precSpinBox->setEnabled(
true);
615 m_ui->m_stdDevDoubleSpinBox->setEnabled(
false);
619 m_ui->m_slicesSpinBox->setEnabled(
false);
620 m_ui->m_precSpinBox->setEnabled(
true);
621 m_ui->m_stdDevDoubleSpinBox->setEnabled(
true);
625 m_ui->m_slicesSpinBox->setEnabled(
false);
626 m_ui->m_precSpinBox->setEnabled(
true);
627 m_ui->m_stdDevDoubleSpinBox->setEnabled(
false);
651 int index =
m_ui->m_typeComboBox->currentIndex();
652 int type =
m_ui->m_typeComboBox->itemData(index).toInt();
654 int curRow =
m_ui->m_tableWidget->currentRow();
655 int curCol =
m_ui->m_tableWidget->currentColumn();
657 std::string attrName =
m_ui->m_attrComboBox->currentText().toUtf8().data();
659 QString str = item->text();
663 std::string ruleName = str.toUtf8().data();
664 m_rules[curRow]->setName(&ruleName);
668 else if(curCol == 2 || curCol == 3)
678 std::string valueMin;
679 std::string valueMax;
684 item->setText(valueMin.c_str());
686 item->setText(valueMax.c_str());
690 std::string valueMin;
691 std::string valueMax;
696 valueMin = item->text().toUtf8().data();
698 valueMax = item->text().toUtf8().data();
711 int curRow =
m_ui->m_tableWidget->currentRow();
712 int curCol =
m_ui->m_tableWidget->currentColumn();
718 std::vector<te::se::Symbolizer*> symbVec = ruleItem->
getSymbolizers();
721 QBoxLayout* layout =
new QBoxLayout(QBoxLayout::TopToBottom, dialog);
723 QDialogButtonBox* bbox =
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, dialog);
727 if(symbVec[0]->getType() ==
"PolygonSymbolizer")
733 else if(symbVec[0]->getType() ==
"LineSymbolizer")
739 else if(symbVec[0]->getType() ==
"PointSymbolizer")
746 layout->addWidget(symbWidget);
747 layout->addWidget(bbox);
749 connect(bbox, SIGNAL(accepted()), dialog, SLOT(accept()));
750 connect(bbox, SIGNAL(rejected()), dialog, SLOT(reject()));
752 if(dialog->exec() == QDialog::Rejected)
758 if(symbVec[0]->getType() ==
"PolygonSymbolizer")
764 else if(symbVec[0]->getType() ==
"LineSymbolizer")
770 else if(symbVec[0]->getType() ==
"PointSymbolizer")
782 QTableWidgetItem* newItem =
new QTableWidgetItem(icon,
"");
783 newItem->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
785 m_ui->m_tableWidget->setItem(curRow, 0, newItem);
806 std::unique_ptr<te::map::LayerSchema> dsType(
m_layer->getSchema());
808 std::size_t idx=std::string::npos;
810 for(std::size_t t = 0; t < dsType->getProperties().size(); ++t)
812 if(dsType->getProperty(t)->getName() == attrName)
819 std::unique_ptr<te::da::DataSet>
ds(
m_layer->getData());
821 ds->moveBeforeFirst();
823 while(
ds->moveNext())
832 vec.push_back((
double)
ds->getInt16(idx));
834 vec.push_back((
double)
ds->getInt32(idx));
836 vec.push_back((
double)
ds->getInt64(idx));
838 vec.push_back((
double)
ds->getFloat(idx));
840 vec.push_back(
ds->getDouble(idx));
843 QString strNum =
ds->getNumeric(idx).c_str();
847 double value = strNum.toDouble(&ok);
850 vec.push_back(value);
859 std::unique_ptr<te::map::LayerSchema> dsType(
m_layer->getSchema());
861 std::string
function =
m_ui->m_summaryComboBox->currentText().toUtf8().data();
862 std::vector<std::string> poid;
873 std::vector<te::dt::Property*> props = dsType->getPrimaryKey()->getProperties();
874 while(++pksize < props.size())
876 poid.push_back(props[pksize-1]->getName());
877 if(props[pksize-1]->getDatasetName() != props[pksize]->getDatasetName())
881 for(
size_t i = 0; i < pksize; ++i)
887 std::size_t idx=std::string::npos;
889 for(std::size_t t = 0; t < dsType->getProperties().size(); ++t)
891 if(dsType->getProperty(t)->getName() == attrName)
898 std::vector<std::string> pkdata(pksize), pkdataaux(pksize);
899 std::unique_ptr<te::da::DataSet>
ds(
m_layer->getData());
902 bool nullValue =
false;
903 std::vector<double> values;
905 ds->moveBeforeFirst();
907 while(
ds->moveNext())
913 for(i = 0; i < pksize; ++i)
915 pkdata[i] =
ds->getAsString(poid[i]);
919 pkdataaux[i] =
ds->getAsString(poid[i]);
923 for(i = 0; i < pksize; ++i)
925 if(pkdata[i] != pkdataaux[i])
933 if(nullValue ==
false)
940 values.push_back((
double)
ds->getInt16(idx));
942 values.push_back((
double)
ds->getInt32(idx));
944 values.push_back((
double)
ds->getInt64(idx));
946 values.push_back((
double)
ds->getFloat(idx));
948 values.push_back(
ds->getDouble(idx));
951 QString strNum =
ds->getNumeric(idx).c_str();
955 double value = strNum.toDouble(&ok);
958 values.push_back(value);
982 values.push_back((
double)
ds->getInt16(idx));
984 values.push_back((
double)
ds->getInt32(idx));
986 values.push_back((
double)
ds->getInt64(idx));
988 values.push_back((
double)
ds->getFloat(idx));
990 values.push_back(
ds->getDouble(idx));
993 QString strNum =
ds->getNumeric(idx).c_str();
997 double value = strNum.toDouble(&ok);
1000 values.push_back(value);
1024 std::unique_ptr<te::map::LayerSchema> dsType(
m_layer->getSchema());
1026 std::size_t idx=std::string::npos;
1028 for(std::size_t t = 0; t < dsType->getProperties().size(); ++t)
1030 if(dsType->getProperty(t)->getName() == attrName)
1037 std::unique_ptr<te::da::DataSet>
ds(
m_layer->getData());
1039 ds->moveBeforeFirst();
1041 while(
ds->moveNext())
1043 if(!
ds->isNull(idx))
1044 vec.push_back(
ds->getAsString(idx));
1054 std::unique_ptr<te::map::LayerSchema> dsType(
m_layer->getSchema());
1056 std::string
function =
m_ui->m_summaryComboBox->currentText().toUtf8().data();
1057 std::vector<std::string> poid;
1068 std::vector<te::dt::Property*> props = dsType->getPrimaryKey()->getProperties();
1069 while(++pksize < props.size())
1071 poid.push_back(props[pksize-1]->getName());
1072 if(props[pksize-1]->getDatasetName() != props[pksize]->getDatasetName())
1076 for(
size_t i = 0; i < pksize; ++i)
1082 std::size_t idx=std::string::npos;
1084 for(std::size_t t = 0; t < dsType->getProperties().size(); ++t)
1086 if(dsType->getProperty(t)->getName() == attrName)
1093 std::vector<std::string> pkdata(pksize), pkdataaux(pksize);
1094 std::unique_ptr<te::da::DataSet>
ds(
m_layer->getData());
1097 bool nullValue =
false;
1098 std::vector<std::string> values;
1099 bool isBegin =
true;
1100 ds->moveBeforeFirst();
1102 while(
ds->moveNext())
1108 for(i = 0; i < pksize; ++i)
1110 pkdata[i] =
ds->getAsString(poid[i]);
1114 pkdataaux[i] =
ds->getAsString(poid[i]);
1118 for(i = 0; i < pksize; ++i)
1120 if(pkdata[i] != pkdataaux[i])
1128 if(nullValue ==
false)
1133 values.push_back(
ds->getAsString(idx));
1153 values.push_back(
ds->getAsString(idx));
1170 std::string attrName =
m_ui->m_attrComboBox->currentText().toUtf8().data();
1172 std::string* ruleName =
new std::string(
NO_TITLE);
1179 std::vector<te::se::Symbolizer*> symbVec;
1181 symbVec.push_back(s);
1192 std::string attrName =
m_ui->m_attrComboBox->currentText().toUtf8().data();
1194 std::string* ruleName =
new std::string(
NO_TITLE);
1201 std::vector<te::se::Symbolizer*> symbVec;
1203 symbVec.push_back(s);
1222 int legendSize =
static_cast<int>(
m_rules.size());
1224 std::vector<te::color::RGBAColor> colorVec;
1226 if(meanTitle.empty())
1235 for(
size_t t = 0; t <
m_rules.size(); ++t)
1237 std::string ruleName = *
m_rules[t]->getName();
1238 if (ruleName != meanTitle)
1244 afterMean =
static_cast<int>(
m_rules.size() - t - 1);
1253 for(
size_t t = 0; t < lowerColorVec.size(); ++t)
1254 colorVec.push_back(lowerColorVec[t]);
1256 colorVec.push_back(meanColor);
1258 for(
size_t t = 0; t < upperColorVec.size(); ++t)
1259 colorVec.push_back(upperColorVec[t]);
1262 if (colorVec.size() !=
m_rules.size())
1267 for(
size_t t = 0; t < colorVec.size(); ++t)
1269 std::vector<te::se::Symbolizer*> symbVec;
1273 symbVec.push_back(s);
1275 m_rules[t]->setSymbolizers(symbVec);
1281 QString curValue =
m_ui->m_attrComboBox->currentText();
1283 m_ui->m_attrComboBox->clear();
1285 std::unique_ptr<te::map::LayerSchema> dsType(
m_layer->getSchema());
1288 int index =
m_ui->m_typeComboBox->currentIndex();
1289 int type =
m_ui->m_typeComboBox->itemData(index).toInt();
1293 for(
size_t t = 0; t < dsType->getProperties().size(); ++t)
1316 for(
size_t t = 0; t < dsType->getProperties().size(); ++t)
1339 if(curValue.isEmpty() ==
false)
1341 int idx =
m_ui->m_attrComboBox->findText(curValue);
1344 m_ui->m_attrComboBox->setCurrentIndex(idx);
1359 m_ui->m_summaryComboBox->clear();
1362 m_ui->m_summaryComboBox->addItem(
"MIN");
1363 m_ui->m_summaryComboBox->addItem(
"MAX");
1364 m_ui->m_summaryComboBox->addItem(
"SUM");
1365 m_ui->m_summaryComboBox->addItem(
"AVERAGE");
1366 m_ui->m_summaryComboBox->addItem(
"MEDIAN");
1367 m_ui->m_summaryComboBox->addItem(
"STDDEV");
1368 m_ui->m_summaryComboBox->addItem(
"VARIANCE");
1369 m_ui->m_summaryComboBox->addItem(
"NONE");
1373 int index =
m_ui->m_summaryComboBox->findText(QString::fromUtf8(
m_layer->getGrouping()->getSummary().c_str()));
1374 m_ui->m_summaryComboBox->setCurrentIndex(index);
1377 m_ui->m_summaryComboBox->setEnabled(
true);
1378 m_ui->m_summaryComboBox->show();
1379 m_ui->m_summaryLabel->show();
1383 m_ui->m_summaryComboBox->addItem(
"NONE");
1384 m_ui->m_summaryComboBox->setEnabled(
false);
1385 m_ui->m_summaryComboBox->hide();
1386 m_ui->m_summaryLabel->hide();
1389 for(std::size_t i = 0; i < allLayers.size(); ++i)
1391 if(!allLayers[i]->isValid())
1394 std::unique_ptr<te::da::DataSetType>
dt(allLayers[i]->getSchema());
1396 if(dt->hasGeom() && allLayers[i]->getGrouping() && allLayers[i]->getId() != selectedLayer->getId())
1398 m_ui->m_layersComboBox->addItem(allLayers[i]->getTitle().c_str(), QVariant::fromValue(allLayers[i]));
1405 if(
m_ui->m_layersComboBox->currentText() ==
"")
1407 QMessageBox::warning(
this, tr(
"Grouping"), tr(
"There are no other layers with Grouping!"));
1413 int reply = QMessageBox::question(
this, tr(
"Grouping"), tr(
"Manual changes will be lost. Continue?"), QMessageBox::Yes | QMessageBox::Cancel);
1415 if(reply != QMessageBox::Yes)
1419 QVariant varLayer =
m_ui->m_layersComboBox->itemData(
m_ui->m_layersComboBox->currentIndex(), Qt::UserRole);
1424 std::unique_ptr<te::da::DataSetType>
dt =
m_layer->getSchema();
1426 std::vector<te::dt::Property*> props = dt->getProperties();
1428 bool isValid =
false;
1429 for(std::size_t i = 0; i < props.size(); ++i)
1441 QString err = tr(
"There is no grouping that can be imported!\nThe layer must have an attribute with the same name of the attribute used to make the reference layer grouping: ");
1442 err.append(ref->getPropertyName().c_str());
1443 QMessageBox::warning(
this, tr(
"Grouping"), err);
1460 QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Open..."),
1461 QString(), tr(
"LEG (*.leg *.LEG);;"),
nullptr, QFileDialog::DontConfirmOverwrite);
1463 if (fileName.isEmpty())
1466 m_ui->m_tableWidget->setRowCount(0);
1468 boost::property_tree::ptree pt;
1472 boost::property_tree::json_parser::read_json(fileName.toUtf8().data(), pt);
1476 boost::property_tree::ptree legend = pt.get_child(
"Legend");
1478 std::string attrName = legend.get<std::string>(
"Attribute");
1479 std::string precision = legend.get<std::string>(
"Precision");
1480 std::string catalog = legend.get<std::string>(
"Catalog");
1481 std::string group = legend.get<std::string>(
"Group");
1482 std::string schema = legend.get<std::string>(
"Schema");
1484 if(!
m_ui->m_attrComboBox->findText(attrName.c_str()))
1486 QMessageBox::warning(
this, tr(
"Grouping"), tr(
"Attribute not found."));
1490 m_ui->m_attrComboBox->setCurrentIndex(
m_ui->m_attrComboBox->findText(attrName.c_str()));
1491 m_ui->m_precSpinBox->setValue(boost::lexical_cast<double>(precision));
1499 std::vector<std::vector<std::string> > items;
1501 for(boost::property_tree::ptree::value_type &v: legend.get_child(
"Items"))
1503 std::vector<std::string> item;
1504 item.push_back(v.second.get<std::string>(
"Title"));
1505 item.push_back(v.second.get<std::string>(
"Min"));
1506 item.push_back(v.second.get<std::string>(
"Max"));
1507 item.push_back(v.second.get<std::string>(
"R"));
1508 item.push_back(v.second.get<std::string>(
"G"));
1509 item.push_back(v.second.get<std::string>(
"B"));
1511 items.push_back(item);
1514 m_ui->m_tableWidget->setRowCount(items.size());
1516 for (std::size_t i = 0; i < items.size(); ++i)
1518 m_ui->m_tableWidget->setItem(i, 1,
new QTableWidgetItem(items[i][0].c_str()));
1519 m_ui->m_tableWidget->setItem(i, 2,
new QTableWidgetItem(items[i][1].c_str()));
1520 m_ui->m_tableWidget->setItem(i, 3,
new QTableWidgetItem(items[i][2].c_str()));
1523 color.setRgb(boost::lexical_cast<int>(items[i][3]), boost::lexical_cast<int>(items[i][4]), boost::lexical_cast<int>(items[i][5]));
1525 QPixmap pix(24, 24);
1528 p.fillRect(0, 0, 12, 24, color);
1529 p.fillRect(12, 0, 12, 24, color);
1530 p.setBrush(Qt::transparent);
1531 p.setPen(Qt::black);
1532 p.drawRect(0, 0, 23, 23);
1536 QTableWidgetItem* item =
new QTableWidgetItem(icon,
"");
1537 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1538 m_ui->m_tableWidget->setItem(i, 0, item);
1542 catch(boost::property_tree::ptree_error& e)
1544 QMessageBox::warning(
this, tr(
"Grouping"), tr(
"Attribute not found."));
1548 catch(boost::property_tree::json_parser::json_parser_error& e)
1550 QMessageBox::warning(
this, tr(
"Grouping"), tr(
"Invalid file"));
1557 QString fileName = QFileDialog::getSaveFileName(
this, tr(
"Save as..."),
1558 QString(), tr(
"LEG (*.leg *.LEG);;"),
nullptr, QFileDialog::DontConfirmOverwrite);
1565 int rowCount =
m_ui->m_tableWidget->rowCount();
1573 boost::property_tree::ptree pt;
1574 boost::property_tree::ptree legend;
1576 std::string attrName =
m_ui->m_attrComboBox->currentText().toUtf8().data();
1577 std::string precision =
m_ui->m_precSpinBox->text().toUtf8().data();
1582 legend.add(
"Attribute", attrName);
1583 legend.add(
"Precision", precision);
1584 legend.add(
"Catalog", catalog);
1585 legend.add(
"Group", group);
1586 legend.add(
"Schema", schema);
1588 boost::property_tree::ptree items;
1590 for (
int i = 0; i <
m_ui->m_tableWidget->rowCount(); ++i)
1592 std::string title =
m_ui->m_tableWidget->item(i, 1)->text().toUtf8().data();
1593 std::string min =
m_ui->m_tableWidget->item(i, 2)->text().toUtf8().data();
1594 std::string max =
m_ui->m_tableWidget->item(i, 3)->text().toUtf8().data();
1598 const std::vector<te::se::Symbolizer*>& ss = rule->
getSymbolizers();
1603 boost::property_tree::ptree item;
1604 item.add(
"Title", title);
1605 item.add(
"Min", min);
1606 item.add(
"Max", max);
1607 item.add(
"R", color.
getRed());
1609 item.add(
"B", color.
getBlue());
1611 items.add_child(
"Item", item);
1614 legend.add_child(
"Items", items);
1616 pt.add_child(
"Legend", legend);
1618 boost::property_tree::write_json(path, pt);
TEDATAACCESSEXPORT DataSourcePtr GetDataSource(const std::string &datasourceId, const bool opened=true)
Search for a data source with the informed id in the DataSourceManager.
const Fill * getFill() const
Gets the Fill associates with the PolygonSymbolizer.
TESEEXPORT void GetColor(const te::se::Stroke *stroke, te::color::RGBAColor &color)
It gets the RGBA color from the Stroke element.
const double getStdDeviation() const
It gets the standard deviation used in the Standard Deviation grouping.
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
A Description gives human-readable descriptive information for the object it is included within...
The Style defines the styling that is to be applied to a geographic dataset (vector geometries or cov...
int getRed() const
It returns the red component color value (a value from 0 to 255).
A PolygonSymbolizer is used to draw a polygon (or other area-type geometries), including filling its ...
TESEEXPORT Symbolizer * CreateSymbolizer(const te::gm::GeomType &geomType)
Try creates an appropriate symbolizer based on given geometry type.
boost::shared_ptr< DataSource > DataSourcePtr
TEDATAACCESSEXPORT bool HasLinkedTable(te::da::DataSetType *type)
It checks if the datasettype has a linked table.
const size_t getPrecision() const
It gets the precision used for the property values.
A Symbolizer describes how a feature is to appear on a map.
TEMAPEXPORT void GroupingByUniqueValues(std::string attrName, std::vector< std::string > &inputValues, int dataType, std::vector< te::se::Rule * > &rules, int precision)
It groups the values using the unique value algorithm.
void setDescription(Description *d)
Rule * clone() const
It creates a new copy of this object.
std::string getPropertyName() const
It gets the property name whose values will be grouped.
void setName(std::string *name)
TEMAPEXPORT te::gm::GeomType GetGeomType(const te::map::AbstractLayerPtr &layer)
It gets the geometry type of the given layer.
int getBlue() const
It returns the blue component color value (a value from 0 to 255).
int getGreen() const
It returns the green component color value (a value from 0 to 255).
const std::vector< te::color::RGBAColor > & getUpperMeanSlices(const int &n)
boost::ptr_vector< OrderByItem > OrderBy
A class that can be used to model an ORDER BY clause.
void GroupingByQuantil(std::string attrName, iterator begin, iterator end, int nSteps, std::vector< te::se::Rule * > &rules, int precision=0)
It groups the values defined by a range of iterators using the quantil algorithm. ...
std::string Convert2UCase(const std::string &value)
It converts a string to upper case.
A PointSymbolizer specifies the rendering of a graphic Symbolizer at a point.
te::da::Expression * getExpression(const te::fe::Filter *f)
It converts the OGC Filter Expression to a TerraLib Expression.
virtual ReturnType accept(VisitorType &guest) const =0
It call the visit method from the guest object.
A layer resulting from a query.
static te::dt::Date ds(2010, 01, 01)
void GroupingByEqualSteps(std::string attrName, iterator begin, iterator end, int nSteps, std::vector< te::se::Rule * > &rules, int precision=0)
It groups the values defined by a range of iterators using the equal steps algorithm.
void setFilter(te::fe::Filter *f)
const te::fe::Filter * getFilter() const
It models a property definition.
This is an abstract class that models a query expression.
Rule * getRule(std::size_t i) const
const std::vector< Rule * > & getRules() const
const std::vector< te::color::RGBAColor > & getLowerMeanSlices(const int &n)
This class contains the parameters needed for grouping the values of a Property.
TEFEEXPORT void GetFilterStepValues(const te::fe::Filter *filter, std::string &valueMin, std::string &valueMax)
TEFEEXPORT te::fe::Filter * CreateFilterByStep(const std::string &attrName, const std::string &minValue, const std::string &maxValue)
TEFEEXPORT te::fe::Filter * CreateFilterByUniqueValue(const std::string &attrName, const std::string &value)
static te::dt::TimeDuration dt(20, 30, 50, 11)
void setTitle(const std::string &title)
A visitor that converts a OGC Filter Expression to TerraLib Expression.
TEDATAACCESSEXPORT double GetSummarizedValue(std::vector< double > &values, const std::string &summary)
It gets the summarized value.
A Fill specifies the pattern for filling an area geometry.
te::da::Select * getQuery() const
A filter is any valid predicate expression.
Query * clone() const
It creates a new copy of this query.
const te::color::RGBAColor & getMeanSlice()
void setSymbolizers(const std::vector< Symbolizer * > &symbs)
void setOrderBy(OrderBy *o)
It sets the list of expressions used to sort the output result.
A Select models a query to be used when retrieving data from a DataSource.
A Symbology Enconding visitor that finds a color given a symbolizer element. If you want to use this ...
const std::vector< te::color::RGBAColor > & getSlices(const int &n)
It generates color bar.
const std::vector< Symbolizer * > & getSymbolizers() const
int getType() const
It returns the property data type.
void find(const te::se::Symbolizer *symbolizer)
It find the color based on given symbolizer.
void addColor(const RGBAColor &color, const double &pos)
It adds a color in the color bar.
GroupingType
The grouping type associated to the layer.
A Rule is used to attach property/scale conditions to and group the individual symbols used for rende...
void setQuery(te::da::Select *s)
A helper class for 32-bit RGBA (Red-Green-Blue-Alpha channel) color.
const GroupingType getType() const
It gets the grouping type.
It models the concept of color bar.
A LineSymbolizer is used to style a stroke along a linear geometry type, such as a string of line seg...
A visitor for building an SQL statement from a given Query hierarchy.
const SvgParameter * getColor() const
const size_t getNumSlices() const
It gets the number of slices used in the Equal Steps and Quantil groupings.
A class that can be used in an ORDER BY clause to sort the items of a resulting query.
te::color::RGBAColor getColor()
Get the color.
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
void FreeContents(boost::unordered_map< K, V * > &m)
This function can be applied to a map of pointers. It will delete each pointer in the map...
void GroupingByStdDeviation(std::string attrName, iterator begin, iterator end, double nDevs, std::vector< te::se::Rule * > &rules, std::string &meanTitle, int precision=0)
It groups the values defined by a range of iterators using the standard deviation algorithm...
static const std::string sm_nanStr
Not a number string value.
const std::string & getName() const
It returns the property name.
TEFEEXPORT void GetFilterUniqueValue(const te::fe::Filter *filter, std::string &value)
const std::string * getName() const