[FEATURE] remove RoadGraph plugin

tagged as feature to not forget mention this in docs and changelog
This commit is contained in:
Alexander Bruy 2016-12-06 14:49:37 +02:00
parent ab823c4c66
commit ce342b0f87
27 changed files with 2 additions and 4087 deletions

5
debian/qgis.install vendored
View File

@ -1,13 +1,12 @@
usr/lib/qgis/plugins/libgeorefplugin.so usr/lib/qgis/plugins/libgeorefplugin.so
usr/lib/qgis/plugins/libgpsimporterplugin.so usr/lib/qgis/plugins/libgpsimporterplugin.so
usr/lib/qgis/plugins/libinterpolationplugin.so usr/lib/qgis/plugins/libinterpolationplugin.so
usr/lib/qgis/plugins/libcoordinatecaptureplugin.so usr/lib/qgis/plugins/libcoordinatecaptureplugin.so
usr/lib/qgis/plugins/liboracleplugin.so usr/lib/qgis/plugins/liboracleplugin.so
usr/lib/qgis/plugins/libevis.so usr/lib/qgis/plugins/libevis.so
usr/lib/qgis/plugins/librasterterrainplugin.so usr/lib/qgis/plugins/librasterterrainplugin.so
usr/lib/qgis/plugins/libspatialqueryplugin.so usr/lib/qgis/plugins/libspatialqueryplugin.so
usr/lib/qgis/plugins/libofflineeditingplugin.so usr/lib/qgis/plugins/libofflineeditingplugin.so
usr/lib/qgis/plugins/libroadgraphplugin.so
usr/lib/qgis/plugins/libtopolplugin.so usr/lib/qgis/plugins/libtopolplugin.so
usr/lib/qgis/plugins/libgeometrycheckerplugin.so usr/lib/qgis/plugins/libgeometrycheckerplugin.so
usr/lib/qgis/qgis_help usr/lib/qgis/qgis_help

View File

@ -389,7 +389,6 @@ tar -C %OSGEO4W_ROOT% -cjf %ARCH%/release/qgis/%PACKAGENAME%/%PACKAGENAME%-%VERS
"apps/%PACKAGENAME%/plugins/offlineeditingplugin.dll" ^ "apps/%PACKAGENAME%/plugins/offlineeditingplugin.dll" ^
"apps/%PACKAGENAME%/plugins/oracleplugin.dll" ^ "apps/%PACKAGENAME%/plugins/oracleplugin.dll" ^
"apps/%PACKAGENAME%/plugins/rasterterrainplugin.dll" ^ "apps/%PACKAGENAME%/plugins/rasterterrainplugin.dll" ^
"apps/%PACKAGENAME%/plugins/roadgraphplugin.dll" ^
"apps/%PACKAGENAME%/plugins/spatialqueryplugin.dll" ^ "apps/%PACKAGENAME%/plugins/spatialqueryplugin.dll" ^
"apps/%PACKAGENAME%/plugins/topolplugin.dll" ^ "apps/%PACKAGENAME%/plugins/topolplugin.dll" ^
"apps/%PACKAGENAME%/plugins/geometrycheckerplugin.dll" ^ "apps/%PACKAGENAME%/plugins/geometrycheckerplugin.dll" ^

View File

@ -18,7 +18,6 @@ WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "interpolationplugin
WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "offlineeditingplugin" "true" WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "offlineeditingplugin" "true"
WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "oracleplugin" "true" WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "oracleplugin" "true"
WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "rasterterrainplugin" "true" WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "rasterterrainplugin" "true"
WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "roadgraphplugin" "true"
WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "spatialqueryplugin" "true" WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "spatialqueryplugin" "true"
WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "topolplugin" "true" WriteRegStr HKEY_CURRENT_USER "Software\QGIS\QGIS3\Plugins" "topolplugin" "true"

View File

@ -12,7 +12,6 @@ ADD_SUBDIRECTORY(raster_terrain_analysis)
ADD_SUBDIRECTORY(coordinate_capture) ADD_SUBDIRECTORY(coordinate_capture)
ADD_SUBDIRECTORY(evis) ADD_SUBDIRECTORY(evis)
ADD_SUBDIRECTORY(spatialquery) ADD_SUBDIRECTORY(spatialquery)
ADD_SUBDIRECTORY(roadgraph)
ADD_SUBDIRECTORY(georeferencer) ADD_SUBDIRECTORY(georeferencer)
ADD_SUBDIRECTORY(gps_importer) ADD_SUBDIRECTORY(gps_importer)
ADD_SUBDIRECTORY(topology) ADD_SUBDIRECTORY(topology)

View File

@ -1,62 +0,0 @@
########################################################
# Files
SET (VRP_SRCS
roadgraphplugin.cpp
settingsdlg.cpp
units.cpp
shortestpathwidget.cpp
linevectorlayersettings.cpp
linevectorlayerwidget.cpp
exportdlg.cpp
)
#SET ([pluginlcasename]_UIS [pluginlcasename]guibase.ui)
SET (VRP_MOC_HDRS
roadgraphplugin.h
settingsdlg.h
shortestpathwidget.h
linevectorlayerwidget.h
exportdlg.h
)
SET (VRP_RCCS roadgraph.qrc)
INCLUDE_DIRECTORIES(SYSTEM
${GEOS_INCLUDE_DIR}
)
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_BINARY_DIR}
../../core
../../core/geometry
../../gui
../../analysis/network
..
)
########################################################
# Build
QT5_WRAP_CPP (VRP_MOC_SRCS ${VRP_MOC_HDRS})
QT5_ADD_RESOURCES(VRP_RCC_SRCS ${VRP_RCCS})
ADD_LIBRARY (roadgraphplugin MODULE ${VRP_SRCS} ${VRP_MOC_SRCS} ${VRP_RCC_SRCS})
TARGET_LINK_LIBRARIES(roadgraphplugin
qgis_core
qgis_gui
qgis_analysis
)
########################################################
# Install
INSTALL(TARGETS roadgraphplugin
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR}
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR})

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -1,117 +0,0 @@
/***************************************************************************
* Copyright (C) 2010 by Sergey Yakushev *
* yakushevs@list.ru *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "exportdlg.h"
#include <qgscontexthelp.h>
//qt includes
#include <qlabel.h>
#include <qcombobox.h>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QUuid>
#include <qdialogbuttonbox.h>
#include <qmessagebox.h>
// Qgis includes
#include <qgsvectorlayer.h>
#include <qgsproject.h>
#include <qgsproviderregistry.h>
#include <qgsvectordataprovider.h>
//standard includes
RgExportDlg::RgExportDlg( QWidget* parent, Qt::WindowFlags fl )
: QDialog( parent, fl )
{
// create base widgets;
setWindowTitle( tr( "Export feature" ) );
QVBoxLayout *v = new QVBoxLayout( this );
QHBoxLayout *h = new QHBoxLayout();
QLabel *l = new QLabel( tr( "Select destination layer" ), this );
h->addWidget( l );
mcbLayers = new QComboBox( this );
h->addWidget( mcbLayers );
v->addLayout( h );
QDialogButtonBox *bb = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this );
connect( bb, SIGNAL( accepted() ), this, SLOT( on_buttonBox_accepted() ) );
connect( bb, SIGNAL( rejected() ), this, SLOT( on_buttonBox_rejected() ) );
v->addWidget( bb );
//fill list of layers
mcbLayers->insertItem( 0, tr( "New temporary layer" ), QVariant( "-1" ) );
QMap<QString, QgsMapLayer*> mapLayers = QgsProject::instance()->mapLayers();
QMap<QString, QgsMapLayer*>::iterator layer_it = mapLayers.begin();
for ( ; layer_it != mapLayers.end(); ++layer_it )
{
QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( layer_it.value() );
if ( !vl )
continue;
if ( vl->geometryType() != QgsWkbTypes::LineGeometry )
continue;
mcbLayers->insertItem( 0, vl->name(), QVariant( vl->id() ) );
}
} // RgSettingsDlg::RgSettingsDlg()
RgExportDlg::~RgExportDlg()
{
}
QgsVectorLayer* RgExportDlg::mapLayer() const
{
QgsVectorLayer* myLayer = nullptr;
QString layerId = mcbLayers->currentData().toString();
if ( layerId == QLatin1String( "-1" ) )
{
// create a temporary layer
myLayer = new QgsVectorLayer( QStringLiteral( "LineString?crs=epsg:4326&memoryid=%1" ).arg( QUuid::createUuid().toString() ), QStringLiteral( "shortest path" ), QStringLiteral( "memory" ) );
QgsVectorDataProvider *prov = myLayer->dataProvider();
if ( !prov )
return nullptr;
QList<QgsField> attrList;
attrList.append( QgsField( QStringLiteral( "length" ), QVariant::Double, QLatin1String( "" ), 20, 8 ) );
attrList.append( QgsField( QStringLiteral( "time" ), QVariant::Double, QLatin1String( "" ), 20, 8 ) );
prov->addAttributes( attrList );
myLayer->updateFields();
QList<QgsMapLayer *> myList;
myList << myLayer;
QgsProject::instance()->addMapLayers( myList );
}
else
{
// return selected layer
myLayer = dynamic_cast<QgsVectorLayer*>( QgsProject::instance()->mapLayer( layerId ) );
}
return myLayer;
} // QgsVectorLayer* RgExportDlg::vectorLayer() const
void RgExportDlg::on_buttonBox_accepted()
{
accept();
} // void RgExportDlg::on_buttonBox_accepted()
void RgExportDlg::on_buttonBox_rejected()
{
reject();
}
void RgExportDlg::on_buttonBox_helpRequested()
{
QgsContextHelp::run( metaObject()->className() );
}

View File

@ -1,54 +0,0 @@
/***************************************************************************
exportdlg.h
--------------------------------------
Date : 2010-11-29
Copyright : (C) 2010 by Yakushev Sergey
Email : YakushevS <at> list.ru
****************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef ROADGRAPH_EXPORTDLG_H
#define ROADGRAPH_EXPORTDLG_H
#include <QDialog>
// forward declaration QT-classes
class QComboBox;
// forward declaration Qgis-classes
//forward declaration RoadGraph plugins classes
class QgsVectorLayer;
/**
@author Sergey Yakushev
*/
/**
* \class RgSettingsDlg
* \brief implement of export dialog
*/
class RgExportDlg : public QDialog
{
Q_OBJECT
public:
RgExportDlg( QWidget* parent = nullptr, Qt::WindowFlags fl = 0 );
~RgExportDlg();
public:
QgsVectorLayer* mapLayer() const;
private slots:
void on_buttonBox_accepted();
void on_buttonBox_rejected();
void on_buttonBox_helpRequested();
private:
QComboBox *mcbLayers;
};
#endif

