34 #include "../../..//dataaccess/query/EqualTo.h" 35 #include "../../../Exception.h" 36 #include "../../../color/ColorBar.h" 37 #include "../../../color/ColorScheme.h" 38 #include "../../../color/ColorSchemeCatalog.h" 39 #include "../../../color/ColorSchemeCatalogManager.h" 40 #include "../../../color/ColorSchemeGroup.h" 41 #include "../../../color/RGBAColor.h" 42 #include "../../../common/Globals.h" 43 #include "../../../common/STLUtils.h" 44 #include "../../../dataaccess/datasource/DataSourceManager.h" 45 #include "../../../dataaccess/query/And.h" 46 #include "../../../dataaccess/query/DataSetName.h" 47 #include "../../../dataaccess/query/Field.h" 48 #include "../../../dataaccess/query/From.h" 49 #include "../../../dataaccess/query/FromItem.h" 50 #include "../../../dataaccess/query/GreaterThanOrEqualTo.h" 51 #include "../../../dataaccess/query/LessThanOrEqualTo.h" 52 #include "../../../dataaccess/query/LiteralString.h" 53 #include "../../../dataaccess/query/OrderBy.h" 54 #include "../../../dataaccess/query/OrderByItem.h" 55 #include "../../../dataaccess/query/PropertyName.h" 56 #include "../../../dataaccess/query/SQLVisitor.h" 57 #include "../../../dataaccess/query/Select.h" 58 #include "../../../dataaccess/query/Where.h" 59 #include "../../../dataaccess/utils/Utils.h" 60 #include "../../../fe.h" 61 #include "../../../geometry/GeometryProperty.h" 62 #include "../../../maptools/AbstractLayer.h" 63 #include "../../../maptools/Grouping.h" 64 #include "../../../maptools/GroupingAlgorithms.h" 65 #include "../../../maptools/MapDisplay.h" 66 #include "../../../maptools/Utils.h" 67 #include "../../../se/ColorMap.h" 68 #include "../../../se/PolygonSymbolizer.h" 69 #include "../../../se/Rule.h" 70 #include "../../../se/Style.h" 71 #include "../../../se/Utils.h" 72 #include "../../af/ApplicationController.h" 73 #include "../../af/BaseApplication.h" 74 #include "../../af/connectors/MapDisplay.h" 75 #include "../../af/events/LayerEvents.h" 76 #include "../../af/events/MapEvents.h" 77 #include "../../widgets/Utils.h" 78 #include "../../widgets/canvas/Canvas.h" 79 #include "../../widgets/canvas/MapDisplay.h" 80 #include "../../widgets/layer/explorer/LayerItemView.h" 81 #include "../../widgets/se/GroupingDialog.h" 83 #include "ui_TimeViewerWidget.h" 86 #include <boost/algorithm/string.hpp> 87 #include <boost/algorithm/string/join.hpp> 88 #include <boost/uuid/random_generator.hpp> 89 #include <boost/uuid/uuid_io.hpp> 92 #include <QtConcurrent/qtconcurrentrun.h> 97 #include <QMessageBox> 99 #include <QVBoxLayout> 107 m_ui(new
Ui::TimeViewerWidget),
110 m_drawingLoop(nullptr),
127 setWindowTitle(
"Time Viewer");
128 setWindowIcon(QIcon::fromTheme(
"time-viewer"));
131 m_ui->m_stopToolButton->setIcon(QIcon::fromTheme(
"media-playback-stop"));
132 m_ui->m_backToolButton->setIcon(QIcon::fromTheme(
"media-skip-backward"));
133 m_ui->m_passToolButton->setIcon(QIcon::fromTheme(
"media-skip-forward"));
134 m_ui->m_pauseToolButton->setIcon(QIcon::fromTheme(
"media-playback-pause"));
135 m_ui->m_playToolButton->setIcon(QIcon::fromTheme(
"media-playback-start"));
148 m_ui->m_accumPushButton->setEnabled(
false);
162 m_app->addDockWidget(Qt::BottomDockWidgetArea,
this);
167 m_ui->m_timeSlider->setMinimum(0);
168 m_ui->m_timeSlider->setSingleStep(1);
169 m_ui->m_timeSlider->setTracking(
false);
177 auto it = std::find_if(layerList.begin(), layerList.end(),
179 return m_layer->getTitle() == layer->getTitle();
182 if(it != layerList.end())
184 layerList.remove(*it);
200 m_ui->m_layerCBox->addItem(
"");
203 m_ui->m_layerCBox->addItem(layer->getDataSetName().c_str(),layer->getDataSourceId().c_str());
212 m_dsId =
m_ui->m_layerCBox->itemData(index).toString().toUtf8().data();
217 m_ui->m_startDateCBox->clear();
218 m_ui->m_endDateCBox->clear();
219 m_ui->m_startDateCBox->addItem(
"");
220 m_ui->m_endDateCBox->addItem(
"");
222 m_ui->m_accumulate->setChecked(
false);
223 m_ui->m_accumPushButton->setEnabled(
false);
227 if(
m_dsPtr->getType() !=
"POSTGIS")
229 QMessageBox::warning(0,
"TimeViewer",
"Unsupported datasource");
233 for(
auto propertie : properties)
235 m_ui->m_startDateCBox->addItem(propertie.c_str());
236 m_ui->m_endDateCBox->addItem(propertie.c_str());
242 static boost::uuids::basic_random_generator<boost::mt19937> gen;
243 boost::uuids::uuid u = gen();
244 return boost::uuids::to_string(u);
257 m_layer->setRendererType(
"QUERY_LAYER_RENDERER");
263 if(
m_layer->getStyle() ==
nullptr)
273 m_ui->m_timeSlider->setEnabled(
true);
279 m_ui->m_timeSlider->setValue(
m_ui->m_timeSlider->maximum());
280 m_ui->m_timeSlider->setEnabled(
true);
287 int value =
m_ui->m_timeSlider->value();
288 if(!(value ==
m_ui->m_timeSlider->maximum()))
290 m_ui->m_timeSlider->setValue(++value);
296 int value =
m_ui->m_timeSlider->value();
299 m_ui->m_timeSlider->setValue(--value);
310 int max_value =
m_ui->m_timeSlider->maximum();
314 if(
m_ui->m_timeSlider->value() == max_value)
316 m_ui->m_timeSlider->setValue(0);
319 m_ui->m_timeSlider->setEnabled(
false);
321 for(min_value =
m_ui->m_timeSlider->value(); min_value <= max_value;
326 QThread::currentThread()->msleep(250);
330 QThread::currentThread()->msleep(2000);
331 m_ui->m_timeSlider->setValue(min_value);
335 m_ui->m_timeSlider->setEnabled(
true);
344 auto result =
m_dsPtr->query(query);
348 std::string alias =
"timeviewer";
352 from->push_back(fromItem);
357 for(
auto propertie : properties)
359 fields->push_back(
new te::da::Field(alias +
"." + propertie));
374 visitor.
visit(select);
390 QMessageBox::warning(
392 "There is no layer selected. \nPlease select one before edit legend");
407 QMessageBox::warning(
409 "There is no layer selected. \nPlease select one before applying");
413 m_start =
m_ui->m_startDateCBox->currentText().toUtf8().data();
414 m_end =
m_ui->m_endDateCBox->currentText().toUtf8().data();
418 QMessageBox::warning(0,
"TimeViewer",
419 "There is no start date attribute selected. \nPlease " 420 "select one before applying");
424 std::string query =
"SELECT " +
m_start +
440 query +=
" ORDER BY date";
442 auto result =
m_dsPtr->query(query);
444 result->moveBeforeFirst();
446 while(result->moveNext())
448 m_dates.push_back(result->getAsString(
"date"));
451 m_ui->m_timeSlider->setMaximum(
m_dates.size() - 1);
456 auto it = std::find_if(layerList.begin(), layerList.end(),
458 return m_layer->getTitle() == layer->getTitle();
461 if(it == layerList.end())
469 m_ui->m_timeSlider->blockSignals(
true);
470 m_ui->m_timeSlider->setValue(0);
471 m_ui->m_timeSlider->blockSignals(
false);
478 int index =
m_ui->m_timeSlider->value();
480 std::string date =
m_dates[index];
484 std::string alias =
"timeviewer";
488 from->push_back(fromItem);
493 for(
auto propertie : properties)
495 fields->push_back(
new te::da::Field(alias +
"." + propertie));
512 if(
m_ui->m_accumulate->isChecked())
549 visitor.
visit(select);
555 if(
m_ui->m_accumulate->isChecked())
561 std::string dateAttr =
m_ui->m_startDateCBox->currentText().toUtf8().data();
574 std::vector<te::se::Symbolizer*> symbVec;
578 symbVec.push_back(s);
588 std::vector<te::se::Symbolizer*> symbVecAct;
592 symbVecAct.push_back(symbAct);
600 for(std::size_t t = 0; t <
m_rules.size(); ++t)
614 filterB->
setOp(andOp);
624 else if(!
m_rules.empty() &&
m_ui->m_timeSlider->value() == 0)
631 for(std::size_t t = 0; t <
m_rules.size(); ++t)
646 if(mapDisplay->getSRID() == 0)
649 std::pair<int, std::string> srid(mapDisplay->getSRID(),
"EPSG");
654 auto extent =
m_layer->getExtent();
657 mapDisplay->setExtent(extent,
true);
671 m_ui->m_accumPushButton->setEnabled(
true);
static const char * sm_propertyIsLessThan
A dialog used to edit legend.
An abstract class that models a source of data in a query.
The Field class can be used to model an expression that takes part of the output items of a SELECT...
It models the inequality operator less than or equal to (<=).
The Style defines the styling that is to be applied to a geographic dataset (vector geometries or cov...
A class that models the name of a dataset used in a From clause.
TESEEXPORT Symbolizer * CreateSymbolizer(const te::gm::GeomType &geomType)
Try creates an appropriate symbolizer based on given geometry type.
virtual Style * clone() const =0
It creates a new copy of this object.
A class that models the name of any property of an object.
A Symbolizer describes how a feature is to appear on a map.
A base class for application events.
This event signals that the srid of the map display changed.
It models the inequality operator greater than or equal to (>=).
AbstractOp * getOp() const
It returns main filter operation.
void push_back(const std::string &semanticTypeIdentifier)
A dialog used to edit legend.
A layer resulting from a query.
void setFilter(te::fe::Filter *f)
static const char * sm_propertyIsEqualTo
Boolean logic operator: AND.
This is an abstract class that models a query expression.
TESEEXPORT Style * CreateFeatureTypeStyle(const te::gm::GeomType &geomType)
Try creates an appropriate feature type style based on given geometry type.
virtual void setLayerList(const std::list< te::map::AbstractLayerPtr > &layers)
It sets the layer list to be showed in the Map Display.
void setWhere(Where *w)
It sets the filter codition.
TEFEEXPORT te::fe::Filter * CreateFilterByUniqueValue(const std::string &attrName, const std::string &value)
void setOp(AbstractOp *o)
It sets the filter main operation (expression).
int getSRID() const
It returns the spatial reference system identifier associated to this property.
static ApplicationController & getInstance()
It returns a reference to the singleton instance.
virtual void visit(const Expression &visited)
This class is used to encode the name of any property of an object.
GeomType getGeometryType() const
It returns the geometry subtype allowed for the property.
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
te::qt::widgets::LayerItemView * getLayerExplorer()
A class that can be used to model a filter expression that can be applied to a query.
A filter is any valid predicate expression.
A dialog used to edit legend.
void setSymbolizers(const std::vector< Symbolizer * > &symbs)
A Select models a query to be used when retrieving data from a DataSource.
boost::ptr_vector< FromItem > From
It models the FROM clause for a query.
An abstract interface for operators.
A class for binary comparison operators.
static const char * sm_and
std::list< te::map::AbstractLayerPtr > m_layers
This class can be used to represent literal values.
A Rule is used to attach property/scale conditions to and group the individual symbols used for rende...
te::qt::widgets::MapDisplay * getMapDisplay()
It models the comparison operator.
A visitor for building an SQL statement from a given Query hierarchy.
A logical operator can be used to combine two or more conditional expressions.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
boost::intrusive_ptr< AbstractLayer > AbstractLayerPtr
void setFields(Fields *f)
It sets the list of output expressions used to form the result set.
virtual AbstractOp * clone() const =0
It creates a new copy of this object.
void setFrom(From *f)
It sets the list of source information.
This class models a string Literal value.
const std::string & getName() const
It returns the property name.