View File

@ -1,130 +0,0 @@
/***************************************************************************
* Copyright (C) 2009 by Sergey Yakushev *
* yakushevs <at> list.ru *
* *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
/**
* \file linevectorlayersettings.cpp
* \brief implementation of RgLineVectorLayerSettings
*/
#include "linevectorlayersettings.h"
#include "linevectorlayerwidget.h"
// Qgis includes
#include <qgsproject.h>
#include "qgsmaplayercombobox.h"
// QT includes
#include <QLineEdit>
#include <QComboBox>
#include <QSpinBox>
//standard includes
RgLineVectorLayerSettings::RgLineVectorLayerSettings()
: mDefaultDirection( QgsVectorLayerDirector::Direction::DirectionBoth )
, mDefaultSpeed( 40 )
{
}
RgLineVectorLayerSettings::~RgLineVectorLayerSettings()
{
}
bool RgLineVectorLayerSettings::test()
{
// implement me
// check default speed
if ( mDefaultSpeed <= 0.0 )
{
return false;
}
if ( mLayerName.isEmpty() )
{
return false;
}
// implement me
return true;
} // RgLineVectorLayerSettings::test()
void RgLineVectorLayerSettings::read( const QgsProject *project )
{
mDefaultDirection = static_cast<QgsVectorLayerDirector::Direction>( project->readNumEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/defaultDirection" ) ) );
mDirection = project->readEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/directionField" ) );
mFirstPointToLastPointDirectionVal =
project->readEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/FirstPointToLastPointDirectionVal" ) );
mLastPointToFirstPointDirectionVal =
project->readEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/LastPointToFirstPointDirectionVal" ) );
mBothDirectionVal = project->readEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/BothDirectionVal" ) );
mSpeed = project->readEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/speedField" ) );
mDefaultSpeed = project->readDoubleEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/defaultSpeed" ) );
mLayerName = project->readEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/layer" ) );
mSpeedUnitName = project->readEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/speedUnitName" ) );
} // RgLineVectorLayerSettings::read( const QgsProject *project )
void RgLineVectorLayerSettings::write( QgsProject *project )
{
project->writeEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/defaultDirection" ), mDefaultDirection );
project->writeEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/directionField" ), mDirection );
project->writeEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/FirstPointToLastPointDirectionVal" ),
mFirstPointToLastPointDirectionVal );
project->writeEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/LastPointToFirstPointDirectionVal" ),
mLastPointToFirstPointDirectionVal );
project->writeEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/BothDirectionVal" ), mBothDirectionVal );
project->writeEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/speedField" ), mSpeed );
project->writeEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/defaultSpeed" ), mDefaultSpeed );
project->writeEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/layer" ), mLayerName );
project->writeEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/speedUnitName" ), mSpeedUnitName );
} // RgLineVectorLayerSettings::write( QgsProject *project )
QWidget* RgLineVectorLayerSettings::getGui( QWidget *parent )
{
return new RgLineVectorLayerSettingsWidget( this, parent );
}
void RgLineVectorLayerSettings::setFromGui( QWidget *myGui )
{
RgLineVectorLayerSettingsWidget* w = dynamic_cast<RgLineVectorLayerSettingsWidget*>( myGui );
if ( !w )
return;
mFirstPointToLastPointDirectionVal = w->mleFirstPointToLastPointDirection->text();
mLastPointToFirstPointDirectionVal = w->mleLastPointToFirstPointDirection->text();
mBothDirectionVal = w->mleBothDirection->text();
mDirection = w->mcbDirection->currentText();
mLayerName = w->mcbLayers->currentText();
if ( w->mcbDirectionDefault->currentIndex() == 0 )
{
mDefaultDirection = QgsVectorLayerDirector::Direction::DirectionBoth;
}
else if ( w->mcbDirectionDefault->currentIndex() == 1 )
{
mDefaultDirection = QgsVectorLayerDirector::Direction::DirectionForward;
}
else if ( w->mcbDirectionDefault->currentIndex() == 2 )
{
mDefaultDirection = QgsVectorLayerDirector::Direction::DirectionBackward;
}
mSpeed = w->mcbSpeed->currentText();
mDefaultSpeed = w->msbSpeedDefault->value();
if ( w->mcbUnitOfSpeed->currentIndex() == 0 )
{
mSpeedUnitName = QStringLiteral( "m/s" );
}
else if ( w->mcbUnitOfSpeed->currentIndex() == 1 )
{
mSpeedUnitName = QStringLiteral( "km/h" );
}
}

View File

@ -1,115 +0,0 @@
/***************************************************************************
* Copyright (C) 2010 by Sergey Yakushev *
* yakushevs <at> list.ru *
* *
* This is file define Road graph plugins settings *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef ROADGRAPH_LINEVECTOR_SETTINGS
#define ROADGRAPH_LINEVECTOR_SETTINGS
#include "settings.h"
// QT includes
#include <qstring.h>
#include <qgsvectorlayerdirector.h>
// Qgis includes
// standard includes
// forward declaration Qgis-classes
class QWidget;
/**
@author Sergey Yakushev
*/
/**
* \class RgSettings
* \brief This class contained settings for RgLineVectorLayerDirector
*/
class RgLineVectorLayerSettings: public RgSettings
{
public:
/**
* \enum DirectionType
* \brief DirectionType enumeration discribe
*/
enum DirectionType { FirstPointToLastPoint = 1, LastPointToFirstPoint = 2, Both = 3 };
public:
/**
* default constructor.
*/
RgLineVectorLayerSettings();
/**
* destructor
*/
~RgLineVectorLayerSettings();
public:
/*
* MANDATORY SETTINGS PROPERTY DECLARATIONS
*/
void write( QgsProject * ) override;
void read( const QgsProject * ) override;
bool test() override;
QWidget *getGui( QWidget* Parent ) override;
void setFromGui( QWidget* ) override;
public:
/**
* contained Layer name
*/
QString mLayerName;
/**
* contained direction field name
*/
QString mDirection;
/**
* mDirection field value as first point to last point value
*/
QString mFirstPointToLastPointDirectionVal;
/**
* mDirection field value as last point to first point value
*/
QString mLastPointToFirstPointDirectionVal;
/**
* mDirection field value as both direction
*/
QString mBothDirectionVal;
/**
* contained Default direction
*/
QgsVectorLayerDirector::Direction mDefaultDirection;
/**
* contained speed filed name
*/
QString mSpeed;
/**
* сontained default speed value;
*/
double mDefaultSpeed;
/*
* name of speed unit
*/
QString mSpeedUnitName;
};
#endif

View File

@ -1,194 +0,0 @@
/***************************************************************************
* Copyright (C) 2010 by Sergey Yakushev *
* yakushevs@list.ru *
* *
* This is a plugin generated from the QGIS plugin template *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "linevectorlayerwidget.h"
#include "linevectorlayersettings.h"
//qt includes
#include <qgscontexthelp.h>
#include <qlabel.h>
#include <qcombobox.h>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <qdialogbuttonbox.h>
#include <qtabwidget.h>
#include <qspinbox.h>
#include <qmessagebox.h>
#include <qlineedit.h>
// Qgis includes
#include "qgsfields.h"
#include "qgsvectorlayer.h"
#include "qgsmaplayercombobox.h"
//standard includes
RgLineVectorLayerSettingsWidget::RgLineVectorLayerSettingsWidget( RgLineVectorLayerSettings *s, QWidget* parent )
: QWidget( parent )
{
// create base widgets;
QTabWidget *tab = new QTabWidget( this );
QVBoxLayout *v = new QVBoxLayout( this );
v->addWidget( tab );
// transportation layer
QFrame *frame = new QFrame( this );
tab->addTab( frame, tr( "Transportation layer" ) );
v = new QVBoxLayout( frame );
QLabel *l = new QLabel( tr( "Layer" ), frame );
mcbLayers = new QgsMapLayerComboBox( frame );
mcbLayers->setFilters( QgsMapLayerProxyModel::LineLayer );
QHBoxLayout *h = new QHBoxLayout();
h->addWidget( l );
h->addWidget( mcbLayers );
v->addLayout( h );
h = new QHBoxLayout();
l = new QLabel( tr( "Direction field" ), frame );
mcbDirection = new QComboBox( frame );
h->addWidget( l );
h->addWidget( mcbDirection );
v->addLayout( h );
h = new QHBoxLayout();
h->addWidget( new QLabel( tr( "Value for forward direction" ), frame ) );
mleFirstPointToLastPointDirection = new QLineEdit( s->mFirstPointToLastPointDirectionVal, frame );
h->addWidget( mleFirstPointToLastPointDirection );
v->addLayout( h );
h = new QHBoxLayout();
h->addWidget( new QLabel( tr( "Value for reverse direction" ), frame ) );
mleLastPointToFirstPointDirection = new QLineEdit( s->mLastPointToFirstPointDirectionVal, frame );
h->addWidget( mleLastPointToFirstPointDirection );
v->addLayout( h );
h = new QHBoxLayout();
h->addWidget( new QLabel( tr( "Value two-way direction" ), frame ) );
mleBothDirection = new QLineEdit( s->mBothDirectionVal, frame );
h->addWidget( mleBothDirection );
v->addLayout( h );
h = new QHBoxLayout();
l = new QLabel( tr( "Speed field" ), frame );
mcbSpeed = new QComboBox( frame );
h->addWidget( l );
h->addWidget( mcbSpeed );
mcbUnitOfSpeed = new QComboBox( this );
h->addWidget( mcbUnitOfSpeed );
mcbUnitOfSpeed->insertItem( 0, tr( "km/h" ) );
mcbUnitOfSpeed->insertItem( 0, tr( "m/s" ) );
v->addLayout( h );
frame = new QFrame( tab );
tab->addTab( frame, tr( "Default settings" ) );
v = new QVBoxLayout( frame );
h = new QHBoxLayout();
l = new QLabel( tr( "Direction" ), frame );
mcbDirectionDefault = new QComboBox( frame );
mcbDirectionDefault->insertItem( 0, tr( "Two-way direction" ) );
mcbDirectionDefault->insertItem( 1, tr( "Forward direction" ) );
mcbDirectionDefault->insertItem( 2, tr( "Reverse direction" ) );
connect( mcbLayers, SIGNAL( currentIndexChanged( int ) ), this, SLOT( on_mcbLayers_selectItem() ) );
h->addWidget( l );
h->addWidget( mcbDirectionDefault );
v->addLayout( h );
h = new QHBoxLayout();
l = new QLabel( tr( "Cost" ), frame );
h->addWidget( l );
l = new QLabel( tr( "Line lengths" ), frame );
h->addWidget( l );
v->addLayout( h );
h = new QHBoxLayout();
l = new QLabel( tr( "Speed" ), frame );
msbSpeedDefault = new QSpinBox( frame );
msbSpeedDefault->setMinimum( 1 );
msbSpeedDefault->setMaximum( 10000000 );
h->addWidget( l );
h->addWidget( msbSpeedDefault );
v->addLayout( h );
//sets current settings
msbSpeedDefault->setValue( static_cast<int>( s->mDefaultSpeed ) );
int idx = mcbLayers->findText( s->mLayerName );
if ( idx != -1 )
{
mcbLayers->setCurrentIndex( idx );
}
on_mcbLayers_selectItem();
idx = mcbDirection->findText( s->mDirection );
if ( idx != -1 )
mcbDirection->setCurrentIndex( idx );
idx = mcbSpeed->findText( s->mSpeed );
if ( idx != -1 )
mcbSpeed->setCurrentIndex( idx );
switch ( s->mDefaultDirection )
{
case QgsVectorLayerDirector::Direction::DirectionBoth:
mcbDirectionDefault->setCurrentIndex( 0 );
break;
case QgsVectorLayerDirector::Direction::DirectionForward:
mcbDirectionDefault->setCurrentIndex( 1 );
break;
case QgsVectorLayerDirector::Direction::DirectionBackward:
mcbDirectionDefault->setCurrentIndex( 2 );
break;
}
if ( s->mSpeedUnitName == QLatin1String( "km/h" ) )
mcbUnitOfSpeed->setCurrentIndex( 1 );
else if ( s->mSpeedUnitName == QLatin1String( "m/s" ) )
mcbUnitOfSpeed->setCurrentIndex( 0 );
}
QgsVectorLayer* RgLineVectorLayerSettingsWidget::selectedLayer()
{
return dynamic_cast< QgsVectorLayer* >( mcbLayers->currentLayer() );
}
void RgLineVectorLayerSettingsWidget::on_mcbLayers_selectItem()
{
mcbDirection->clear();
mcbSpeed->clear();
mcbDirection->insertItem( 0, tr( "Always use default" ) );
mcbSpeed->insertItem( 0, tr( "Always use default" ) );
QgsVectorLayer* vl = selectedLayer();
if ( !vl )
return;
Q_FOREACH ( const QgsField& currentField, vl->fields() )
{
QVariant currentType = currentField.type();
if ( currentType == QVariant::Int || currentType == QVariant::LongLong ||
currentType == QVariant::String )
{
mcbDirection->insertItem( 1, currentField.name() );
}
if ( currentType == QVariant::Int || currentType == QVariant::LongLong ||
currentType == QVariant::Double )
{
mcbSpeed->insertItem( 1, currentField.name() );
}
}
}

View File

@ -1,100 +0,0 @@
/***************************************************************************
roadgraphplugin.h
--------------------------------------
Date : 2010-10-19
Copyright : (C) 2010 by Yakushev Sergey
Email : YakushevS@list.ru
****************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef ROADGRAPH_LINEVECTORLAYERSETTINGSWIDGET_H
#define ROADGRAPH_LINEVECTORLAYERSETTINGSWIDGET_H
#include <QWidget>
class RgLineVectorLayerSettings;
// forward declaration QT-classes
class QComboBox;
class QLineEdit;
class QSpinBox;
class QLineEdit;
// forward declaration Qgis-classes
class QgsVectorLayer;
class QgsMapLayerComboBox;
/**
@author Sergey Yakushev
*/
/**
* \class RgLineVectorLayerSettingsWidget
* \brief
*/
class RgLineVectorLayerSettingsWidget : public QWidget
{
Q_OBJECT
public:
RgLineVectorLayerSettingsWidget( RgLineVectorLayerSettings *s, QWidget* parent = nullptr );
private slots:
void on_mcbLayers_selectItem();
private:
QgsVectorLayer * selectedLayer();
public:
/**
* list of passible layers
*/
QgsMapLayerComboBox *mcbLayers;
/**
* list of possible fields for use as direction
*/
QComboBox *mcbDirection;
/**
*
*/
QLineEdit *mleFirstPointToLastPointDirection;
/**
*
*/
QLineEdit *mleLastPointToFirstPointDirection;
/**
*
*/
QLineEdit *mleBothDirection;
/**
* default direction value
*/
QComboBox *mcbDirectionDefault;
/**
* list of possible fields for use as speed
*/
QComboBox *mcbSpeed;
/**
* Default speed value
*/
QSpinBox *msbSpeedDefault;
/**
* Unit of speed
*/
QComboBox *mcbUnitOfSpeed;
};
#endif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,8 +0,0 @@
<RCC>
<qresource prefix="/roadgraph/" >
<file>road-fast.png</file>
<file>showdirect.png</file>
<file>about.png</file>
<file>coordinate_capture.png</file>
</qresource>
</RCC>

View File

@ -1,304 +0,0 @@
/***************************************************************************
roadgraphplugin.cpp - implemention of plugin
--------------------------------------
Date : 2010-10-10
Copyright : (C) 2010 by Yakushev Sergey
Email : YakushevS <at> list.ru
****************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
// QGIS Specific includes
#include <qgsapplication.h>
#include <qgisinterface.h>
#include <qgisgui.h>
#include <qgsmapcanvas.h>
#include <qgsproject.h>
#include <qgsmaptoolemitpoint.h>
#include <qgsvectorlayer.h>
#include <qgsvectordataprovider.h>
#include <qgsvectorlayerdirector.h>
#include <qgsgraphbuilder.h>
#include <qgsgraph.h>
#include <qgsnetworkdistancestrategy.h>
#include <qgsnetworkspeedstrategy.h>
#include "qgsdockwidget.h"
// Road grap plugin includes
#include "roadgraphplugin.h"
#include "shortestpathwidget.h"
#include "settingsdlg.h"
#include "units.h"
#include "linevectorlayersettings.h"
//
// Qt4 Related Includes
//
#include <QAction>
#include <QLabel>
#include <QLocale>
#include <QToolBar>
#include <QPushButton>
#include <QVBoxLayout>
#include <QDebug>
// standard includes
static const QString sName = QObject::tr( "Road graph plugin" );
static const QString sDescription = QObject::tr( "Solves the shortest path problem by tracing along line layers." );
static const QString sCategory = QObject::tr( "Vector" );
static const QString sPluginVersion = QObject::tr( "Version 0.1" );
static const QString sPluginIcon = QStringLiteral( ":/roadgraph/road-fast.png" );
static const QgisPlugin::PLUGINTYPE sPluginType = QgisPlugin::UI;
//////////////////////////////////////////////////////////////////////
//
// THE FOLLOWING METHODS ARE MANDATORY FOR ALL PLUGINS
//
//////////////////////////////////////////////////////////////////////
/**
* Constructor for the plugin. The plugin is passed a pointer
* an interface object that provides access to exposed functions in QGIS.
* @param theQgisInterface - Pointer to the QGIS interface object
*/
RoadGraphPlugin::RoadGraphPlugin( QgisInterface * theQgisInterface )
: QgisPlugin( sName, sDescription, sCategory, sPluginVersion, sPluginType )
, mQGisIface( theQgisInterface )
, mQSettingsAction( nullptr )
, mQShortestPathDock( nullptr )
{
mSettings = new RgLineVectorLayerSettings();
mTimeUnitName = QStringLiteral( "h" );
mDistanceUnitName = QStringLiteral( "km" );
mTopologyToleranceFactor = 0.0;
}
RoadGraphPlugin::~RoadGraphPlugin()
{
}
/*
* Initialize the GUI interface for the plugin - this is only called once when the plugin is
* added to the plugin registry in the QGIS application.
*/
void RoadGraphPlugin::initGui()
{
// create shorttest path dock
mQShortestPathDock = new RgShortestPathWidget( mQGisIface->mainWindow(), this );
mQGisIface->addDockWidget( Qt::LeftDockWidgetArea, mQShortestPathDock );
// Create the action for tool
mQSettingsAction = new QAction( QIcon( ":/roadgraph/road.png" ), tr( "Settings..." ), this );
mQSettingsAction->setObjectName( QStringLiteral( "mQSettingsAction" ) );
// Set the what's this text
mQSettingsAction->setWhatsThis( tr( "Road graph plugin settings" ) );
setGuiElementsToDefault();
// Connect the action to slots
connect( mQSettingsAction, SIGNAL( triggered() ), this, SLOT( property() ) );
mQGisIface->addPluginToVectorMenu( tr( "Road Graph" ), mQSettingsAction );
connect( mQGisIface, SIGNAL( projectRead() ), this, SLOT( projectRead() ) );
connect( mQGisIface, SIGNAL( newProjectCreated() ), this, SLOT( newProject() ) );
connect( mQGisIface, SIGNAL( projectRead() ), mQShortestPathDock, SLOT( clear() ) );
connect( mQGisIface, SIGNAL( newProjectCreated() ), mQShortestPathDock, SLOT( clear() ) );
// load settings
projectRead();
}
// Unload the plugin by cleaning up the GUI
void RoadGraphPlugin::unload()
{
// remove the GUI
mQGisIface->removePluginVectorMenu( tr( "Road Graph" ), mQSettingsAction );
// disconnect
disconnect( mQGisIface->mainWindow(), SIGNAL( projectRead() ), this, SLOT( projectRead() ) );
disconnect( mQGisIface->mainWindow(), SIGNAL( newProject() ), this, SLOT( newProject() ) );
delete mQSettingsAction;
delete mQShortestPathDock;
}
void RoadGraphPlugin::setGuiElementsToDefault()
{
}
//method defined in interface
void RoadGraphPlugin::help()
{
//implement me!
}
void RoadGraphPlugin::onShowDirection()
{
mQGisIface->mapCanvas()->refresh();
}
void RoadGraphPlugin::newProject()
{
setGuiElementsToDefault();
}
void RoadGraphPlugin::property()
{
RgSettingsDlg dlg( mSettings, mQGisIface->mainWindow(), QgisGui::ModalDialogFlags );
dlg.setTimeUnitName( mTimeUnitName );
dlg.setDistanceUnitName( mDistanceUnitName );
dlg.setTopologyTolerance( mTopologyToleranceFactor );
if ( !dlg.exec() )
return;
mTimeUnitName = dlg.timeUnitName();
mDistanceUnitName = dlg.distanceUnitName();
mTopologyToleranceFactor = dlg.topologyTolerance();
mSettings->write( QgsProject::instance() );
QgsProject::instance()->writeEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/pluginTimeUnit" ), mTimeUnitName );
QgsProject::instance()->writeEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/pluginDistanceUnit" ), mDistanceUnitName );
QgsProject::instance()->writeEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/topologyToleranceFactor" ), mTopologyToleranceFactor );
setGuiElementsToDefault();
}
void RoadGraphPlugin::projectRead()
{
mSettings->read( QgsProject::instance() );
mTimeUnitName = QgsProject::instance()->readEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/pluginTimeUnit" ), QStringLiteral( "h" ) );
mDistanceUnitName = QgsProject::instance()->readEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/pluginDistanceUnit" ), QStringLiteral( "km" ) );
mTopologyToleranceFactor =
QgsProject::instance()->readDoubleEntry( QStringLiteral( "roadgraphplugin" ), QStringLiteral( "/topologyToleranceFactor" ), 0.0 );
setGuiElementsToDefault();
}
QgisInterface* RoadGraphPlugin::iface()
{
return mQGisIface;
}
const QgsGraphDirector* RoadGraphPlugin::director() const
{
QList< QgsMapLayer* > mapLayers = QgsProject::instance()->mapLayersByName( mSettings->mLayerName );
if ( mapLayers.isEmpty() )
return nullptr;
QgsVectorLayer *layer = dynamic_cast< QgsVectorLayer* >( mapLayers.at( 0 ) );
if ( !layer )
return nullptr;
if ( layer->wkbType() == QgsWkbTypes::LineString
|| layer->wkbType() == QgsWkbTypes::MultiLineString )
{
SpeedUnit speedUnit = SpeedUnit::byName( mSettings->mSpeedUnitName );
QgsVectorLayerDirector * director =
new QgsVectorLayerDirector( layer,
layer->fields().lookupField( mSettings->mDirection ),
mSettings->mFirstPointToLastPointDirectionVal,
mSettings->mLastPointToFirstPointDirectionVal,
mSettings->mBothDirectionVal,
mSettings->mDefaultDirection
);
director->addStrategy( new QgsNetworkDistanceStrategy() );
director->addStrategy( new QgsNetworkSpeedStrategy( layer->fields().lookupField( mSettings->mSpeed ),
mSettings->mDefaultSpeed, speedUnit.multipler() ) );
return director;
}
return nullptr;
}
QString RoadGraphPlugin::timeUnitName()
{
return mTimeUnitName;
}
QString RoadGraphPlugin::distanceUnitName()
{
return mDistanceUnitName;
}
double RoadGraphPlugin::topologyToleranceFactor()
{
return mTopologyToleranceFactor;
}
//////////////////////////////////////////////////////////////////////////
//
//
// THE FOLLOWING CODE IS AUTOGENERATED BY THE PLUGIN BUILDER SCRIPT
// YOU WOULD NORMALLY NOT NEED TO MODIFY THIS, AND YOUR PLUGIN
// MAY NOT WORK PROPERLY IF YOU MODIFY THIS INCORRECTLY
//
//
//////////////////////////////////////////////////////////////////////////
/**
* Required extern functions needed for every plugin
* These functions can be called prior to creating an instance
* of the plugin class
*/
// Class factory to return a new instance of the plugin class
QGISEXTERN QgisPlugin * classFactory( QgisInterface * theQgisInterfacePointer )
{
return new RoadGraphPlugin( theQgisInterfacePointer );
}
// Return the name of the plugin - note that we do not user class members as
// the class may not yet be insantiated when this method is called.
QGISEXTERN QString name()
{
return sName;
}
// Return the description
QGISEXTERN QString description()
{
return sDescription;
}
// Return the category
QGISEXTERN QString category()
{
return sCategory;
}
QGISEXTERN QString icon()
{
return sPluginIcon;
}
// Return the type (either UI or MapLayer plugin)
QGISEXTERN int type()
{
return sPluginType;
}
// Return the version number for the plugin
QGISEXTERN QString version()
{
return sPluginVersion;
}
// Delete ourself
QGISEXTERN void unload( QgisPlugin * thePluginPointer )
{
delete thePluginPointer;
}

View File

@ -1,163 +0,0 @@
/***************************************************************************
roadgraphplugin.h
--------------------------------------
Date : 2010-10-10
Copyright : (C) 2010 by Yakushev Sergey
Email : YakushevS <at> list.ru
****************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef ROADGRAPHPLUGIN
#define ROADGRAPHPLUGIN
//QT4 includes
#include <QObject>
//QGIS includes
#include <qgisplugin.h>
#include <qgspoint.h>
//forward declarations
class QAction;
class QToolBar;
class QPainter;
class QgisInterface;
class QgsDockWidget;
//forward declarations RoadGraph plugins classes
class QgsGraphDirector;
class RgShortestPathWidget;
class RgLineVectorLayerSettings;
/**
* \class RoadGraphPlugin
* \brief Road graph plugin for QGIS
* This plugin can solve the shotrest path problem and etc...
*/
class RoadGraphPlugin: public QObject, public QgisPlugin
{
Q_OBJECT
public:
/**
* Constructor for a plugin. The QgisInterface pointer is passed by
* QGIS when it attempts to instantiate the plugin.
* @param theQgisInterface Pointer to the QgisInterface object.
*/
explicit RoadGraphPlugin( QgisInterface * theQgisInterface );
//! Destructor
virtual ~RoadGraphPlugin();
/**
* return pointer to my Interface
*/
QgisInterface *iface();
/**
* return pointer to graph director
*/
const QgsGraphDirector* director() const;
/**
* get time unit name
*/
QString timeUnitName();
/**
* get distance unit name
*/
QString distanceUnitName();
/**
* get topology tolerance factor
*/
double topologyToleranceFactor();
public slots:
//! init the gui
virtual void initGui() override;
//!set values onthe gui when a project is read or the gui first loaded
virtual void projectRead();
//!set default values for new project
void newProject();
//! Show the property dialog box
void property();
//! unload the plugin
void unload() override;
//! show the help document
void help();
private slots:
/**
* set show roads direction
*/
void onShowDirection();
private:
/**
* set all gui elements to default status
*/
void setGuiElementsToDefault();
private:
////////////////////////////////////////////////////////////////////
//
// MANDATORY PLUGIN PROPERTY DECLARATIONS .....
//
////////////////////////////////////////////////////////////////////
//! Pointer to the QGIS interface object
QgisInterface *mQGisIface;
////////////////////////////////////////////////////////////////////
// ADD YOUR OWN PROPERTY DECLARATIONS AFTER THIS POINT.....
//
////////////////////////////////////////////////////////////////////
/**
* on show settings
*/
QAction * mQSettingsAction;
/**
* GUI for use shortest path finder
*/
RgShortestPathWidget *mQShortestPathDock;
/**
* My graph settings.
* @note. Should be used RgSettings
*/
RgLineVectorLayerSettings *mSettings;
/**
* time unit for results presentation
*/
QString mTimeUnitName;
/**
* distance unit for results presentation
*/
QString mDistanceUnitName;
/**
* topology tolerance factor
*/
double mTopologyToleranceFactor;
};
#endif //ROADGRAPHPLUGIN

View File

@ -1,63 +0,0 @@
/***************************************************************************
settings.h
--------------------------------------
Date : 2010-10-18
Copyright : (C) 2010 by Yakushev Sergey
Email : YakushevS <at> list.ru
****************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef ROADGRAPH_SETTINGS
#define ROADGRAPH_SETTINGS
//QT4 includes
//QGIS includes
//forward declarations
class QWidget;
class QgsProject;
/**
* \class RgGraphDirector
* \brief Determine making the graph
* contained the settings
*/
class RgSettings
{
public:
//! Destructor
virtual ~RgSettings() { }
/**
* write settings to the poject file
*/
virtual void write( QgsProject * ) = 0;
/**
* read settings form project file
*/
virtual void read( const QgsProject * ) = 0;
/**
* This function test settings and return true if setting correct
*/
virtual bool test() = 0;
/**
* Make settings widget
* use it for GUI setting
*/
virtual QWidget* getGui( QWidget* parent ) = 0;
/**
* Load settings from widget
*/
virtual void setFromGui( QWidget * ) = 0;
};
#endif //ROADGRAPH_SETTIGNS

View File

@ -1,132 +0,0 @@
/***************************************************************************
* Copyright (C) 2010 by Sergey Yakushev *
* yakushevs <at> list.ru *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
//road-graph plugin includes
#include "settingsdlg.h"
#include <qgscontexthelp.h>
//qt includes
#include <qlabel.h>
#include <qcombobox.h>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <qdialogbuttonbox.h>
#include <qmessagebox.h>
#include <QDoubleSpinBox>
// Qgis includes
#include "settings.h"
//standard includes
RgSettingsDlg::RgSettingsDlg( RgSettings *settings, QWidget* parent, Qt::WindowFlags fl )
: QDialog( parent, fl )
, mSettings( settings )
{
// create base widgets;
setWindowTitle( tr( "Road graph plugin settings" ) );
QVBoxLayout *v = new QVBoxLayout( this );
QHBoxLayout *h = new QHBoxLayout();
QLabel *l = new QLabel( tr( "Time unit" ), this );
h->addWidget( l );
mcbPluginsTimeUnit = new QComboBox( this );
h->addWidget( mcbPluginsTimeUnit );
v->addLayout( h );
h = new QHBoxLayout();
l = new QLabel( tr( "Distance unit" ), this );
h->addWidget( l );
mcbPluginsDistanceUnit = new QComboBox( this );
h->addWidget( mcbPluginsDistanceUnit );
v->addLayout( h );
h = new QHBoxLayout();
l = new QLabel( tr( "Topology tolerance" ), this );
h->addWidget( l );
msbTopologyTolerance = new QDoubleSpinBox( this );
msbTopologyTolerance->setMinimum( 0.0 );
msbTopologyTolerance->setDecimals( 5 );
h->addWidget( msbTopologyTolerance );
v->addLayout( h );
mSettingsWidget = mSettings->getGui( this );
v->addWidget( mSettingsWidget );
QDialogButtonBox *bb = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help, Qt::Horizontal, this );
connect( bb, SIGNAL( accepted() ), this, SLOT( on_buttonBox_accepted() ) );
connect( bb, SIGNAL( rejected() ), this, SLOT( on_buttonBox_rejected() ) );
connect( bb, SIGNAL( helpRequested() ), this, SLOT( on_buttonBox_helpRequested() ) );
v->addWidget( bb );
mcbPluginsTimeUnit->addItem( tr( "second" ), QVariant( "s" ) );
mcbPluginsTimeUnit->addItem( tr( "hour" ), QVariant( "h" ) );
mcbPluginsDistanceUnit->addItem( tr( "meter" ), QVariant( "m" ) );
mcbPluginsDistanceUnit->addItem( tr( "kilometer" ), QVariant( "km" ) );
} // RgSettingsDlg::RgSettingsDlg()
RgSettingsDlg::~RgSettingsDlg()
{
}
void RgSettingsDlg::on_buttonBox_accepted()
{
mSettings->setFromGui( mSettingsWidget );
accept();
}
void RgSettingsDlg::on_buttonBox_rejected()
{
reject();
}
void RgSettingsDlg::on_buttonBox_helpRequested()
{
QgsContextHelp::run( metaObject()->className() );
}
QString RgSettingsDlg::timeUnitName()
{
return mcbPluginsTimeUnit->currentData().toString();
}
void RgSettingsDlg::setTimeUnitName( const QString& name )
{
int i = mcbPluginsTimeUnit->findData( QVariant( name ) );
if ( i != -1 )
{
mcbPluginsTimeUnit->setCurrentIndex( i );
}
}
QString RgSettingsDlg::distanceUnitName()
{
return mcbPluginsDistanceUnit->currentData().toString();
}
void RgSettingsDlg::setDistanceUnitName( const QString& name )
{
int i = mcbPluginsDistanceUnit->findData( QVariant( name ) );
if ( i != -1 )
{
mcbPluginsDistanceUnit->setCurrentIndex( i );
}
}
void RgSettingsDlg::setTopologyTolerance( double f )
{
msbTopologyTolerance->setValue( f );
}
double RgSettingsDlg::topologyTolerance()
{
return msbTopologyTolerance->value();
}

View File

@ -1,87 +0,0 @@
/***************************************************************************
roadgraphplugin.h
--------------------------------------
Date : 2010-10-10
Copyright : (C) 2010 by Yakushev Sergey
Email : YakushevS <at> list.ru
****************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef ROADGRAPH_SETTINGSDLG_H
#define ROADGRAPH_SETTINGSDLG_H
#include <QDialog>
// forward declaration QT-classes
class QComboBox;
class QDoubleSpinBox;
// forward declaration Qgis-classes
//forward declaration RoadGraph plugins classes
class RgSettings;
/**
@author Sergey Yakushev
*/
/**
* \class RgSettingsDlg
* \brief implement of settings dialog
*/
class RgSettingsDlg : public QDialog
{
Q_OBJECT
public:
RgSettingsDlg( RgSettings *settings, QWidget* parent = nullptr, Qt::WindowFlags fl = 0 );
~RgSettingsDlg();
QString timeUnitName();
void setTimeUnitName( const QString& );
QString distanceUnitName();
void setDistanceUnitName( const QString& );
void setTopologyTolerance( double f );
double topologyTolerance();
private:
static const int context_id = 0;
private slots:
void on_buttonBox_accepted();
void on_buttonBox_rejected();
void on_buttonBox_helpRequested();
private:
/**
* current graph settings object
*/
RgSettings *mSettings;
QWidget *mSettingsWidget;
/**
* plugin distance unit
*/
QComboBox *mcbPluginsDistanceUnit;
/**
* plugin time unit
*/
QComboBox *mcbPluginsTimeUnit;
/**
* topology tolerance factor
*/
QDoubleSpinBox *msbTopologyTolerance;
};
#endif

View File

@ -1,447 +0,0 @@
/***************************************************************************
* Copyright (C) 2009 by Sergey Yakushev *
* yakushevs@list.ru *
* *
* This is a plugin generated from the QGIS plugin template *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
/**
* \file shortestpathwidget.cpp
* \brief implemetation UI for find shotest path
*/
//qt includes
#include <qcombobox.h>
#include <qlayout.h>
#include <qpushbutton.h>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <qlabel.h>
#include <qlineedit.h>
#include <QToolButton>
#include <QMessageBox>
#include <qgscontexthelp.h>
// Qgis includes
#include <qgsmapcanvas.h>
#include <qgsmaptoolemitpoint.h>
#include <qgisinterface.h>
#include <qgsrubberband.h>
#include <qgsmaptopixel.h>
#include <qgsfeature.h>
#include <qgsapplication.h>
#include <qgsvectorlayer.h>
#include <qgsvectordataprovider.h>
#include <qgsmessagebar.h>
#include <qgsgraphdirector.h>
#include <qgsgraphbuilder.h>
#include <qgsgraph.h>
#include <qgsgraphanalyzer.h>
// roadgraph plugin includes
#include "roadgraphplugin.h"
#include "shortestpathwidget.h"
#include "exportdlg.h"
#include "units.h"
#include "settings.h"
//standard includes
RgShortestPathWidget::RgShortestPathWidget( QWidget* theParent, RoadGraphPlugin *thePlugin )
: QgsDockWidget( theParent )
, mPlugin( thePlugin )
{
setWindowTitle( tr( "Shortest path" ) );
setObjectName( QStringLiteral( "ShortestPathDock" ) );
setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
QWidget *myWidget = new QWidget( this );
setWidget( myWidget );
QVBoxLayout *v = new QVBoxLayout( myWidget );
v->setMargin( 0 );
v->setContentsMargins( 0, 0, 0, 0 );
QHBoxLayout *h = nullptr;
QLabel *l = nullptr;
l = new QLabel( tr( "Start" ), myWidget );
v->addWidget( l );
h = new QHBoxLayout();
mFrontPointLineEdit = new QLineEdit( myWidget );
mFrontPointLineEdit->setReadOnly( true );
QToolButton *selectFrontPoint = new QToolButton( myWidget );
selectFrontPoint->setCheckable( true );
selectFrontPoint->setIcon( QPixmap( ":/roadgraph/coordinate_capture.png" ) );
h->addWidget( mFrontPointLineEdit );
h->addWidget( selectFrontPoint );
v->addLayout( h );
l = new QLabel( tr( "Stop" ), myWidget );
v->addWidget( l );
h = new QHBoxLayout();
mBackPointLineEdit = new QLineEdit( myWidget );
mBackPointLineEdit->setReadOnly( true );
QToolButton *selectBackPoint = new QToolButton( myWidget );
selectBackPoint->setCheckable( true );
selectBackPoint->setIcon( QPixmap( ":/roadgraph/coordinate_capture.png" ) );
h->addWidget( mBackPointLineEdit );
h->addWidget( selectBackPoint );
v->addLayout( h );
h = new QHBoxLayout();
l = new QLabel( tr( "Criterion" ), myWidget );
mCriterionName = new QComboBox( myWidget );
mCriterionName->insertItem( 0, tr( "Length" ) );
mCriterionName->insertItem( 1, tr( "Time" ) );
h->addWidget( l );
h->addWidget( mCriterionName );
v->addLayout( h );
h = new QHBoxLayout();
l = new QLabel( tr( "Length" ), myWidget );
mPathCostLineEdit = new QLineEdit( myWidget );
mPathCostLineEdit->setReadOnly( true );
h->addWidget( l );
h->addWidget( mPathCostLineEdit );
v->addLayout( h );
h = new QHBoxLayout();
l = new QLabel( tr( "Time" ), myWidget );
mPathTimeLineEdit = new QLineEdit( myWidget );
mPathTimeLineEdit->setReadOnly( true );
h->addWidget( l );
h->addWidget( mPathTimeLineEdit );
v->addLayout( h );
h = new QHBoxLayout();
mCalculate = new QPushButton( tr( "Calculate" ), myWidget );
h->addWidget( mCalculate );
QPushButton *pbExport = new QPushButton( tr( "Export" ), myWidget );
h->addWidget( pbExport );
connect( pbExport, SIGNAL( clicked( bool ) ), this, SLOT( exportPath() ) );
mClear = new QPushButton( tr( "Clear" ), myWidget );
h->addWidget( mClear );
v->addLayout( h );
h = new QHBoxLayout();
QPushButton *helpButton = new QPushButton( tr( "Help" ), this );
helpButton->setIcon( style()->standardIcon( QStyle::SP_DialogHelpButton ) );
h->addWidget( helpButton );
v->addLayout( h );
v->addStretch();
mFrontPointMapTool = new QgsMapToolEmitPoint( mPlugin->iface()->mapCanvas() );
mFrontPointMapTool->setButton( selectFrontPoint );
mBackPointMapTool = new QgsMapToolEmitPoint( mPlugin->iface()->mapCanvas() );
mBackPointMapTool->setButton( selectBackPoint );
connect( selectFrontPoint, SIGNAL( clicked( bool ) ), this, SLOT( onSelectFrontPoint() ) );
connect( mFrontPointMapTool, SIGNAL( canvasClicked( const QgsPoint&, Qt::MouseButton ) ),
this, SLOT( setFrontPoint( const QgsPoint& ) ) );
connect( selectBackPoint, SIGNAL( clicked( bool ) ), this, SLOT( onSelectBackPoint() ) );
connect( mBackPointMapTool, SIGNAL( canvasClicked( const QgsPoint&, Qt::MouseButton ) ),
this, SLOT( setBackPoint( const QgsPoint& ) ) );
connect( helpButton, SIGNAL( clicked( bool ) ), this, SLOT( helpRequested() ) );
connect( mCalculate, SIGNAL( clicked( bool ) ), this, SLOT( findingPath() ) );
connect( mClear, SIGNAL( clicked( bool ) ), this, SLOT( clear() ) );
mrbFrontPoint = new QgsRubberBand( mPlugin->iface()->mapCanvas(), QgsWkbTypes::PolygonGeometry );
mrbFrontPoint->setColor( QColor( 0, 255, 0, 65 ) );
mrbFrontPoint->setWidth( 2 );
mrbBackPoint = new QgsRubberBand( mPlugin->iface()->mapCanvas(), QgsWkbTypes::PolygonGeometry );
mrbBackPoint->setColor( QColor( 255, 0, 0, 65 ) );
mrbBackPoint->setWidth( 2 );
mrbPath = new QgsRubberBand( mPlugin->iface()->mapCanvas(), QgsWkbTypes::LineGeometry );
mrbPath->setWidth( 2 );
connect( mPlugin->iface()->mapCanvas(), SIGNAL( extentsChanged() ), this, SLOT( mapCanvasExtentsChanged() ) );
} //RgShortestPathWidget::RgShortestPathWidget()
RgShortestPathWidget::~RgShortestPathWidget()
{
} //RgShortestPathWidget::~RgShortestPathWidget()
void RgShortestPathWidget::mapCanvasExtentsChanged()
{
// update rubberbands
if ( mFrontPointLineEdit->text().length() > 0 )
setFrontPoint( mFrontPoint );
if ( mBackPointLineEdit->text().length() > 0 )
setBackPoint( mBackPoint );
}
void RgShortestPathWidget::onSelectFrontPoint()
{
mPlugin->iface()->mapCanvas()->setMapTool( mFrontPointMapTool );
}
void RgShortestPathWidget::setFrontPoint( const QgsPoint& pt )
{
mPlugin->iface()->mapCanvas()->unsetMapTool( mFrontPointMapTool );
mFrontPointLineEdit->setText( QStringLiteral( "(%1, %2)" ).arg( QString::number( pt.x(), 'f' ),
QString::number( pt.y(), 'f' ) ) );
mFrontPoint = pt;
double mupp = mPlugin->iface()->mapCanvas()->getCoordinateTransform()->mapUnitsPerPixel() * 2;
mrbFrontPoint->reset( QgsWkbTypes::PolygonGeometry );
mrbFrontPoint->addPoint( QgsPoint( pt.x() - mupp, pt.y() - mupp ), false );
mrbFrontPoint->addPoint( QgsPoint( pt.x() + mupp, pt.y() - mupp ), false );
mrbFrontPoint->addPoint( QgsPoint( pt.x() + mupp, pt.y() + mupp ), false );
mrbFrontPoint->addPoint( QgsPoint( pt.x() - mupp, pt.y() + mupp ), true );
mrbFrontPoint->show();
} //RgShortestPathWidget::setFrontPoint( const QgsPoint& pt )
void RgShortestPathWidget::onSelectBackPoint()
{
mPlugin->iface()->mapCanvas()->setMapTool( mBackPointMapTool );
}
void RgShortestPathWidget::setBackPoint( const QgsPoint& pt )
{
mPlugin->iface()->mapCanvas()->unsetMapTool( mBackPointMapTool );
mBackPoint = pt;
mBackPointLineEdit->setText( QStringLiteral( "(%1, %2)" ).arg( QString::number( pt.x(), 'f' ),
QString::number( pt.y(), 'f' ) ) );
double mupp = mPlugin->iface()->mapCanvas()->getCoordinateTransform()->mapUnitsPerPixel() * 2;
mrbBackPoint->reset( QgsWkbTypes::PolygonGeometry );
mrbBackPoint->addPoint( QgsPoint( pt.x() - mupp, pt.y() - mupp ), false );
mrbBackPoint->addPoint( QgsPoint( pt.x() + mupp, pt.y() - mupp ), false );
mrbBackPoint->addPoint( QgsPoint( pt.x() + mupp, pt.y() + mupp ), false );
mrbBackPoint->addPoint( QgsPoint( pt.x() - mupp, pt.y() + mupp ), true );
mrbBackPoint->show();
}
QgsGraph* RgShortestPathWidget::getPath( QgsPoint& p1, QgsPoint& p2 )
{
if ( mFrontPointLineEdit->text().isNull() || mBackPointLineEdit->text().isNull() )
{
QMessageBox::critical( this, tr( "Point not selected" ), tr( "First, select start and stop points." ) );
return nullptr;
}
QgsGraphBuilder builder(
mPlugin->iface()->mapCanvas()->mapSettings().destinationCrs(),
mPlugin->iface()->mapCanvas()->mapSettings().hasCrsTransformEnabled(),
mPlugin->topologyToleranceFactor() );
{
const QgsGraphDirector *director = mPlugin->director();
if ( !director )
{
QMessageBox::critical( this, tr( "Plugin isn't configured" ), tr( "Plugin isn't configured! Please go to the Vector menu, Road Graph, Settings option to configure it." ) );
return nullptr;
}
connect( director, SIGNAL( buildProgress( int, int ) ), mPlugin->iface()->mainWindow(), SLOT( showProgress( int, int ) ) );
connect( director, SIGNAL( buildMessage( QString ) ), mPlugin->iface()->mainWindow(), SLOT( showStatusMessage( QString ) ) );
QVector< QgsPoint > points;
QVector< QgsPoint > tiedPoint;
points.push_back( mFrontPoint );
points.push_back( mBackPoint );
director->makeGraph( &builder, points, tiedPoint );
p1 = tiedPoint[ 0 ];
p2 = tiedPoint[ 1 ];
// not need
delete director;
}
if ( p1 == QgsPoint( 0.0, 0.0 ) )
{
QMessageBox::critical( this, tr( "Tie point failed" ), tr( "Start point doesn't tie to the road!" ) );
return nullptr;
}
if ( p2 == QgsPoint( 0.0, 0.0 ) )
{
QMessageBox::critical( this, tr( "Tie point failed" ), tr( "Stop point doesn't tie to the road!" ) );
return nullptr;
}
QgsGraph *graph = builder.graph();
int startVertexIdx = graph->findVertex( p1 );
if ( startVertexIdx < 0 )
{
mPlugin->iface()->messageBar()->pushMessage(
tr( "Cannot calculate path" ),
tr( "Could not find start vertex. Please check your input data." ),
QgsMessageBar::WARNING,
mPlugin->iface()->messageTimeout()
);
delete graph;
return nullptr;
}
int criterionNum = 0;
if ( mCriterionName->currentIndex() > 0 )
criterionNum = 1;
if ( graph->vertexCount() == 0 )
{
mPlugin->iface()->messageBar()->pushMessage(
tr( "Cannot calculate path" ),
tr( "The created graph is empty. Please check your input data." ),
QgsMessageBar::WARNING,
mPlugin->iface()->messageTimeout()
);
delete graph;
return nullptr;
}
QgsGraph* shortestpathTree = QgsGraphAnalyzer::shortestTree( graph, startVertexIdx, criterionNum );
delete graph;
if ( shortestpathTree->findVertex( p2 ) == -1 )
{
delete shortestpathTree;
QMessageBox::critical( this, tr( "Path not found" ), tr( "Path not found" ) );
return nullptr;
}
return shortestpathTree;
}
void RgShortestPathWidget::findingPath()
{
QgsPoint p1, p2;
QgsGraph *path = getPath( p1, p2 );
if ( !path )
return;
mrbPath->reset( QgsWkbTypes::LineGeometry );
double time = 0.0;
double cost = 0.0;
int startVertexIdx = path->findVertex( p1 );
int stopVertexIdx = path->findVertex( p2 );
QVector< QgsPoint > p;
while ( startVertexIdx != stopVertexIdx )
{
if ( stopVertexIdx < 0 )
break;
QgsGraphEdgeIds l = path->vertex( stopVertexIdx ).inEdges();
if ( l.empty() )
break;
const QgsGraphEdge& e = path->edge( l.front() );
cost += e.cost( 0 ).toDouble();
time += e.cost( 1 ).toDouble();
p.push_front( path->vertex( e.inVertex() ).point() );
stopVertexIdx = e.outVertex();
}
p.push_front( p1 );
QVector< QgsPoint>::iterator it;
for ( it = p.begin(); it != p.end(); ++it )
{
mrbPath->addPoint( *it );
}
Unit timeUnit = Unit::byName( mPlugin->timeUnitName() );
Unit distanceUnit = Unit::byName( mPlugin->distanceUnitName() );
mPathCostLineEdit->setText( QString().setNum( cost / distanceUnit.multipler() ) + distanceUnit.name() );
mPathTimeLineEdit->setText( QString().setNum( time / timeUnit.multipler() ) + timeUnit.name() );
mrbPath->setColor( Qt::red );
delete path;
}
void RgShortestPathWidget::clear()
{
mFrontPointLineEdit->setText( QString() );
mrbFrontPoint->reset( QgsWkbTypes::PolygonGeometry );
mBackPointLineEdit->setText( QString() );
mrbBackPoint->reset( QgsWkbTypes::PolygonGeometry );
mrbPath->reset( QgsWkbTypes::LineGeometry );
mPathCostLineEdit->setText( QString() );
mPathTimeLineEdit->setText( QString() );
}
void RgShortestPathWidget::exportPath()
{
RgExportDlg dlg( this );
if ( !dlg.exec() )
return;
QgsVectorLayer *vl = dlg.mapLayer();
if ( !vl )
return;
QgsPoint p1, p2;
QgsGraph *path = getPath( p1, p2 );
if ( !path )
return;
QgsCoordinateTransform ct( mPlugin->iface()->mapCanvas()->mapSettings().destinationCrs(),
vl->crs() );
int startVertexIdx = path->findVertex( p1 );
int stopVertexIdx = path->findVertex( p2 );
double time = 0.0;
double cost = 0.0;
Unit timeUnit = Unit::byName( mPlugin->timeUnitName() );
Unit distanceUnit = Unit::byName( mPlugin->distanceUnitName() );
QgsPolyline p;
while ( startVertexIdx != stopVertexIdx )
{
if ( stopVertexIdx < 0 )
break;
QgsGraphEdgeIds l = path->vertex( stopVertexIdx ).inEdges();
if ( l.empty() )
break;
const QgsGraphEdge& e = path->edge( l.front() );
cost += e.cost( 0 ).toDouble();
time += e.cost( 1 ).toDouble();
p.push_front( ct.transform( path->vertex( e.inVertex() ).point() ) );
stopVertexIdx = e.outVertex();
}
p.push_front( ct.transform( p1 ) );
QgsFeature f;
f.initAttributes( vl->fields().count() );
f.setGeometry( QgsGeometry::fromPolyline( p ) );
f.setAttribute( 0, cost / distanceUnit.multipler() );
f.setAttribute( 1, time / timeUnit.multipler() );
QgsFeatureList features;
features << f;
vl->dataProvider()->addFeatures( features );
vl->updateExtents();
mPlugin->iface()->mapCanvas()->update();
delete path;
}
void RgShortestPathWidget::helpRequested()
{
QgsContextHelp::run( metaObject()->className() );
}

View File

@ -1,187 +0,0 @@
/***************************************************************************
* Copyright (C) 2009 by Sergey Yakushev *
* yakushevs<at>list.ru *
* *
* This is file define vrp plugins settings *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef ROADGRAPHPLUGIN_SHORTESTPATHDLG_H
#define ROADGRAPHPLUGIN_SHORTESTPATHDLG_H
// Qgis includes
#include <qgspoint.h>
#include "qgsdockwidget.h"
// standard includes
// forward declaration
class QComboBox;
class QLineEdit;
class QPushButton;
class QgsRubberBand;
class QgsMapToolEmitPoint;
class QgsMapCanvas;
class RoadGraphPlugin;
class QgsGraph;
/**
@author Sergey Yakushev
*/
/**
* \class VrpPluginShortestPathDlg
* \brief This class implement user interface for finding shortest path between two points.
*/
class RgShortestPathWidget : public QgsDockWidget
{
Q_OBJECT
public:
/**
* Standard constructor
*/
RgShortestPathWidget( QWidget *, RoadGraphPlugin * );
/**
* destructor
*/
~RgShortestPathWidget();
private slots:
/**
* export path
*/
void exportPath();
/**
* update rubberbands where extents changed
*/
void mapCanvasExtentsChanged();
/**
* on canvas click mouse button
*/
void setFrontPoint( const QgsPoint& );
/**
* on canvas click mouse button
*/
void setBackPoint( const QgsPoint& );
/**
* Activate map tool for coordinate capture
*/
void onSelectFrontPoint();
/**
* Activate map tool for coordinate capture
*/
void onSelectBackPoint();
/**
* finding path
*/
void findingPath();
/**
* clear
*/
void clear();
/**
* help requested
*/
void helpRequested();
private:
/**
* return path as a graph
*/
QgsGraph* getPath( QgsPoint& p1, QgsPoint& p2 );
/**
* This line edit show front points coordinates
*/
QLineEdit *mFrontPointLineEdit;
/**
* This line edit show back points coordinates
*/
QLineEdit *mBackPointLineEdit;
/**
* This combobox conteined criterion name
*/
QComboBox *mCriterionName;
/**
* This line edit show length calculated path
*/
QLineEdit *mPathCostLineEdit;
/**
* This line edit show time calculated path
*/
QLineEdit *mPathTimeLineEdit;
/**
* this button called to find shortest path
*/
QPushButton *mCalculate;
/**
* this button called to clear line edits and clar current path
*/
QPushButton *mClear;
/**
* this map tool use for select coordinates
*/
QgsMapToolEmitPoint *mFrontPointMapTool;
/**
* this map tool use for select coordinates
*/
QgsMapToolEmitPoint *mBackPointMapTool;
/**
* pointer to Plugin
*/
RoadGraphPlugin *mPlugin;
/**
* Front point
*/
QgsPoint mFrontPoint;
/**
* Back point
*/
QgsPoint mBackPoint;
/**
* show front point
*/
QgsRubberBand *mrbFrontPoint;
/**
* show back point
*/
QgsRubberBand *mrbBackPoint;
/**
* show shortest path
*/
QgsRubberBand *mrbPath;
};
#endif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 639 B

View File

@ -1,85 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="25"
height="25"
id="svg2"
sodipodi:version="0.32"
inkscape:version="0.46"
sodipodi:docname="showdirect.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
version="1.0"
inkscape:export-filename="/home/sy/projects/qgis_1.0.1/src/plugins/vrp/showdirect.png"
inkscape:export-xdpi="75"
inkscape:export-ydpi="75">
<defs
id="defs4">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 526.18109 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="744.09448 : 526.18109 : 1"
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
id="perspective10" />
<inkscape:perspective
id="perspective2467"
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
inkscape:vp_z="744.09448 : 526.18109 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 526.18109 : 1"
sodipodi:type="inkscape:persp3d" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
gridtolerance="10000"
guidetolerance="10"
objecttolerance="10"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="60.866488"
inkscape:cy="830.2407"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1017"
inkscape:window-height="687"
inkscape:window-x="0"
inkscape:window-y="0" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
style="fill:#00ff00;fill-opacity:1;fill-rule:evenodd;stroke:#008000;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 7.3583272,16.837617 L 1.9839972,1.7606866 L 16.152667,6.2478766 L 7.3583272,16.837617 z"
id="path2475"
sodipodi:nodetypes="cccc" />
<path
style="fill:#00ff00;fill-opacity:1;fill-rule:evenodd;stroke:#008000;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 17.609677,7.6837566 L 22.983997,22.760687 L 8.8153272,18.273497 L 17.609677,7.6837566 z"
id="path2477"
sodipodi:nodetypes="cccc" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -1,96 +0,0 @@
/***************************************************************************
* Copyright (C) 2009 by Sergey Yakushev *
* yakushevs@list.ru *
* *
* This is file implements Units classes *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
/**
* \file units.cpp
* \brief implementation of VRP plugins utils
*/
#include "units.h"
Unit::Unit()
{
mMultipler = 1.0;
}
Unit::Unit( const QString& name, double multipler )
: mName( name )
, mMultipler( multipler )
{
}
QString Unit::name() const
{
return mName;
}
double Unit::multipler() const
{
return mMultipler;
}
Unit Unit::byName( const QString& name )
{
if ( name == QLatin1String( "h" ) )
return Unit( name, 60*60 );
else if ( name == QLatin1String( "km" ) )
return Unit( name, 1000 );
else if ( name == QLatin1String( "s" ) )
return Unit( name, 1 );
else if ( name == QLatin1String( "m" ) )
return Unit( name, 1 );
return Unit();
}
SpeedUnit::SpeedUnit()
: mTimeUnit( QLatin1String( "" ), 1 )
, mDistanceUnit( QLatin1String( "" ), 1 )
{
}
SpeedUnit::SpeedUnit( const Unit& distanceUnit, const Unit& timeUnit )
: mTimeUnit( timeUnit )
, mDistanceUnit( distanceUnit )
{
}
QString SpeedUnit::name() const
{
if ( mDistanceUnit.name().isNull() || mTimeUnit.name().isNull() )
return QString();
return mDistanceUnit.name() + QStringLiteral( "/" ) + mTimeUnit.name();
}
SpeedUnit SpeedUnit::byName( const QString& name )
{
if ( name == QLatin1String( "km/h" ) )
return SpeedUnit( Unit::byName( QStringLiteral( "km" ) ), Unit::byName( QStringLiteral( "h" ) ) );
else if ( name == QLatin1String( "m/s" ) )
return SpeedUnit( Unit::byName( QStringLiteral( "m" ) ), Unit::byName( QStringLiteral( "s" ) ) );
return SpeedUnit();
}
double SpeedUnit::multipler() const
{
return mDistanceUnit.multipler() / mTimeUnit.multipler();
}
Unit SpeedUnit::timeUnit() const
{
return mTimeUnit;
}
Unit SpeedUnit::distanceUnit() const
{
return mDistanceUnit;
}

View File

@ -1,92 +0,0 @@
/***************************************************************************
* Copyright (C) 2010 by Sergey Yakushev *
* yakushevs@list.ru *
* *
* This is file define vrp plugins time, distance and speed units *
* classes *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef ROADGRAPH_UNITS_H
#define ROADGRAPH_UNITS_H
//#include <vrpguibase.h>
// QT includes
#include <qstring.h>
// Qgis includes
// forward declaration Qgis-classes
/**
@author Sergey Yakushev
*/
/**
* \class Unit
* \brief This class provide interface to access unit name and multipler.
* You can use it for convert units to metric system
*/
class Unit
{
public:
/**
* default constructor
*/
Unit();
/**
* constructor
*/
Unit( const QString& name, double multipler );
/**
* return unit name
*/
QString name() const;
/**
* return unit multipler. You can use multipler to conver unit to metric system
*/
double multipler() const;
/**
* return unit by name
*/
static Unit byName( const QString& name );
private:
/**
* units name
*/
QString mName;
/**
* units multipler
*/
double mMultipler;
};
class SpeedUnit
{
public:
SpeedUnit();
SpeedUnit( const Unit& distanceUnit, const Unit& timeUnit );
QString name() const;
double multipler() const;
Unit timeUnit() const;
Unit distanceUnit() const;
static SpeedUnit byName( const QString& name );
protected:
Unit mTimeUnit;
Unit mDistanceUnit;
};
#endif