mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
fix windows build, warnings, typos and roadgraph plugin indentation
git-svn-id: http://svn.osgeo.org/qgis/trunk@15071 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
d29ac2476b
commit
656ca4ad6a
2
INSTALL
2
INSTALL
@ -1555,7 +1555,7 @@ You can take care of both with the PyQwt source from:
|
||||
|
||||
|
||||
Double-click the tarball to unpack it. The following assumes PyQwt v5.2.0 (comes with Qwt 5.2.1).
|
||||
Normal compilation does both Qwt and PyQwt at the same time, but Qwt is staically linked
|
||||
Normal compilation does both Qwt and PyQwt at the same time, but Qwt is statically linked
|
||||
into PyQwt, and Qgis can't use it. So, we need to split the build.
|
||||
|
||||
First edit qwtconfig.pri in the qwt-5.2 subdir and change some settings so
|
||||
|
@ -265,7 +265,7 @@ http://pyqwt.sourceforge.net/
|
||||
```
|
||||
|
||||
Double-click the tarball to unpack it. The following assumes PyQwt v5.2.0 (comes with Qwt 5.2.1).
|
||||
Normal compilation does both Qwt and PyQwt at the same time, but Qwt is staically linked
|
||||
Normal compilation does both Qwt and PyQwt at the same time, but Qwt is statically linked
|
||||
into PyQwt, and Qgis can't use it. So, we need to split the build.
|
||||
|
||||
First edit qwtconfig.pri in the qwt-5.2 subdir and change some settings so
|
||||
|
@ -56,7 +56,7 @@ static pysqlite_StatementKind detect_statement_type(char* statement)
|
||||
dst = buf;
|
||||
*dst = 0;
|
||||
while (isalpha(*src) && dst - buf < sizeof(buf) - 2) {
|
||||
*dst++ = tolower(*src++);
|
||||
*dst++ = (char) tolower(*src++);
|
||||
}
|
||||
|
||||
*dst = 0;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
RE=$(echo $(cut -d: -f1 scripts/spelling.dat | sed -e 's/^/\\</; s/$/\\>|/;') | sed -e 's/| /|/g; s/|$//;')
|
||||
EX="\.(svn-base|tmp|xpm|ts)|context_help|spelling\.dat"
|
||||
EX="\.(svn-base|tmp|xpm|ts)|context_help|spelling\.dat|Exception_to_GPL_for_Qt.txt|sqlite3.c"
|
||||
|
||||
egrep --color=always "$RE" -ir . | egrep -iv "$EX"
|
||||
egrep --color=always "$RE" -i resources/context_help/*-en_US
|
||||
|
@ -1596,7 +1596,7 @@ string ASBeautifier::beautify(const string &originalLine)
|
||||
/*
|
||||
* Create a temporary snapshot of the current block's header-list in the
|
||||
* uppermost inner stack in tempStacks, and clear the headerStack up to
|
||||
* the begining of the block.
|
||||
* the beginning of the block.
|
||||
* Thus, the next future statement will think it comes one indent past
|
||||
* the block's '{' unless it specifically checks for a companion-header
|
||||
* (such as a previous 'if' for an 'else' header) within the tempStacks,
|
||||
@ -1758,7 +1758,7 @@ string ASBeautifier::beautify(const string &originalLine)
|
||||
if (lineCommentNoBeautify || blockCommentNoBeautify || isInQuoteContinuation)
|
||||
tabCount = spaceTabCount = 0;
|
||||
|
||||
// finally, insert indentations into begining of line
|
||||
// finally, insert indentations into beginning of line
|
||||
|
||||
prevFinalLineSpaceTabCount = spaceTabCount;
|
||||
prevFinalLineTabCount = tabCount;
|
||||
@ -1897,7 +1897,7 @@ const string *ASBeautifier::findHeader(const string &line, int i, const vector<c
|
||||
if (line.compare(i, header->length(), header->c_str()) == 0)
|
||||
{
|
||||
// check that this is a header and not a part of a longer word
|
||||
// (e.g. not at its begining, not at its middle...)
|
||||
// (e.g. not at its beginning, not at its middle...)
|
||||
|
||||
int lineLength = line.length();
|
||||
int headerEnd = i + header->length();
|
||||
|
@ -475,7 +475,7 @@ bool ASEnhancer::findKeyword(const string &line, int i, const char *keyword) con
|
||||
if (line.compare(i, strlen(keyword), keyword) == 0)
|
||||
{
|
||||
// check that this is a header and not a part of a longer word
|
||||
// (e.g. not at its begining, not at its middle...)
|
||||
// (e.g. not at its beginning, not at its middle...)
|
||||
|
||||
int lineLength = line.length();
|
||||
int wordEnd = i + strlen(keyword);
|
||||
|
@ -180,7 +180,7 @@ void ASFormatter::staticInit()
|
||||
*
|
||||
* init() should be called every time a ASFormatter object is to start
|
||||
* formatting a NEW source file.
|
||||
* init() recieves a pointer to a DYNAMICALLY CREATED ASSourceIterator object
|
||||
* init() receives a pointer to a DYNAMICALLY CREATED ASSourceIterator object
|
||||
* that will be used to iterate through the source code. This object will be
|
||||
* deleted during the ASFormatter's destruction, and thus should not be
|
||||
* deleted elsewhere.
|
||||
@ -307,7 +307,7 @@ string ASFormatter::nextLine()
|
||||
}
|
||||
else // stuff to do when reading a new character...
|
||||
{
|
||||
// make sure that a virgin '{' at the begining ofthe file will be treated as a block...
|
||||
// make sure that a virgin '{' at the beginning ofthe file will be treated as a block...
|
||||
if (isInVirginLine && currentChar == '{' && lineBeginsWith('{'))
|
||||
previousCommandChar = '{';
|
||||
isPreviousCharPostComment = isCharImmediatelyPostComment;
|
||||
@ -322,7 +322,7 @@ string ASFormatter::nextLine()
|
||||
{
|
||||
appendCurrentChar();
|
||||
|
||||
// explicitely break a line when a line comment's end is found.
|
||||
// explicitly break a line when a line comment's end is found.
|
||||
if (charNum + 1 == (int) currentLine.length())
|
||||
{
|
||||
isInLineBreak = true;
|
||||
@ -404,7 +404,7 @@ string ASFormatter::nextLine()
|
||||
formattedLineCommentNum = formattedLine.length();
|
||||
appendSequence(AS_OPEN_LINE_COMMENT);
|
||||
goForward(1);
|
||||
// explicitely break a line when a line comment's end is found.
|
||||
// explicitly break a line when a line comment's end is found.
|
||||
if (charNum + 1 == (int) currentLine.length())
|
||||
{
|
||||
isInLineBreak = true;
|
||||
@ -448,7 +448,7 @@ string ASFormatter::nextLine()
|
||||
previousCommandChar = previousNonWSChar = previousChar = '{';
|
||||
|
||||
// check if in preprocessor
|
||||
// ** isInPreprocessor will be automatically reset at the begining
|
||||
// ** isInPreprocessor will be automatically reset at the beginning
|
||||
// of a new line in getnextChar()
|
||||
if (isCStyle && currentChar == '#')
|
||||
{
|
||||
@ -1263,7 +1263,7 @@ bool ASFormatter::isBeforeLineEndComment(int startPos) const
|
||||
* get the next character, increasing the current placement in the process.
|
||||
* the new character is inserted into the variable currentChar.
|
||||
*
|
||||
* @return whether succeded to recieve the new character.
|
||||
* @return whether succeded to receive the new character.
|
||||
*/
|
||||
bool ASFormatter::getNextChar()
|
||||
{
|
||||
|
@ -90,7 +90,7 @@ class CORE_EXPORT QgsPalLayerSettings
|
||||
Hali, //horizontal alignment for data defined label position (Left, Center, Right)
|
||||
Vali, //vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top)
|
||||
LabelDistance,
|
||||
Rotation //data defined rotation (only usefull in connection with data defined position)
|
||||
Rotation //data defined rotation (only useful in connection with data defined position)
|
||||
};
|
||||
|
||||
QString fieldName;
|
||||
|
@ -377,7 +377,7 @@ extern "C"
|
||||
char *Name; /* field name */
|
||||
unsigned char Type; /* field type */
|
||||
int Offset; /* buffer offset [this field begins at *buffer+offset* and extends for *length* bytes */
|
||||
unsigned char Length; /* field total lenght [in bytes] */
|
||||
unsigned char Length; /* field total length [in bytes] */
|
||||
unsigned char Decimals; /* decimal positions */
|
||||
gaiaValuePtr Value; /* the current multitype value for this attribute */
|
||||
struct gaiaDbfFieldStruct *Next; /* pointer to next element in linked list */
|
||||
|
@ -4448,7 +4448,7 @@ SQLITE_API int sqlite3_release_memory(int);
|
||||
** <li> Memory accounting is disabled using a combination of the
|
||||
** [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and
|
||||
** the [SQLITE_DEFAULT_MEMSTATUS] compile-time option.
|
||||
** <li> An alternative page cache implementation is specifed using
|
||||
** <li> An alternative page cache implementation is specified using
|
||||
** [sqlite3_config]([SQLITE_CONFIG_PCACHE],...).
|
||||
** <li> The page cache allocates from its own memory pool supplied
|
||||
** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than
|
||||
|
@ -424,7 +424,7 @@ struct sqlite3_api_routines {
|
||||
|
||||
/*
|
||||
** The following macros redefine the API routines so that they are
|
||||
** redirected throught the global sqlite3_api structure.
|
||||
** redirected through the global sqlite3_api structure.
|
||||
**
|
||||
** This header file is also used by the loadext.c source file
|
||||
** (part of the main SQLite library - not an extension) so that
|
||||
|
@ -4556,7 +4556,7 @@ SQLITE_API int sqlite3_release_memory(int);
|
||||
** <li> Memory accounting is disabled using a combination of the
|
||||
** [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and
|
||||
** the [SQLITE_DEFAULT_MEMSTATUS] compile-time option.
|
||||
** <li> An alternative page cache implementation is specifed using
|
||||
** <li> An alternative page cache implementation is specified using
|
||||
** [sqlite3_config]([SQLITE_CONFIG_PCACHE],...).
|
||||
** <li> The page cache allocates from its own memory pool supplied
|
||||
** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than
|
||||
@ -6717,7 +6717,7 @@ struct sqlite3_api_routines {
|
||||
|
||||
/*
|
||||
** The following macros redefine the API routines so that they are
|
||||
** redirected throught the global sqlite3_api structure.
|
||||
** redirected through the global sqlite3_api structure.
|
||||
**
|
||||
** This header file is also used by the loadext.c source file
|
||||
** (part of the main SQLite library - not an extension) so that
|
||||
@ -7533,7 +7533,7 @@ extern "C"
|
||||
char *Name; /* field name */
|
||||
unsigned char Type; /* field type */
|
||||
int Offset; /* buffer offset [this field begins at *buffer+offset* and extends for *length* bytes */
|
||||
unsigned char Length; /* field total lenght [in bytes] */
|
||||
unsigned char Length; /* field total length [in bytes] */
|
||||
unsigned char Decimals; /* decimal positions */
|
||||
gaiaValuePtr Value; /* the current multitype value for this attribute */
|
||||
struct gaiaDbfFieldStruct *Next; /* pointer to next element in linked list */
|
||||
|
@ -82,24 +82,24 @@ ADD_EXECUTABLE(qgis_mapserv.fcgi
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${GDAL_INCLUDE_DIR}
|
||||
${FCGI_INCLUDE_DIR}
|
||||
${GEOS_INCLUDE_DIR}
|
||||
${PROJ_INCLUDE_DIR}
|
||||
${POSTGRES_INCLUDE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${QGIS_INCLUDE_DIR}
|
||||
../core
|
||||
../core/raster
|
||||
../core/renderer
|
||||
../core/symbology
|
||||
../core/symbology-ng
|
||||
../core/composer
|
||||
../analysis/interpolation
|
||||
../plugins/diagram_overlay
|
||||
.
|
||||
)
|
||||
${GDAL_INCLUDE_DIR}
|
||||
${FCGI_INCLUDE_DIR}
|
||||
${GEOS_INCLUDE_DIR}
|
||||
${PROJ_INCLUDE_DIR}
|
||||
${POSTGRES_INCLUDE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${QT_INCLUDE_DIR}
|
||||
${QGIS_INCLUDE_DIR}
|
||||
../core
|
||||
../core/raster
|
||||
../core/renderer
|
||||
../core/symbology
|
||||
../core/symbology-ng
|
||||
../core/composer
|
||||
../analysis/interpolation
|
||||
../plugins/diagram_overlay
|
||||
.
|
||||
)
|
||||
|
||||
IF (WITH_INTERNAL_SPATIALITE)
|
||||
INCLUDE_DIRECTORIES(BEFORE ../core/spatialite/headers/spatialite)
|
||||
|
@ -629,6 +629,8 @@ QList<QDomElement> QgsProjectParser::legendGroupElements() const
|
||||
{
|
||||
groupList.push_back( groupNodeList.at( i ).toElement() );
|
||||
}
|
||||
|
||||
return groupList;
|
||||
}
|
||||
|
||||
QMap< QString, QDomElement > QgsProjectParser::projectLayerElementsById() const
|
||||
|
@ -88,7 +88,7 @@ QgsMapLayer* QgsRemoteOWSBuilder::createMapLayer( const QDomElement& elem, const
|
||||
|
||||
if ( serviceName == "WFS" )
|
||||
{
|
||||
//support for old format where type is explicitely given and not part of url
|
||||
//support for old format where type is explicitly given and not part of url
|
||||
QString tname = onlineResourceElement.attribute( "type" );
|
||||
if ( !tname.isEmpty() )
|
||||
{
|
||||
|
@ -28,6 +28,7 @@ SET (VRP_RCCS roadgraph.qrc)
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${GEOS_INCLUDE_DIR}
|
||||
../../core
|
||||
../../gui
|
||||
..
|
||||
|
@ -31,27 +31,27 @@ RgExportDlg::RgExportDlg( QWidget* parent, Qt::WFlags fl )
|
||||
: QDialog( parent, fl )
|
||||
{
|
||||
// create base widgets;
|
||||
setWindowTitle( tr("Export feature") );
|
||||
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);
|
||||
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") );
|
||||
|
||||
mcbLayers->insertItem( 0, tr( "new temporary layer" ), QVariant( "-1" ) );
|
||||
|
||||
QMap<QString, QgsMapLayer*> mapLayers = QgsMapLayerRegistry::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() );
|
||||
@ -72,33 +72,34 @@ QgsVectorLayer* RgExportDlg::mapLayer() const
|
||||
{
|
||||
QgsVectorLayer* myLayer = NULL;
|
||||
QString layerId = mcbLayers->itemData( mcbLayers->currentIndex() ).toString();
|
||||
|
||||
if ( layerId == QString("-1") )
|
||||
|
||||
if ( layerId == QString( "-1" ) )
|
||||
{
|
||||
// create a temporary layer
|
||||
myLayer = new QgsVectorLayer( "LineString", "shortest path", "memory" );
|
||||
|
||||
QgsVectorDataProvider *prov = myLayer->dataProvider();
|
||||
if ( prov == NULL)
|
||||
return NULL;
|
||||
if ( prov == NULL )
|
||||
return NULL;
|
||||
|
||||
QList<QgsField> attrList;
|
||||
attrList.append( QgsField("one", QVariant::Int) );
|
||||
attrList.append( QgsField( "one", QVariant::Int ) );
|
||||
prov->addAttributes( attrList );
|
||||
QgsMapLayerRegistry::instance()->addMapLayer( myLayer );
|
||||
QgsMapLayerRegistry::instance()->addMapLayer( myLayer );
|
||||
|
||||
}else
|
||||
}
|
||||
else
|
||||
{
|
||||
// retrun selected layer
|
||||
myLayer = dynamic_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( layerId ) );
|
||||
}
|
||||
|
||||
|
||||
return myLayer;
|
||||
} // QgsVectorLayer* RgExportDlg::vectorLayer() const
|
||||
|
||||
void RgExportDlg::on_buttonBox_accepted()
|
||||
{
|
||||
accept();
|
||||
{
|
||||
accept();
|
||||
} // void RgExportDlg::on_buttonBox_accepted()
|
||||
|
||||
void RgExportDlg::on_buttonBox_rejected()
|
||||
|
@ -11,7 +11,7 @@
|
||||
* 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
|
||||
|
||||
@ -35,20 +35,20 @@ class QgsVectorLayer;
|
||||
class RgExportDlg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RgExportDlg( QWidget* parent = 0, Qt::WFlags fl = 0 );
|
||||
~RgExportDlg();
|
||||
public:
|
||||
QgsVectorLayer* mapLayer() const;
|
||||
private:
|
||||
static const int context_id = 0;
|
||||
public:
|
||||
RgExportDlg( QWidget* parent = 0, Qt::WFlags fl = 0 );
|
||||
~RgExportDlg();
|
||||
public:
|
||||
QgsVectorLayer* mapLayer() const;
|
||||
private:
|
||||
static const int context_id = 0;
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
void on_buttonBox_rejected();
|
||||
void on_buttonBox_helpRequested();
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
void on_buttonBox_rejected();
|
||||
void on_buttonBox_helpRequested();
|
||||
|
||||
private:
|
||||
QComboBox *mcbLayers;
|
||||
private:
|
||||
QComboBox *mcbLayers;
|
||||
};
|
||||
#endif
|
||||
|
@ -32,38 +32,38 @@
|
||||
*/
|
||||
class RgGraphBuilder
|
||||
{
|
||||
public:
|
||||
//! Destructor
|
||||
virtual ~RgGraphBuilder()
|
||||
{};
|
||||
/**
|
||||
* set source CRS
|
||||
*/
|
||||
virtual void setSourceCrs( const QgsCoordinateReferenceSystem& crs ) = 0;
|
||||
public:
|
||||
//! Destructor
|
||||
virtual ~RgGraphBuilder()
|
||||
{};
|
||||
/**
|
||||
* set source CRS
|
||||
*/
|
||||
virtual void setSourceCrs( const QgsCoordinateReferenceSystem& crs ) = 0;
|
||||
|
||||
/**
|
||||
* set destionation CRS
|
||||
*/
|
||||
virtual void setDestinationCrs( const QgsCoordinateReferenceSystem& crs ) = 0;
|
||||
|
||||
/**
|
||||
* add vertex
|
||||
*/
|
||||
virtual void addVertex( const QgsPoint& pt ) = 0;
|
||||
|
||||
/**
|
||||
* add arc
|
||||
*/
|
||||
virtual void addArc( const QgsPoint& pt1, const QgsPoint& pt2, double speed ) = 0;
|
||||
/**
|
||||
* set destionation CRS
|
||||
*/
|
||||
virtual void setDestinationCrs( const QgsCoordinateReferenceSystem& crs ) = 0;
|
||||
|
||||
/**
|
||||
* tie point
|
||||
* @param pt maps point
|
||||
* @param pt ok = false if tiePoint failed.
|
||||
* @return Graph vertex corresponding pt.
|
||||
* @note: graph can be modified
|
||||
*/
|
||||
virtual QgsPoint tiePoint( const QgsPoint &pt, bool &ok ) = 0;
|
||||
/**
|
||||
* add vertex
|
||||
*/
|
||||
virtual void addVertex( const QgsPoint& pt ) = 0;
|
||||
|
||||
/**
|
||||
* add arc
|
||||
*/
|
||||
virtual void addArc( const QgsPoint& pt1, const QgsPoint& pt2, double speed ) = 0;
|
||||
|
||||
/**
|
||||
* tie point
|
||||
* @param pt maps point
|
||||
* @param pt ok = false if tiePoint failed.
|
||||
* @return Graph vertex corresponding pt.
|
||||
* @note: graph can be modified
|
||||
*/
|
||||
virtual QgsPoint tiePoint( const QgsPoint &pt, bool &ok ) = 0;
|
||||
|
||||
};
|
||||
#endif //GRAPHBUILDER
|
||||
|
@ -31,23 +31,23 @@ class RgGraphBuilder;
|
||||
*/
|
||||
class RgGraphDirector
|
||||
{
|
||||
public:
|
||||
//! Destructor
|
||||
virtual ~RgGraphDirector() { };
|
||||
|
||||
/**
|
||||
* get adjacency matrix
|
||||
*/
|
||||
virtual void makeGraph( RgGraphBuilder * ) const = 0;
|
||||
|
||||
/**
|
||||
* return pointer to my Settings
|
||||
*/
|
||||
virtual RgSettings* settings() = 0;
|
||||
|
||||
/**
|
||||
* return Director name
|
||||
*/
|
||||
virtual QString name() const = 0;
|
||||
public:
|
||||
//! Destructor
|
||||
virtual ~RgGraphDirector() { };
|
||||
|
||||
/**
|
||||
* get adjacency matrix
|
||||
*/
|
||||
virtual void makeGraph( RgGraphBuilder * ) const = 0;
|
||||
|
||||
/**
|
||||
* return pointer to my Settings
|
||||
*/
|
||||
virtual RgSettings* settings() = 0;
|
||||
|
||||
/**
|
||||
* return Director name
|
||||
*/
|
||||
virtual QString name() const = 0;
|
||||
};
|
||||
#endif //GRAPHDIRECTOR
|
||||
|
@ -43,7 +43,7 @@ RgSettings* RgLineVectorLayerDirector::settings()
|
||||
return &mSettings;
|
||||
}
|
||||
|
||||
QString RgLineVectorLayerDirector::name() const
|
||||
QString RgLineVectorLayerDirector::name() const
|
||||
{
|
||||
return QString( "Vector line" );
|
||||
}
|
||||
@ -63,13 +63,13 @@ void RgLineVectorLayerDirector::makeGraph( RgGraphBuilder *builder ) const
|
||||
}
|
||||
if ( vl == NULL )
|
||||
return;
|
||||
|
||||
|
||||
QgsVectorDataProvider *provider = dynamic_cast<QgsVectorDataProvider*>( vl->dataProvider() );
|
||||
if ( provider == NULL )
|
||||
return;
|
||||
|
||||
int directionFieldId = provider->fieldNameIndex( mSettings.mDirection );
|
||||
int speedFieldId = provider->fieldNameIndex( mSettings.mSpeed );
|
||||
int speedFieldId = provider->fieldNameIndex( mSettings.mSpeed );
|
||||
|
||||
builder->setSourceCrs( vl->crs() );
|
||||
QgsAttributeList la;
|
||||
@ -82,12 +82,12 @@ void RgLineVectorLayerDirector::makeGraph( RgGraphBuilder *builder ) const
|
||||
|
||||
vl->select( la );
|
||||
QgsFeature feature;
|
||||
while ( vl->nextFeature(feature) )
|
||||
while ( vl->nextFeature( feature ) )
|
||||
{
|
||||
QgsAttributeMap attr = feature.attributeMap();
|
||||
RgLineVectorLayerSettings::DirectionType directionType = mSettings.mDefaultDirection;
|
||||
QgsAttributeMap::const_iterator it;
|
||||
// What direction have feature?
|
||||
// What direction have feature?
|
||||
for ( it = attr.constBegin(); it != attr.constEnd(); ++it )
|
||||
{
|
||||
if ( it.key() != directionFieldId )
|
||||
@ -110,23 +110,23 @@ void RgLineVectorLayerDirector::makeGraph( RgGraphBuilder *builder ) const
|
||||
}
|
||||
// What speed have feature?
|
||||
double speed = 0.0;
|
||||
for (it = attr.constBegin(); it != attr.constEnd(); ++it)
|
||||
for ( it = attr.constBegin(); it != attr.constEnd(); ++it )
|
||||
{
|
||||
if ( it.key() != speedFieldId )
|
||||
if ( it.key() != speedFieldId )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
speed = it.value().toDouble();
|
||||
}
|
||||
if (speed <= 0.0)
|
||||
if ( speed <= 0.0 )
|
||||
{
|
||||
speed = mSettings.mDefaultSpeed;
|
||||
}
|
||||
|
||||
// begin features segments and add arc to the Graph;
|
||||
QgsPoint pt1, pt2;
|
||||
|
||||
bool isFirstPoint=true;
|
||||
|
||||
bool isFirstPoint = true;
|
||||
QgsPolyline pl = feature.geometry()->asPolyline();
|
||||
QgsPolyline::iterator pointIt;
|
||||
for ( pointIt = pl.begin(); pointIt != pl.end(); ++pointIt )
|
||||
@ -135,18 +135,18 @@ void RgLineVectorLayerDirector::makeGraph( RgGraphBuilder *builder ) const
|
||||
if ( !isFirstPoint )
|
||||
{
|
||||
if ( directionType == RgLineVectorLayerSettings::FirstPointToLastPoint ||
|
||||
directionType == RgLineVectorLayerSettings::Both )
|
||||
directionType == RgLineVectorLayerSettings::Both )
|
||||
{
|
||||
builder->addArc(pt1, pt2, speed*su.multipler() );
|
||||
builder->addArc( pt1, pt2, speed*su.multipler() );
|
||||
}
|
||||
if (directionType == RgLineVectorLayerSettings::LastPointToFirstPoint ||
|
||||
directionType == RgLineVectorLayerSettings::Both )
|
||||
if ( directionType == RgLineVectorLayerSettings::LastPointToFirstPoint ||
|
||||
directionType == RgLineVectorLayerSettings::Both )
|
||||
{
|
||||
builder->addArc( pt2, pt1, speed*su.multipler() );
|
||||
}
|
||||
}
|
||||
pt1 = pt2;
|
||||
isFirstPoint=false;
|
||||
isFirstPoint = false;
|
||||
} // for (it = pl.begin(); it != pl.end(); ++it)
|
||||
|
||||
} // while( vl->nextFeature(feature) )
|
||||
|
@ -32,22 +32,22 @@ class RgGraphBuilder;
|
||||
*/
|
||||
class RgLineVectorLayerDirector : public RgGraphDirector
|
||||
{
|
||||
public:
|
||||
RgLineVectorLayerDirector();
|
||||
//! Destructor
|
||||
virtual ~RgLineVectorLayerDirector();
|
||||
/**
|
||||
* MANDATORY DIRECTOR PROPERTY DECLARATION
|
||||
*/
|
||||
void makeGraph( RgGraphBuilder * ) const;
|
||||
|
||||
RgSettings* settings();
|
||||
public:
|
||||
RgLineVectorLayerDirector();
|
||||
//! Destructor
|
||||
virtual ~RgLineVectorLayerDirector();
|
||||
/**
|
||||
* MANDATORY DIRECTOR PROPERTY DECLARATION
|
||||
*/
|
||||
void makeGraph( RgGraphBuilder * ) const;
|
||||
|
||||
QString name() const;
|
||||
private:
|
||||
/**
|
||||
* settings of this director
|
||||
*/
|
||||
RgLineVectorLayerSettings mSettings;
|
||||
RgSettings* settings();
|
||||
|
||||
QString name() const;
|
||||
private:
|
||||
/**
|
||||
* settings of this director
|
||||
*/
|
||||
RgLineVectorLayerSettings mSettings;
|
||||
};
|
||||
#endif //GRAPHDIRECTOR
|
||||
|
@ -28,7 +28,7 @@
|
||||
//standard includes
|
||||
|
||||
RgLineVectorLayerSettings::RgLineVectorLayerSettings()
|
||||
{
|
||||
{
|
||||
mLayer = "";
|
||||
mDirection = "";
|
||||
mDefaultDirection = Both;
|
||||
@ -42,13 +42,13 @@ RgLineVectorLayerSettings::~RgLineVectorLayerSettings()
|
||||
bool RgLineVectorLayerSettings::test()
|
||||
{
|
||||
// implement me
|
||||
|
||||
|
||||
// check default speed
|
||||
if (mDefaultSpeed <= 0.0)
|
||||
if ( mDefaultSpeed <= 0.0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (mLayer == "")
|
||||
if ( mLayer == "" )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -61,25 +61,25 @@ void RgLineVectorLayerSettings::read( const QgsProject *project )
|
||||
{
|
||||
int dd = project->readNumEntry( "roadgraphplugin", "/defaultDirection" );
|
||||
mDirection = project->readEntry( "roadgraphplugin", "/directionField" );
|
||||
mFirstPointToLastPointDirectionVal =
|
||||
mFirstPointToLastPointDirectionVal =
|
||||
project->readEntry( "roadgraphplugin", "/FirstPointToLastPointDirectionVal" );
|
||||
mLastPointToFirstPointDirectionVal =
|
||||
mLastPointToFirstPointDirectionVal =
|
||||
project->readEntry( "roadgraphplugin", "/LastPointToFirstPointDirectionVal" );
|
||||
mBothDirectionVal = project->readEntry( "roadgraphplugin", "/BothDirectionVal" );
|
||||
mSpeed = project->readEntry( "roadgraphplugin", "/speedField" );
|
||||
mDefaultSpeed = project->readDoubleEntry( "roadgraphplugin", "/defaultSpeed" );
|
||||
mLayer = project->readEntry( "roadgraphplugin", "/layer" );
|
||||
mSpeedUnitName= project->readEntry( "roadgraphplugin","/speedUnitName" );
|
||||
mSpeedUnitName = project->readEntry( "roadgraphplugin", "/speedUnitName" );
|
||||
|
||||
if (dd == 1)
|
||||
if ( dd == 1 )
|
||||
{
|
||||
mDefaultDirection = FirstPointToLastPoint;
|
||||
}
|
||||
else if (dd == 2)
|
||||
else if ( dd == 2 )
|
||||
{
|
||||
mDefaultDirection = LastPointToFirstPoint;
|
||||
}
|
||||
else if (dd == 3)
|
||||
else if ( dd == 3 )
|
||||
{
|
||||
mDefaultDirection = Both;
|
||||
}
|
||||
@ -90,10 +90,10 @@ void RgLineVectorLayerSettings::write( QgsProject *project )
|
||||
{
|
||||
project->writeEntry( "roadgraphplugin", "/defaultDirection", mDefaultDirection );
|
||||
project->writeEntry( "roadgraphplugin", "/directionField", mDirection );
|
||||
project->writeEntry( "roadgraphplugin", "/FirstPointToLastPointDirectionVal",
|
||||
mFirstPointToLastPointDirectionVal );
|
||||
project->writeEntry( "roadgraphplugin", "/LastPointToFirstPointDirectionVal",
|
||||
mLastPointToFirstPointDirectionVal );
|
||||
project->writeEntry( "roadgraphplugin", "/FirstPointToLastPointDirectionVal",
|
||||
mFirstPointToLastPointDirectionVal );
|
||||
project->writeEntry( "roadgraphplugin", "/LastPointToFirstPointDirectionVal",
|
||||
mLastPointToFirstPointDirectionVal );
|
||||
project->writeEntry( "roadgraphplugin", "/BothDirectionVal", mBothDirectionVal );
|
||||
project->writeEntry( "roadgraphplugin", "/speedField", mSpeed );
|
||||
project->writeEntry( "roadgraphplugin", "/defaultSpeed", mDefaultSpeed );
|
||||
@ -103,13 +103,13 @@ void RgLineVectorLayerSettings::write( QgsProject *project )
|
||||
|
||||
QWidget* RgLineVectorLayerSettings::getGui( QWidget *parent )
|
||||
{
|
||||
return new RgLineVectorLayerSettingsWidget( this, parent );
|
||||
return new RgLineVectorLayerSettingsWidget( this, parent );
|
||||
}
|
||||
|
||||
void RgLineVectorLayerSettings::setFromGui( QWidget *myGui )
|
||||
{
|
||||
RgLineVectorLayerSettingsWidget* w = dynamic_cast<RgLineVectorLayerSettingsWidget*>( myGui );
|
||||
if (w == NULL)
|
||||
if ( w == NULL )
|
||||
return;
|
||||
|
||||
mFirstPointToLastPointDirectionVal = w->mleFirstPointToLastPointDirection->text();
|
||||
@ -122,15 +122,15 @@ void RgLineVectorLayerSettings::setFromGui( QWidget *myGui )
|
||||
{
|
||||
mDefaultDirection = Both;
|
||||
}
|
||||
else if ( w->mcbDirectionDefault->currentIndex() == 1 )
|
||||
else if ( w->mcbDirectionDefault->currentIndex() == 1 )
|
||||
{
|
||||
mDefaultDirection = FirstPointToLastPoint;
|
||||
}
|
||||
else if ( w->mcbDirectionDefault->currentIndex() == 2 )
|
||||
else if ( w->mcbDirectionDefault->currentIndex() == 2 )
|
||||
{
|
||||
mDefaultDirection = LastPointToFirstPoint;
|
||||
}
|
||||
|
||||
|
||||
mSpeed = w->mcbSpeed->currentText();
|
||||
mDefaultSpeed = w->msbSpeedDefault->value();
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
// Qgis includes
|
||||
|
||||
// standart includes
|
||||
// standard includes
|
||||
|
||||
// forward declaration Qgis-classes
|
||||
class QWidget;
|
||||
@ -34,77 +34,77 @@ class QWidget;
|
||||
|
||||
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 * );
|
||||
void read( const QgsProject * );
|
||||
bool test();
|
||||
QWidget *getGui( QWidget* Parent );
|
||||
void setFromGui( QWidget* );
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* \enum DirectionType
|
||||
* \brief DirectionType enumeration discribe
|
||||
*/
|
||||
enum DirectionType { FirstPointToLastPoint = 1, LastPointToFirstPoint = 2, Both = 3 };
|
||||
|
||||
/**
|
||||
* contained Layer name
|
||||
*/
|
||||
QString mLayer;
|
||||
public:
|
||||
/**
|
||||
* default constructor.
|
||||
*/
|
||||
RgLineVectorLayerSettings();
|
||||
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* destructor
|
||||
*/
|
||||
~RgLineVectorLayerSettings();
|
||||
public:
|
||||
/*
|
||||
* MANDATORY SETTINGS PROPERTY DECLARATIONS
|
||||
*/
|
||||
void write( QgsProject * );
|
||||
void read( const QgsProject * );
|
||||
bool test();
|
||||
QWidget *getGui( QWidget* Parent );
|
||||
void setFromGui( QWidget* );
|
||||
public:
|
||||
|
||||
/**
|
||||
* contained Default direction
|
||||
*/
|
||||
DirectionType mDefaultDirection;
|
||||
/**
|
||||
* contained Layer name
|
||||
*/
|
||||
QString mLayer;
|
||||
|
||||
/**
|
||||
* contained speed filed name
|
||||
*/
|
||||
QString mSpeed;
|
||||
/**
|
||||
* contained direction field name
|
||||
*/
|
||||
QString mDirection;
|
||||
|
||||
/**
|
||||
* сontained default speed value;
|
||||
*/
|
||||
double mDefaultSpeed;
|
||||
|
||||
/*
|
||||
* name of speed unit
|
||||
*/
|
||||
QString mSpeedUnitName;
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
DirectionType mDefaultDirection;
|
||||
|
||||
/**
|
||||
* contained speed filed name
|
||||
*/
|
||||
QString mSpeed;
|
||||
|
||||
/**
|
||||
* сontained default speed value;
|
||||
*/
|
||||
double mDefaultSpeed;
|
||||
|
||||
/*
|
||||
* name of speed unit
|
||||
*/
|
||||
QString mSpeedUnitName;
|
||||
};
|
||||
#endif
|
||||
|
@ -37,100 +37,100 @@ RgLineVectorLayerSettingsWidget::RgLineVectorLayerSettingsWidget( RgLineVectorLa
|
||||
: QWidget( parent )
|
||||
{
|
||||
// create base widgets;
|
||||
QTabWidget *tab = new QTabWidget(this);
|
||||
QVBoxLayout *v= new QVBoxLayout(this);
|
||||
v->addWidget(tab);
|
||||
|
||||
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 QComboBox(frame);
|
||||
QHBoxLayout *h = new QHBoxLayout(this);
|
||||
QFrame *frame = new QFrame( this );
|
||||
tab->addTab( frame, tr( "Transportation layer" ) );
|
||||
v = new QVBoxLayout( frame );
|
||||
QLabel *l = new QLabel( tr( "Layer" ), frame );
|
||||
mcbLayers = new QComboBox( frame );
|
||||
QHBoxLayout *h = new QHBoxLayout( this );
|
||||
|
||||
h->addWidget(l);
|
||||
h->addWidget(mcbLayers);
|
||||
v->addLayout(h);
|
||||
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);
|
||||
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("Direct direction"), frame) );
|
||||
h->addWidget( new QLabel( tr( "Direct direction" ), frame ) );
|
||||
mleFirstPointToLastPointDirection = new QLineEdit( s->mFirstPointToLastPointDirectionVal, frame );
|
||||
h->addWidget( mleFirstPointToLastPointDirection );
|
||||
v->addLayout(h);
|
||||
v->addLayout( h );
|
||||
|
||||
h = new QHBoxLayout();
|
||||
h->addWidget( new QLabel( tr("Reverse direction"), frame) );
|
||||
h->addWidget( new QLabel( tr( "Reverse direction" ), frame ) );
|
||||
mleLastPointToFirstPointDirection = new QLineEdit( s->mLastPointToFirstPointDirectionVal, frame );
|
||||
h->addWidget( mleLastPointToFirstPointDirection );
|
||||
v->addLayout(h);
|
||||
v->addLayout( h );
|
||||
|
||||
h = new QHBoxLayout();
|
||||
h->addWidget( new QLabel( tr("Both direction"), frame) );
|
||||
h->addWidget( new QLabel( tr( "Both direction" ), frame ) );
|
||||
mleBothDirection = new QLineEdit( s->mBothDirectionVal, frame );
|
||||
h->addWidget( mleBothDirection );
|
||||
v->addLayout(h);
|
||||
v->addLayout( h );
|
||||
|
||||
h = new QHBoxLayout();
|
||||
l = new QLabel( tr("Speed field"), frame );
|
||||
mcbSpeed = new QComboBox(frame);
|
||||
h->addWidget(l);
|
||||
h->addWidget(mcbSpeed);
|
||||
v->addLayout(h);
|
||||
|
||||
frame = new QFrame(tab);
|
||||
tab->addTab( frame, tr("Default settings") );
|
||||
v = new QVBoxLayout(frame);
|
||||
l = new QLabel( tr( "Speed field" ), frame );
|
||||
mcbSpeed = new QComboBox( frame );
|
||||
h->addWidget( l );
|
||||
h->addWidget( mcbSpeed );
|
||||
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("Both direction") );
|
||||
mcbDirectionDefault->insertItem( 1, tr("Direct direction") );
|
||||
mcbDirectionDefault->insertItem( 2, tr("Reverse direction") );
|
||||
connect( mcbLayers, SIGNAL(currentIndexChanged(int)), this, SLOT(on_mcbLayers_selectItem()) );
|
||||
l = new QLabel( tr( "Direction" ), frame );
|
||||
mcbDirectionDefault = new QComboBox( frame );
|
||||
mcbDirectionDefault->insertItem( 0, tr( "Both direction" ) );
|
||||
mcbDirectionDefault->insertItem( 1, tr( "Direct 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(frame);
|
||||
l = new QLabel( tr("Cost"), frame );
|
||||
h->addWidget(l);
|
||||
l = new QLabel( tr("lines length"), frame );
|
||||
h->addWidget(l);
|
||||
v->addLayout(h);
|
||||
h->addWidget( l );
|
||||
h->addWidget( mcbDirectionDefault );
|
||||
v->addLayout( h );
|
||||
|
||||
h = new QHBoxLayout(frame);
|
||||
l = new QLabel( tr("Speed"), frame );
|
||||
h = new QHBoxLayout( frame );
|
||||
l = new QLabel( tr( "Cost" ), frame );
|
||||
h->addWidget( l );
|
||||
l = new QLabel( tr( "lines length" ), frame );
|
||||
h->addWidget( l );
|
||||
v->addLayout( h );
|
||||
|
||||
h = new QHBoxLayout( frame );
|
||||
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 );
|
||||
|
||||
frame = new QFrame(tab);
|
||||
tab->addTab( frame, tr("Units") );
|
||||
|
||||
frame = new QFrame( tab );
|
||||
tab->addTab( frame, tr( "Units" ) );
|
||||
v = new QVBoxLayout( frame );
|
||||
h = new QHBoxLayout();
|
||||
l = new QLabel( tr("Unit of speed") );
|
||||
mcbUnitOfSpeed = new QComboBox(this);
|
||||
h->addWidget(l);
|
||||
h->addWidget( mcbUnitOfSpeed );
|
||||
l = new QLabel( tr( "Unit of speed" ) );
|
||||
mcbUnitOfSpeed = new QComboBox( this );
|
||||
h->addWidget( l );
|
||||
h->addWidget( mcbUnitOfSpeed );
|
||||
v->addLayout( h );
|
||||
|
||||
mcbUnitOfSpeed->insertItem( 0, tr("km/h") );
|
||||
mcbUnitOfSpeed->insertItem( 0, tr("m/s") );
|
||||
if ( s->mSpeedUnitName == "km/h" )
|
||||
mcbUnitOfSpeed->insertItem( 0, tr( "km/h" ) );
|
||||
mcbUnitOfSpeed->insertItem( 0, tr( "m/s" ) );
|
||||
if ( s->mSpeedUnitName == "km/h" )
|
||||
mcbUnitOfSpeed->setCurrentIndex( 1 );
|
||||
else if (s->mSpeedUnitName == "m/s" )
|
||||
else if ( s->mSpeedUnitName == "m/s" )
|
||||
mcbUnitOfSpeed->setCurrentIndex( 0 );
|
||||
|
||||
// fill list of layers
|
||||
@ -144,38 +144,38 @@ RgLineVectorLayerSettingsWidget::RgLineVectorLayerSettingsWidget( RgLineVectorLa
|
||||
continue;
|
||||
if ( vl->geometryType() != QGis::Line )
|
||||
continue;
|
||||
mcbLayers->insertItem( 0, vl->name() );
|
||||
mcbLayers->insertItem( 0, vl->name() );
|
||||
}
|
||||
|
||||
|
||||
//sets current settings
|
||||
msbSpeedDefault->setValue( static_cast<int>( s->mDefaultSpeed ) );
|
||||
msbSpeedDefault->setValue( static_cast<int>( s->mDefaultSpeed ) );
|
||||
|
||||
int idx = mcbLayers->findText( s->mLayer );
|
||||
if (idx != -1)
|
||||
if ( idx != -1 )
|
||||
{
|
||||
mcbLayers->setCurrentIndex( idx );
|
||||
}
|
||||
|
||||
|
||||
idx = mcbDirection->findText( s->mDirection );
|
||||
if (idx != -1)
|
||||
if ( idx != -1 )
|
||||
mcbDirection->setCurrentIndex( idx );
|
||||
|
||||
|
||||
idx = mcbSpeed->findText( s->mSpeed );
|
||||
if (idx != -1)
|
||||
if ( idx != -1 )
|
||||
mcbSpeed->setCurrentIndex( idx );
|
||||
|
||||
|
||||
switch( s->mDefaultDirection )
|
||||
|
||||
|
||||
switch ( s->mDefaultDirection )
|
||||
{
|
||||
case RgLineVectorLayerSettings::Both:
|
||||
mcbDirectionDefault->setCurrentIndex(0);
|
||||
break;
|
||||
case RgLineVectorLayerSettings::FirstPointToLastPoint:
|
||||
mcbDirectionDefault->setCurrentIndex(1);
|
||||
break;
|
||||
case RgLineVectorLayerSettings::LastPointToFirstPoint:
|
||||
mcbDirectionDefault->setCurrentIndex(2);
|
||||
break;
|
||||
case RgLineVectorLayerSettings::Both:
|
||||
mcbDirectionDefault->setCurrentIndex( 0 );
|
||||
break;
|
||||
case RgLineVectorLayerSettings::FirstPointToLastPoint:
|
||||
mcbDirectionDefault->setCurrentIndex( 1 );
|
||||
break;
|
||||
case RgLineVectorLayerSettings::LastPointToFirstPoint:
|
||||
mcbDirectionDefault->setCurrentIndex( 2 );
|
||||
break;
|
||||
}
|
||||
} // RgLineVectorLayerSettingsWidget::RgLineVectorLayerSettingsWidget()
|
||||
|
||||
@ -203,8 +203,8 @@ void RgLineVectorLayerSettingsWidget::on_mcbLayers_selectItem()
|
||||
mcbDirection->clear();
|
||||
mcbSpeed->clear();
|
||||
|
||||
mcbDirection->insertItem( 0, tr("Always use default") );
|
||||
mcbSpeed->insertItem( 0, tr("Always use default") );
|
||||
mcbDirection->insertItem( 0, tr( "Always use default" ) );
|
||||
mcbSpeed->insertItem( 0, tr( "Always use default" ) );
|
||||
|
||||
QgsVectorLayer* vl = selectedLayer();
|
||||
if ( !vl )
|
||||
@ -213,20 +213,20 @@ void RgLineVectorLayerSettingsWidget::on_mcbLayers_selectItem()
|
||||
QgsVectorDataProvider* provider = vl->dataProvider();
|
||||
if ( !provider )
|
||||
return;
|
||||
|
||||
|
||||
const QgsFieldMap& fields = provider->fields();
|
||||
QgsFieldMap::const_iterator it;
|
||||
for (it = fields.constBegin(); it != fields.constEnd(); ++it)
|
||||
for ( it = fields.constBegin(); it != fields.constEnd(); ++it )
|
||||
{
|
||||
QgsField currentField = it.value();
|
||||
QVariant currentType = currentField.type();
|
||||
if ( currentType == QVariant::Int || currentType == QVariant::String )
|
||||
{
|
||||
mcbDirection->insertItem(1, currentField.name());
|
||||
mcbDirection->insertItem( 1, currentField.name() );
|
||||
}
|
||||
if ( currentType == QVariant::Int || currentType == QVariant::Double )
|
||||
{
|
||||
mcbSpeed->insertItem(1, currentField.name());
|
||||
mcbSpeed->insertItem( 1, currentField.name() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef ROADGRAPH_LINEVECTORLAYERSETTINGSWIDGET_H
|
||||
#define ROADGRAPH_LINEVECTORLAYERSETTINGSWIDGET_H
|
||||
|
||||
@ -34,64 +34,64 @@ class QgsVectorLayer;
|
||||
*/
|
||||
/**
|
||||
* \class RgLineVectorLayerSettingsWidget
|
||||
* \brief
|
||||
* \brief
|
||||
*/
|
||||
class RgLineVectorLayerSettingsWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RgLineVectorLayerSettingsWidget( RgLineVectorLayerSettings *s, QWidget* parent = 0 );
|
||||
Q_OBJECT
|
||||
public:
|
||||
RgLineVectorLayerSettingsWidget( RgLineVectorLayerSettings *s, QWidget* parent = 0 );
|
||||
|
||||
private slots:
|
||||
void on_mcbLayers_selectItem();
|
||||
private slots:
|
||||
void on_mcbLayers_selectItem();
|
||||
|
||||
private:
|
||||
QgsVectorLayer * selectedLayer();
|
||||
private:
|
||||
QgsVectorLayer * selectedLayer();
|
||||
|
||||
public:
|
||||
/**
|
||||
* list of passible layers
|
||||
*/
|
||||
QComboBox *mcbLayers;
|
||||
|
||||
/**
|
||||
* list of possible fields for use as direction
|
||||
*/
|
||||
QComboBox *mcbDirection;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
QLineEdit *mleFirstPointToLastPointDirection;
|
||||
public:
|
||||
/**
|
||||
* list of passible layers
|
||||
*/
|
||||
QComboBox *mcbLayers;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
QLineEdit *mleLastPointToFirstPointDirection;
|
||||
/**
|
||||
* list of possible fields for use as direction
|
||||
*/
|
||||
QComboBox *mcbDirection;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
QLineEdit *mleBothDirection;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
QLineEdit *mleFirstPointToLastPointDirection;
|
||||
|
||||
/**
|
||||
* default direction value
|
||||
*/
|
||||
QComboBox *mcbDirectionDefault;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
QLineEdit *mleLastPointToFirstPointDirection;
|
||||
|
||||
/**
|
||||
* list of possible fields for use as speed
|
||||
*/
|
||||
QComboBox *mcbSpeed;
|
||||
|
||||
/**
|
||||
* Default speed value
|
||||
*/
|
||||
QSpinBox *msbSpeedDefault;
|
||||
|
||||
/**
|
||||
* Unit of speed
|
||||
*/
|
||||
QComboBox *mcbUnitOfSpeed;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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
|
||||
|
@ -45,7 +45,7 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <QDebug>
|
||||
|
||||
// standart includes
|
||||
// standard includes
|
||||
|
||||
static const char * const sIdent = "$Id: roadgraphplugin.cpp 9327 2009-04-20 10:09:44Z YEKST $";
|
||||
static const QString sName = QObject::tr( "Road graph plugin" );
|
||||
@ -92,13 +92,13 @@ void RoadGraphPlugin::initGui()
|
||||
|
||||
// Create the action for tool
|
||||
mQSettingsAction = new QAction( QIcon( ":/roadgraph/road.png" ), tr( "Road graph settings" ), this );
|
||||
mQShowDirectionAction = new QAction( QIcon( ":/roadgraph/showdirect.png" ), tr("Show roads direction"), this );
|
||||
mQShowDirectionAction = new QAction( QIcon( ":/roadgraph/showdirect.png" ), tr( "Show roads direction" ), this );
|
||||
mInfoAction = new QAction( QIcon( ":/roadgraph/about.png" ), tr( "About" ), this );
|
||||
|
||||
// Set the what's this text
|
||||
mQSettingsAction->setWhatsThis( tr("Road graph plugin settings") );
|
||||
mQShowDirectionAction->setWhatsThis( tr("Roads direction viewer") );
|
||||
mInfoAction->setWhatsThis( tr("About Road graph plugin") );
|
||||
mQSettingsAction->setWhatsThis( tr( "Road graph plugin settings" ) );
|
||||
mQShowDirectionAction->setWhatsThis( tr( "Roads direction viewer" ) );
|
||||
mInfoAction->setWhatsThis( tr( "About Road graph plugin" ) );
|
||||
|
||||
mQShowDirectionAction->setCheckable( true );
|
||||
|
||||
@ -116,7 +116,7 @@ void RoadGraphPlugin::initGui()
|
||||
mQGisIface->addPluginToMenu( tr( "Road graph" ), mQShowDirectionAction );
|
||||
mQGisIface->addPluginToMenu( tr( "Road graph" ), mInfoAction );
|
||||
|
||||
connect( mQGisIface->mapCanvas(), SIGNAL( renderComplete(QPainter*) ), this, SLOT( render(QPainter*) ) );
|
||||
connect( mQGisIface->mapCanvas(), SIGNAL( renderComplete( QPainter* ) ), this, SLOT( render( QPainter* ) ) );
|
||||
connect( mQGisIface, SIGNAL( projectRead() ), this, SLOT( projectRead() ) );
|
||||
connect( mQGisIface , SIGNAL( newProjectCreated() ), this, SLOT( newProject() ) );
|
||||
// load settings
|
||||
@ -127,13 +127,13 @@ void RoadGraphPlugin::initGui()
|
||||
void RoadGraphPlugin::unload()
|
||||
{
|
||||
// remove the GUI
|
||||
mQGisIface->removePluginMenu( tr("Road graph"), mQSettingsAction );
|
||||
mQGisIface->removePluginMenu( tr("Road graph"), mQShowDirectionAction );
|
||||
mQGisIface->removePluginMenu( tr( "Road graph" ), mQSettingsAction );
|
||||
mQGisIface->removePluginMenu( tr( "Road graph" ), mQShowDirectionAction );
|
||||
|
||||
mQGisIface->removeToolBarIcon( mQShowDirectionAction );
|
||||
|
||||
// disconnect
|
||||
disconnect( mQGisIface->mapCanvas(), SIGNAL( renderComplete(QPainter*) ), this, SLOT( render(QPainter*) ) );
|
||||
// disconnect
|
||||
disconnect( mQGisIface->mapCanvas(), SIGNAL( renderComplete( QPainter* ) ), this, SLOT( render( QPainter* ) ) );
|
||||
disconnect( mQGisIface->mainWindow(), SIGNAL( projectRead() ), this, SLOT( projectRead() ) );
|
||||
disconnect( mQGisIface->mainWindow(), SIGNAL( newProject() ), this, SLOT( newProject() ) );
|
||||
|
||||
@ -166,7 +166,7 @@ void RoadGraphPlugin::newProject()
|
||||
|
||||
void RoadGraphPlugin::property()
|
||||
{
|
||||
RgSettingsDlg dlg(mDirector, mQGisIface->mainWindow(), QgisGui::ModalDialogFlags );
|
||||
RgSettingsDlg dlg( mDirector, mQGisIface->mainWindow(), QgisGui::ModalDialogFlags );
|
||||
|
||||
dlg.setTimeUnitName( mTimeUnitName );
|
||||
dlg.setDistanceUnitName( mDistanceUnitName );
|
||||
@ -251,7 +251,7 @@ const RgGraphDirector* RoadGraphPlugin::director() const
|
||||
{
|
||||
return mDirector;
|
||||
}
|
||||
void RoadGraphPlugin::render(QPainter *painter)
|
||||
void RoadGraphPlugin::render( QPainter *painter )
|
||||
{
|
||||
if ( mDirector == NULL )
|
||||
return;
|
||||
@ -271,26 +271,26 @@ void RoadGraphPlugin::render(QPainter *painter)
|
||||
QgsPoint p1 = mQGisIface->mapCanvas()->getCoordinateTransform()->transform( it1->first );
|
||||
QgsPoint p2 = mQGisIface->mapCanvas()->getCoordinateTransform()->transform( it2->first );
|
||||
double x1 = p1.x(),
|
||||
y1 = p1.y(),
|
||||
x2 = p2.x(),
|
||||
y2 = p2.y();
|
||||
y1 = p1.y(),
|
||||
x2 = p2.x(),
|
||||
y2 = p2.y();
|
||||
|
||||
double length = sqrt( pow( x2-x1, 2.0) + pow( y2-y1, 2.0 ) );
|
||||
double Cos = (x2-x1)/length;
|
||||
double Sin = (y2-y1)/length;
|
||||
double centerX = (x1+x2)/2;
|
||||
double centerY = (y1+y2)/2;
|
||||
double length = sqrt( pow( x2 - x1, 2.0 ) + pow( y2 - y1, 2.0 ) );
|
||||
double Cos = ( x2 - x1 ) / length;
|
||||
double Sin = ( y2 - y1 ) / length;
|
||||
double centerX = ( x1 + x2 ) / 2;
|
||||
double centerY = ( y1 + y2 ) / 2;
|
||||
double r = mArrowSize;
|
||||
|
||||
QPointF pt1(centerX - Sin*r, centerY + Cos*r);
|
||||
QPointF pt2(centerX + Sin*r, centerY - Cos*r);
|
||||
QPointF pt1( centerX - Sin*r, centerY + Cos*r );
|
||||
QPointF pt2( centerX + Sin*r, centerY - Cos*r );
|
||||
|
||||
QVector<QPointF> tmp;
|
||||
tmp.resize(3);
|
||||
tmp[0] = QPointF( centerX + Cos*r*2, centerY + Sin*r*2 );
|
||||
tmp.resize( 3 );
|
||||
tmp[0] = QPointF( centerX + Cos * r * 2, centerY + Sin * r * 2 );
|
||||
tmp[1] = pt1;
|
||||
tmp[2] = pt2;
|
||||
painter->drawPolygon(tmp);
|
||||
painter->drawPolygon( tmp );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,121 +40,121 @@ class RgShortestPathWidget;
|
||||
*/
|
||||
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 theInterface Pointer to the QgisInterface object.
|
||||
*/
|
||||
RoadGraphPlugin( QgisInterface * theInterface );
|
||||
//! Destructor
|
||||
virtual ~RoadGraphPlugin();
|
||||
/**
|
||||
* return pointer to my Interface
|
||||
*/
|
||||
QgisInterface *iface();
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* Constructor for a plugin. The QgisInterface pointer is passed by
|
||||
* QGIS when it attempts to instantiate the plugin.
|
||||
* @param theInterface Pointer to the QgisInterface object.
|
||||
*/
|
||||
RoadGraphPlugin( QgisInterface * theInterface );
|
||||
//! Destructor
|
||||
virtual ~RoadGraphPlugin();
|
||||
/**
|
||||
* return pointer to my Interface
|
||||
*/
|
||||
QgisInterface *iface();
|
||||
|
||||
/**
|
||||
* return pointer to my Graph director
|
||||
*/
|
||||
const RgGraphDirector* director() const;
|
||||
/**
|
||||
* return pointer to my Graph director
|
||||
*/
|
||||
const RgGraphDirector* director() const;
|
||||
|
||||
/**
|
||||
* get time unit name
|
||||
*/
|
||||
QString timeUnitName();
|
||||
/**
|
||||
* get time unit name
|
||||
*/
|
||||
QString timeUnitName();
|
||||
|
||||
/**
|
||||
* get distance unit name
|
||||
*/
|
||||
QString distanceUnitName();
|
||||
/**
|
||||
* get distance unit name
|
||||
*/
|
||||
QString distanceUnitName();
|
||||
|
||||
public slots:
|
||||
void render(QPainter *painter);
|
||||
//! init the gui
|
||||
virtual void initGui();
|
||||
|
||||
//!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();
|
||||
|
||||
//! show the help document
|
||||
void help();
|
||||
public slots:
|
||||
void render( QPainter *painter );
|
||||
//! init the gui
|
||||
virtual void initGui();
|
||||
|
||||
//! show about window
|
||||
void about();
|
||||
private slots:
|
||||
/**
|
||||
* set show roads direction
|
||||
*/
|
||||
void onShowDirection();
|
||||
//!set values onthe gui when a project is read or the gui first loaded
|
||||
virtual void projectRead();
|
||||
|
||||
private:
|
||||
/**
|
||||
* set all gui elements to default status
|
||||
*/
|
||||
void setGuiElementsToDefault( );
|
||||
//!set default values for new project
|
||||
void newProject();
|
||||
|
||||
private:
|
||||
//! Show the property dialog box
|
||||
void property();
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MANDATORY PLUGIN PROPERTY DECLARATIONS .....
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int mPluginType;
|
||||
|
||||
//! Pointer to the QGIS interface object
|
||||
QgisInterface *mQGisIface;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// ADD YOUR OWN PROPERTY DECLARATIONS AFTER THIS POINT.....
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* on show settings
|
||||
*/
|
||||
QAction * mQSettingsAction;
|
||||
|
||||
/**
|
||||
* pointer ot the direction show action
|
||||
*/
|
||||
QAction * mQShowDirectionAction;
|
||||
|
||||
/**
|
||||
* pointer ot the about action
|
||||
*/
|
||||
QAction * mInfoAction;
|
||||
/**
|
||||
* GUI for use shortest path finder
|
||||
*/
|
||||
RgShortestPathWidget *mQShortestPathDock;
|
||||
//! unload the plugin
|
||||
void unload();
|
||||
|
||||
/**
|
||||
* My Graph Director
|
||||
*/
|
||||
RgGraphDirector *mDirector;
|
||||
//! show the help document
|
||||
void help();
|
||||
|
||||
/**
|
||||
* time unit for results presentation
|
||||
*/
|
||||
QString mTimeUnitName;
|
||||
//! show about window
|
||||
void about();
|
||||
private slots:
|
||||
/**
|
||||
* set show roads direction
|
||||
*/
|
||||
void onShowDirection();
|
||||
|
||||
/**
|
||||
* distance unit for results presentation
|
||||
*/
|
||||
QString mDistanceUnitName;
|
||||
private:
|
||||
static const int mArrowSize = 5;
|
||||
private:
|
||||
/**
|
||||
* set all gui elements to default status
|
||||
*/
|
||||
void setGuiElementsToDefault( );
|
||||
|
||||
private:
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MANDATORY PLUGIN PROPERTY DECLARATIONS .....
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
int mPluginType;
|
||||
|
||||
//! Pointer to the QGIS interface object
|
||||
QgisInterface *mQGisIface;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// ADD YOUR OWN PROPERTY DECLARATIONS AFTER THIS POINT.....
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* on show settings
|
||||
*/
|
||||
QAction * mQSettingsAction;
|
||||
|
||||
/**
|
||||
* pointer ot the direction show action
|
||||
*/
|
||||
QAction * mQShowDirectionAction;
|
||||
|
||||
/**
|
||||
* pointer ot the about action
|
||||
*/
|
||||
QAction * mInfoAction;
|
||||
/**
|
||||
* GUI for use shortest path finder
|
||||
*/
|
||||
RgShortestPathWidget *mQShortestPathDock;
|
||||
|
||||
/**
|
||||
* My Graph Director
|
||||
*/
|
||||
RgGraphDirector *mDirector;
|
||||
|
||||
/**
|
||||
* time unit for results presentation
|
||||
*/
|
||||
QString mTimeUnitName;
|
||||
|
||||
/**
|
||||
* distance unit for results presentation
|
||||
*/
|
||||
QString mDistanceUnitName;
|
||||
private:
|
||||
static const int mArrowSize = 5;
|
||||
};
|
||||
|
||||
#endif //ROADGRAPHPLUGIN
|
||||
|
@ -30,30 +30,30 @@ class QgsProject;
|
||||
*/
|
||||
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;
|
||||
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
|
||||
|
@ -27,21 +27,21 @@
|
||||
//standard includes
|
||||
|
||||
RgSettingsDlg::RgSettingsDlg( RgGraphDirector *director, QWidget* parent, Qt::WFlags fl )
|
||||
: mDirector(director), QDialog( parent, fl )
|
||||
: mDirector( director ), QDialog( parent, fl )
|
||||
{
|
||||
// create base widgets;
|
||||
setWindowTitle( tr("Road graph plugins settings") );
|
||||
setWindowTitle( tr( "Road graph plugins settings" ) );
|
||||
QVBoxLayout *v = new QVBoxLayout( this );
|
||||
|
||||
|
||||
QHBoxLayout *h = new QHBoxLayout();
|
||||
QLabel *l = new QLabel( tr("Plugins time unit:"), this );
|
||||
QLabel *l = new QLabel( tr( "Plugins time unit:" ), this );
|
||||
h->addWidget( l );
|
||||
mcbPluginsTimeUnit = new QComboBox( this );
|
||||
h->addWidget( mcbPluginsTimeUnit );
|
||||
v->addLayout( h );
|
||||
|
||||
h = new QHBoxLayout();
|
||||
l = new QLabel( tr("Plugins distance unit:"), this );
|
||||
l = new QLabel( tr( "Plugins distance unit:" ), this );
|
||||
h->addWidget( l );
|
||||
mcbPluginsDistanceUnit = new QComboBox( this );
|
||||
h->addWidget( mcbPluginsDistanceUnit );
|
||||
@ -55,18 +55,18 @@ RgSettingsDlg::RgSettingsDlg( RgGraphDirector *director, QWidget* parent, Qt::WF
|
||||
h->addWidget(mcbGraphDirector);
|
||||
v->addLayout(h);
|
||||
*/
|
||||
mSettingsWidget = director->settings()->getGui(this);
|
||||
mSettingsWidget = director->settings()->getGui( this );
|
||||
v->addWidget( mSettingsWidget );
|
||||
|
||||
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()) );
|
||||
connect( bb, SIGNAL( accepted() ), this, SLOT( on_buttonBox_accepted() ) );
|
||||
connect( bb, SIGNAL( rejected() ), this, SLOT( on_buttonBox_rejected() ) );
|
||||
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" ) );
|
||||
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()
|
||||
|
||||
@ -95,10 +95,10 @@ QString RgSettingsDlg::timeUnitName()
|
||||
return mcbPluginsTimeUnit->itemData( mcbPluginsTimeUnit->currentIndex() ).toString();
|
||||
}
|
||||
|
||||
void RgSettingsDlg::setTimeUnitName( const QString& name)
|
||||
void RgSettingsDlg::setTimeUnitName( const QString& name )
|
||||
{
|
||||
int i = mcbPluginsTimeUnit->findData( QVariant( name ) );
|
||||
if (i != -1)
|
||||
if ( i != -1 )
|
||||
{
|
||||
mcbPluginsTimeUnit->setCurrentIndex( i );
|
||||
}
|
||||
@ -109,10 +109,10 @@ QString RgSettingsDlg::distanceUnitName()
|
||||
return mcbPluginsDistanceUnit->itemData( mcbPluginsDistanceUnit->currentIndex() ).toString();
|
||||
}
|
||||
|
||||
void RgSettingsDlg::setDistanceUnitName( const QString& name)
|
||||
void RgSettingsDlg::setDistanceUnitName( const QString& name )
|
||||
{
|
||||
int i = mcbPluginsDistanceUnit->findData( QVariant( name ) );
|
||||
if (i != -1)
|
||||
if ( i != -1 )
|
||||
{
|
||||
mcbPluginsDistanceUnit->setCurrentIndex( i );
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
* 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
|
||||
|
||||
@ -36,44 +36,44 @@ class RgSettingsDlg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RgSettingsDlg( RgGraphDirector *director, QWidget* parent = 0, Qt::WFlags fl = 0 );
|
||||
~RgSettingsDlg();
|
||||
RgSettingsDlg( RgGraphDirector *director, QWidget* parent = 0, Qt::WFlags fl = 0 );
|
||||
~RgSettingsDlg();
|
||||
|
||||
QString timeUnitName();
|
||||
QString timeUnitName();
|
||||
|
||||
void setTimeUnitName( const QString& );
|
||||
void setTimeUnitName( const QString& );
|
||||
|
||||
QString distanceUnitName();
|
||||
|
||||
void setDistanceUnitName( const QString& );
|
||||
QString distanceUnitName();
|
||||
|
||||
private:
|
||||
static const int context_id = 0;
|
||||
void setDistanceUnitName( const QString& );
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
void on_buttonBox_rejected();
|
||||
void on_buttonBox_helpRequested();
|
||||
private:
|
||||
static const int context_id = 0;
|
||||
|
||||
private:
|
||||
// futurame by used
|
||||
QComboBox *mcbGraphDirector;
|
||||
|
||||
/**
|
||||
* current graph director
|
||||
*/
|
||||
RgGraphDirector *mDirector;
|
||||
|
||||
QWidget *mSettingsWidget;
|
||||
|
||||
/**
|
||||
* plugin distance unit
|
||||
*/
|
||||
QComboBox *mcbPluginsDistanceUnit;
|
||||
|
||||
/**
|
||||
* plugin time unit
|
||||
*/
|
||||
QComboBox *mcbPluginsTimeUnit;
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
void on_buttonBox_rejected();
|
||||
void on_buttonBox_helpRequested();
|
||||
|
||||
private:
|
||||
// futurame by used
|
||||
QComboBox *mcbGraphDirector;
|
||||
|
||||
/**
|
||||
* current graph director
|
||||
*/
|
||||
RgGraphDirector *mDirector;
|
||||
|
||||
QWidget *mSettingsWidget;
|
||||
|
||||
/**
|
||||
* plugin distance unit
|
||||
*/
|
||||
QComboBox *mcbPluginsDistanceUnit;
|
||||
|
||||
/**
|
||||
* plugin time unit
|
||||
*/
|
||||
QComboBox *mcbPluginsTimeUnit;
|
||||
};
|
||||
#endif
|
||||
|
@ -50,96 +50,96 @@
|
||||
|
||||
RgShortestPathWidget::RgShortestPathWidget( QWidget* theParent, RoadGraphPlugin *thePlugin ) : QDockWidget( theParent ), mPlugin( thePlugin )
|
||||
{
|
||||
setWindowTitle( tr("Shortest path") );
|
||||
setWindowTitle( tr( "Shortest path" ) );
|
||||
setObjectName( "ShortestPathDock" );
|
||||
setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
|
||||
|
||||
QWidget *myWidget = new QWidget(this);
|
||||
QWidget *myWidget = new QWidget( this );
|
||||
setWidget( myWidget );
|
||||
|
||||
QVBoxLayout *v = new QVBoxLayout( myWidget );
|
||||
QHBoxLayout *h = NULL;
|
||||
QLabel *l = NULL;
|
||||
|
||||
l = new QLabel(tr("Start:"), myWidget );
|
||||
|
||||
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") );
|
||||
selectFrontPoint->setIcon( QPixmap( ":/roadgraph/coordinate_capture.png" ) );
|
||||
h->addWidget( mFrontPointLineEdit );
|
||||
h->addWidget( selectFrontPoint );
|
||||
v->addLayout(h);
|
||||
v->addLayout( h );
|
||||
|
||||
l = new QLabel(tr("Stop:"), myWidget );
|
||||
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") );
|
||||
selectBackPoint->setIcon( QPixmap( ":/roadgraph/coordinate_capture.png" ) );
|
||||
h->addWidget( mBackPointLineEdit );
|
||||
h->addWidget( selectBackPoint );
|
||||
v->addLayout( h );
|
||||
|
||||
h = new QHBoxLayout( this );
|
||||
l = new QLabel(tr("Criterion:"), myWidget );
|
||||
l = new QLabel( tr( "Criterion:" ), myWidget );
|
||||
mCriterionName = new QComboBox( myWidget );
|
||||
mCriterionName->insertItem(0, tr("Length"));
|
||||
mCriterionName->insertItem(1, tr("Time") );
|
||||
mCriterionName->insertItem( 0, tr( "Length" ) );
|
||||
mCriterionName->insertItem( 1, tr( "Time" ) );
|
||||
h->addWidget( l );
|
||||
h->addWidget( mCriterionName );
|
||||
v->addLayout( h );
|
||||
|
||||
|
||||
h = new QHBoxLayout( myWidget );
|
||||
l = new QLabel( tr("Length:"), myWidget );
|
||||
l = new QLabel( tr( "Length:" ), myWidget );
|
||||
mPathCostLineEdit = new QLineEdit( myWidget );
|
||||
mPathCostLineEdit->setReadOnly ( true );
|
||||
mPathCostLineEdit->setReadOnly( true );
|
||||
h->addWidget( l );
|
||||
h->addWidget( mPathCostLineEdit );
|
||||
v->addLayout( h );
|
||||
|
||||
h = new QHBoxLayout( myWidget );
|
||||
l = new QLabel( tr("Time:"), myWidget );
|
||||
l = new QLabel( tr( "Time:" ), myWidget );
|
||||
mPathTimeLineEdit = new QLineEdit( myWidget );
|
||||
mPathTimeLineEdit->setReadOnly ( true );
|
||||
mPathTimeLineEdit->setReadOnly( true );
|
||||
h->addWidget( l );
|
||||
h->addWidget( mPathTimeLineEdit );
|
||||
v->addLayout( h );
|
||||
|
||||
|
||||
h = new QHBoxLayout( myWidget );
|
||||
mCalculate = new QPushButton( tr("Calculate"), myWidget );
|
||||
mCalculate = new QPushButton( tr( "Calculate" ), myWidget );
|
||||
h->addWidget( mCalculate );
|
||||
QPushButton *pbExport = new QPushButton( tr("Export"), myWidget );
|
||||
QPushButton *pbExport = new QPushButton( tr( "Export" ), myWidget );
|
||||
h->addWidget( pbExport );
|
||||
|
||||
connect( pbExport, SIGNAL( clicked(bool) ), this, SLOT(exportPath()) );
|
||||
|
||||
mClear = new QPushButton( tr("Clear"), myWidget );
|
||||
|
||||
connect( pbExport, SIGNAL( clicked( bool ) ), this, SLOT( exportPath() ) );
|
||||
|
||||
mClear = new QPushButton( tr( "Clear" ), myWidget );
|
||||
h->addWidget( mClear );
|
||||
v->addLayout( h );
|
||||
v->addStretch();
|
||||
|
||||
mFrontPointMapTool = new QgsMapToolEmitPoint( mPlugin->iface()->mapCanvas() );
|
||||
mFrontPointMapTool->setButton ( selectFrontPoint );
|
||||
|
||||
mFrontPointMapTool->setButton( selectFrontPoint );
|
||||
|
||||
mBackPointMapTool = new QgsMapToolEmitPoint( mPlugin->iface()->mapCanvas() );
|
||||
mBackPointMapTool->setButton ( selectBackPoint );
|
||||
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( 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( selectBackPoint, SIGNAL( clicked( bool ) ), this, SLOT( onSelectBackPoint() ) );
|
||||
connect( mBackPointMapTool, SIGNAL( canvasClicked( const QgsPoint&, Qt::MouseButton ) ),
|
||||
this, SLOT( setBackPoint( const QgsPoint& ) ) );
|
||||
|
||||
connect( mCalculate, SIGNAL( clicked( bool ) ), this, SLOT( findingPath() ) );
|
||||
connect( mClear, SIGNAL( clicked( bool ) ), this, SLOT( clear() ) );
|
||||
|
||||
connect( mCalculate, SIGNAL(clicked(bool) ), this, SLOT( findingPath() ) );
|
||||
connect( mClear, SIGNAL(clicked(bool)), this, SLOT(clear()) );
|
||||
|
||||
mrbFrontPoint = new QgsRubberBand( mPlugin->iface()->mapCanvas(), true );
|
||||
mrbFrontPoint->setColor( Qt::green );
|
||||
mrbFrontPoint->setWidth( 2 );
|
||||
@ -151,7 +151,7 @@ RgShortestPathWidget::RgShortestPathWidget( QWidget* theParent, RoadGraphPlugin
|
||||
mrbPath = new QgsRubberBand( mPlugin->iface()->mapCanvas(), false );
|
||||
mrbPath->setWidth( 2 );
|
||||
|
||||
connect(mPlugin->iface()->mapCanvas(), SIGNAL( extentsChanged() ), this, SLOT( mapCanvasExtentsChanged() ) );
|
||||
connect( mPlugin->iface()->mapCanvas(), SIGNAL( extentsChanged() ), this, SLOT( mapCanvasExtentsChanged() ) );
|
||||
|
||||
} //RgShortestPathWidget::RgShortestPathWidget()
|
||||
RgShortestPathWidget::~RgShortestPathWidget()
|
||||
@ -169,7 +169,7 @@ void RgShortestPathWidget::mapCanvasExtentsChanged()
|
||||
// update rubberbands
|
||||
if ( mFrontPointLineEdit->text().length() > 0 )
|
||||
setFrontPoint( mFrontPoint );
|
||||
if ( mBackPointLineEdit->text().length() > 0 )
|
||||
if ( mBackPointLineEdit->text().length() > 0 )
|
||||
setBackPoint( mBackPoint );
|
||||
}
|
||||
|
||||
@ -181,17 +181,17 @@ void RgShortestPathWidget::onSelectFrontPoint()
|
||||
void RgShortestPathWidget::setFrontPoint( const QgsPoint& pt )
|
||||
{
|
||||
mPlugin->iface()->mapCanvas()->unsetMapTool( mFrontPointMapTool );
|
||||
mFrontPointLineEdit->setText( QString("(")+QString().setNum(pt.x()) + QString(",") +
|
||||
QString().setNum(pt.y()) + QString(")") );
|
||||
mFrontPointLineEdit->setText( QString( "(" ) + QString().setNum( pt.x() ) + QString( "," ) +
|
||||
QString().setNum( pt.y() ) + QString( ")" ) );
|
||||
mFrontPoint = pt;
|
||||
|
||||
double mupp = mPlugin->iface()->mapCanvas()->getCoordinateTransform()->mapUnitsPerPixel()*2;
|
||||
double mupp = mPlugin->iface()->mapCanvas()->getCoordinateTransform()->mapUnitsPerPixel() * 2;
|
||||
|
||||
mrbFrontPoint->reset(true);
|
||||
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->reset( true );
|
||||
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 )
|
||||
|
||||
@ -203,43 +203,43 @@ void RgShortestPathWidget::onSelectBackPoint()
|
||||
void RgShortestPathWidget::setBackPoint( const QgsPoint& pt )
|
||||
{
|
||||
mPlugin->iface()->mapCanvas()->unsetMapTool( mBackPointMapTool );
|
||||
|
||||
mBackPoint = pt;
|
||||
mBackPointLineEdit->setText( QString("(")+QString().setNum(pt.x()) + QString(",") +
|
||||
QString().setNum(pt.y()) + QString(")") );
|
||||
|
||||
double mupp = mPlugin->iface()->mapCanvas()->getCoordinateTransform()->mapUnitsPerPixel()*2;
|
||||
|
||||
mrbBackPoint->reset(true);
|
||||
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 );
|
||||
mBackPoint = pt;
|
||||
mBackPointLineEdit->setText( QString( "(" ) + QString().setNum( pt.x() ) + QString( "," ) +
|
||||
QString().setNum( pt.y() ) + QString( ")" ) );
|
||||
|
||||
double mupp = mPlugin->iface()->mapCanvas()->getCoordinateTransform()->mapUnitsPerPixel() * 2;
|
||||
|
||||
mrbBackPoint->reset( true );
|
||||
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();
|
||||
}
|
||||
|
||||
bool RgShortestPathWidget::getPath(AdjacencyMatrix& matrix, QgsPoint& p1, QgsPoint& p2)
|
||||
bool RgShortestPathWidget::getPath( AdjacencyMatrix& matrix, QgsPoint& p1, QgsPoint& p2 )
|
||||
{
|
||||
if ( mFrontPointLineEdit->text().isNull() || mBackPointLineEdit->text().isNull() )
|
||||
return false;
|
||||
return false;
|
||||
RgSimpleGraphBuilder builder;
|
||||
builder.setDestinationCrs ( mPlugin->iface()->mapCanvas()->mapRenderer()->destinationSrs() );
|
||||
mPlugin->director()->makeGraph(&builder);
|
||||
builder.setDestinationCrs( mPlugin->iface()->mapCanvas()->mapRenderer()->destinationSrs() );
|
||||
mPlugin->director()->makeGraph( &builder );
|
||||
bool ok;
|
||||
|
||||
p1 = builder.tiePoint(mFrontPoint, ok);
|
||||
p1 = builder.tiePoint( mFrontPoint, ok );
|
||||
if ( !ok )
|
||||
return false;
|
||||
p2 = builder.tiePoint(mBackPoint, ok);
|
||||
p2 = builder.tiePoint( mBackPoint, ok );
|
||||
if ( !ok )
|
||||
return false;
|
||||
AdjacencyMatrix m = builder.adjacencyMatrix();
|
||||
|
||||
DijkstraFinder::OptimizationCriterion criterion = DijkstraFinder::byCost;
|
||||
if (mCriterionName->currentIndex() == 1)
|
||||
if ( mCriterionName->currentIndex() == 1 )
|
||||
criterion = DijkstraFinder::byTime;
|
||||
|
||||
DijkstraFinder f(m, criterion);
|
||||
|
||||
DijkstraFinder f( m, criterion );
|
||||
|
||||
matrix = f.find( p1, p2 );
|
||||
|
||||
@ -250,13 +250,13 @@ void RgShortestPathWidget::findingPath()
|
||||
{
|
||||
QgsPoint p1, p2;
|
||||
AdjacencyMatrix path;
|
||||
if ( !getPath(path, p1, p2) )
|
||||
if ( !getPath( path, p1, p2 ) )
|
||||
return;
|
||||
|
||||
mrbPath->reset( false );
|
||||
double time = 0.0;
|
||||
double cost = 0.0;
|
||||
|
||||
|
||||
AdjacencyMatrix::iterator it = path.find( p1 );
|
||||
if ( it == path.end() )
|
||||
return;
|
||||
@ -275,45 +275,45 @@ void RgShortestPathWidget::findingPath()
|
||||
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() );
|
||||
mPathCostLineEdit->setText( QString().setNum( cost / distanceUnit.multipler() ) + distanceUnit.name() );
|
||||
mPathTimeLineEdit->setText( QString().setNum( time / timeUnit.multipler() ) + timeUnit.name() );
|
||||
|
||||
mrbPath->setColor( Qt::red );
|
||||
}
|
||||
|
||||
void RgShortestPathWidget::clear()
|
||||
{
|
||||
mFrontPointLineEdit->setText(QString());
|
||||
mrbFrontPoint->reset(true);
|
||||
mBackPointLineEdit->setText(QString());
|
||||
mrbBackPoint->reset(true);
|
||||
mFrontPointLineEdit->setText( QString() );
|
||||
mrbFrontPoint->reset( true );
|
||||
mBackPointLineEdit->setText( QString() );
|
||||
mrbBackPoint->reset( true );
|
||||
mrbPath->reset();
|
||||
}
|
||||
|
||||
void RgShortestPathWidget::exportPath()
|
||||
{
|
||||
RgExportDlg dlg(this);
|
||||
RgExportDlg dlg( this );
|
||||
if ( !dlg.exec() )
|
||||
return;
|
||||
|
||||
QgsPoint p1,p2;
|
||||
|
||||
QgsPoint p1, p2;
|
||||
AdjacencyMatrix path;
|
||||
if ( !getPath( path, p1, p2 ) )
|
||||
return;
|
||||
|
||||
QgsVectorLayer *vl = dlg.mapLayer();
|
||||
if ( vl == NULL )
|
||||
return;
|
||||
|
||||
QgsCoordinateTransform ct( mPlugin->iface()->mapCanvas()->mapRenderer()->destinationSrs(),
|
||||
vl->crs() );
|
||||
QgsVectorLayer *vl = dlg.mapLayer();
|
||||
if ( vl == NULL )
|
||||
return;
|
||||
|
||||
QgsCoordinateTransform ct( mPlugin->iface()->mapCanvas()->mapRenderer()->destinationSrs(),
|
||||
vl->crs() );
|
||||
|
||||
QVector< QgsPoint > points;
|
||||
AdjacencyMatrix::iterator it = path.find( p1 );
|
||||
if ( it == path.end() )
|
||||
return;
|
||||
points.append( ct.transform( it->first ) );
|
||||
|
||||
|
||||
while ( it != path.end() )
|
||||
{
|
||||
AdjacencyMatrixString::iterator it2 = it->second.begin();
|
||||
@ -328,7 +328,7 @@ void RgShortestPathWidget::exportPath()
|
||||
f.setGeometry( QgsGeometry::fromPolyline( points ) );
|
||||
vl->addFeature( f );
|
||||
vl->updateExtents();
|
||||
|
||||
|
||||
mPlugin->iface()->mapCanvas()->update();
|
||||
|
||||
|
||||
}
|
||||
|
@ -20,9 +20,9 @@
|
||||
// Qgis includes
|
||||
#include <qgspoint.h>
|
||||
|
||||
// standart includes
|
||||
// standard includes
|
||||
|
||||
// forward declaration
|
||||
// forward declaration
|
||||
|
||||
class QComboBox;
|
||||
class QLineEdit;
|
||||
@ -43,137 +43,137 @@ class RoadGraphPlugin;
|
||||
*/
|
||||
class RgShortestPathWidget : public QDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* Standart construct
|
||||
*/
|
||||
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();
|
||||
|
||||
/**
|
||||
* retrun path as a graph
|
||||
*/
|
||||
bool getPath(AdjacencyMatrix &m, QgsPoint& p1, QgsPoint& p2);
|
||||
private:
|
||||
/**
|
||||
* 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;
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* Standard constructor
|
||||
*/
|
||||
RgShortestPathWidget( QWidget * , RoadGraphPlugin * );
|
||||
|
||||
/**
|
||||
* this button called to find shortest path
|
||||
*/
|
||||
QPushButton *mCalculate;
|
||||
|
||||
/**
|
||||
* this button called to clear line edits and clar current path
|
||||
*/
|
||||
QPushButton *mClear;
|
||||
/**
|
||||
* destructor
|
||||
*/
|
||||
~RgShortestPathWidget();
|
||||
|
||||
/**
|
||||
* this map tool use for select coordinates
|
||||
*/
|
||||
QgsMapToolEmitPoint *mFrontPointMapTool;
|
||||
|
||||
/**
|
||||
* this map tool use for select coordinates
|
||||
*/
|
||||
QgsMapToolEmitPoint *mBackPointMapTool;
|
||||
private slots:
|
||||
/**
|
||||
* export path
|
||||
*/
|
||||
void exportPath();
|
||||
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* retrun path as a graph
|
||||
*/
|
||||
bool getPath( AdjacencyMatrix &m, QgsPoint& p1, QgsPoint& p2 );
|
||||
private:
|
||||
/**
|
||||
* 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
|
||||
|
@ -49,17 +49,17 @@ void RgSimpleGraphBuilder::setDestinationCrs( const QgsCoordinateReferenceSystem
|
||||
|
||||
void RgSimpleGraphBuilder::addVertex( const QgsPoint& pt )
|
||||
{
|
||||
mMatrix[ mCoordinateTransform->transform(pt) ];
|
||||
mMatrix[ mCoordinateTransform->transform( pt )];
|
||||
}
|
||||
|
||||
void RgSimpleGraphBuilder::addArc( const QgsPoint& pt1, const QgsPoint& pt2, double speed )
|
||||
{
|
||||
QgsPoint p1 = mCoordinateTransform->transform(pt1);
|
||||
QgsPoint p2 = mCoordinateTransform->transform(pt2);
|
||||
|
||||
QgsPoint p1 = mCoordinateTransform->transform( pt1 );
|
||||
QgsPoint p2 = mCoordinateTransform->transform( pt2 );
|
||||
|
||||
double distance = mDistanceArea->measureLine( p1, p2 );
|
||||
double time = distance/speed;
|
||||
mMatrix[ p1 ][ p2 ] = ArcAttributes(distance, time, 0);
|
||||
double time = distance / speed;
|
||||
mMatrix[ p1 ][ p2 ] = ArcAttributes( distance, time, 0 );
|
||||
}
|
||||
|
||||
QgsPoint RgSimpleGraphBuilder::tiePoint( const QgsPoint &pt, bool &b )
|
||||
@ -67,7 +67,7 @@ QgsPoint RgSimpleGraphBuilder::tiePoint( const QgsPoint &pt, bool &b )
|
||||
b = false;
|
||||
AdjacencyMatrix::iterator it1;
|
||||
AdjacencyMatrixString::iterator it2;
|
||||
|
||||
|
||||
double min = infinity();
|
||||
QgsPoint minP1, minP2;
|
||||
QgsPoint center;
|
||||
@ -76,8 +76,8 @@ QgsPoint RgSimpleGraphBuilder::tiePoint( const QgsPoint &pt, bool &b )
|
||||
for ( it2 = it1->second.begin(); it2 != it1->second.end(); ++it2 )
|
||||
{
|
||||
QgsPoint c;
|
||||
double d = distance(it1->first, it2->first, pt, c);
|
||||
if (d < min)
|
||||
double d = distance( it1->first, it2->first, pt, c );
|
||||
if ( d < min )
|
||||
{
|
||||
minP1 = it1->first;
|
||||
minP2 = it2->first;
|
||||
@ -88,23 +88,23 @@ QgsPoint RgSimpleGraphBuilder::tiePoint( const QgsPoint &pt, bool &b )
|
||||
}
|
||||
if ( min >= infinity() )
|
||||
return center;
|
||||
|
||||
|
||||
double c = mMatrix[ minP1 ][ minP2 ].mCost;
|
||||
double t = mMatrix[ minP1 ][ minP2 ].mTime;
|
||||
|
||||
double newArcLength = mDistanceArea->measureLine( minP1, center );
|
||||
mMatrix[ minP1 ][ center ] = ArcAttributes( newArcLength, t*newArcLength/c, 0);
|
||||
mMatrix[ minP1 ][ center ] = ArcAttributes( newArcLength, t * newArcLength / c, 0 );
|
||||
newArcLength = mDistanceArea->measureLine( center, minP2 );
|
||||
mMatrix[ center ][ minP2 ] = ArcAttributes( newArcLength, t*newArcLength/c, 0 );
|
||||
mMatrix[ center ][ minP2 ] = ArcAttributes( newArcLength, t * newArcLength / c, 0 );
|
||||
|
||||
if ( mMatrix[ minP2 ].find( minP1 ) != mMatrix[ minP2 ].end() )
|
||||
{
|
||||
c = mMatrix[ minP2 ][ minP1 ].mCost;
|
||||
t = mMatrix[ minP2 ][ minP1 ].mTime;
|
||||
newArcLength = mDistanceArea->measureLine( center, minP1 );
|
||||
mMatrix[ center ][ minP1 ] = ArcAttributes( newArcLength, t*newArcLength/c, 0);
|
||||
mMatrix[ center ][ minP1 ] = ArcAttributes( newArcLength, t * newArcLength / c, 0 );
|
||||
newArcLength = mDistanceArea->measureLine( minP2, center );
|
||||
mMatrix[ minP2 ][ center ] = ArcAttributes( newArcLength, t*newArcLength/c, 0);
|
||||
mMatrix[ minP2 ][ center ] = ArcAttributes( newArcLength, t * newArcLength / c, 0 );
|
||||
}
|
||||
|
||||
mMatrix[minP1].erase( minP2 );
|
||||
@ -115,5 +115,5 @@ QgsPoint RgSimpleGraphBuilder::tiePoint( const QgsPoint &pt, bool &b )
|
||||
|
||||
AdjacencyMatrix RgSimpleGraphBuilder::adjacencyMatrix()
|
||||
{
|
||||
return mMatrix;
|
||||
return mMatrix;
|
||||
}
|
||||
|
@ -34,30 +34,30 @@ class QgsCoordinateTransform;
|
||||
|
||||
class RgSimpleGraphBuilder : public RgGraphBuilder
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* default constructor
|
||||
*/
|
||||
RgSimpleGraphBuilder();
|
||||
/**
|
||||
* MANDATORY DIRECTOR PROPERTY DECLARATION
|
||||
*/
|
||||
~RgSimpleGraphBuilder();
|
||||
void setSourceCrs( const QgsCoordinateReferenceSystem& crs );
|
||||
void setDestinationCrs( const QgsCoordinateReferenceSystem& crs );
|
||||
void addVertex( const QgsPoint& pt );
|
||||
void addArc( const QgsPoint& pt1, const QgsPoint& pt2, double speed );
|
||||
QgsPoint tiePoint( const QgsPoint& pt, bool& ok );
|
||||
|
||||
/**
|
||||
* return Adjacecncy matrix;
|
||||
*/
|
||||
AdjacencyMatrix adjacencyMatrix();
|
||||
private:
|
||||
AdjacencyMatrix mMatrix;
|
||||
|
||||
QgsDistanceArea* mDistanceArea;
|
||||
public:
|
||||
/**
|
||||
* default constructor
|
||||
*/
|
||||
RgSimpleGraphBuilder();
|
||||
/**
|
||||
* MANDATORY DIRECTOR PROPERTY DECLARATION
|
||||
*/
|
||||
~RgSimpleGraphBuilder();
|
||||
void setSourceCrs( const QgsCoordinateReferenceSystem& crs );
|
||||
void setDestinationCrs( const QgsCoordinateReferenceSystem& crs );
|
||||
void addVertex( const QgsPoint& pt );
|
||||
void addArc( const QgsPoint& pt1, const QgsPoint& pt2, double speed );
|
||||
QgsPoint tiePoint( const QgsPoint& pt, bool& ok );
|
||||
|
||||
QgsCoordinateTransform* mCoordinateTransform;
|
||||
/**
|
||||
* return Adjacecncy matrix;
|
||||
*/
|
||||
AdjacencyMatrix adjacencyMatrix();
|
||||
private:
|
||||
AdjacencyMatrix mMatrix;
|
||||
|
||||
QgsDistanceArea* mDistanceArea;
|
||||
|
||||
QgsCoordinateTransform* mCoordinateTransform;
|
||||
};
|
||||
#endif //SIMPLEGRAPHBUILDER
|
||||
|
@ -23,8 +23,8 @@ Unit::Unit()
|
||||
mMultipler = 1.0;
|
||||
}
|
||||
|
||||
Unit::Unit(const QString& name, double multipler) :
|
||||
mName(name), mMultipler(multipler)
|
||||
Unit::Unit( const QString& name, double multipler ) :
|
||||
mName( name ), mMultipler( multipler )
|
||||
{
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ double Unit::multipler() const
|
||||
{
|
||||
return mMultipler;
|
||||
}
|
||||
Unit Unit::byName( const QString& name)
|
||||
Unit Unit::byName( const QString& name )
|
||||
{
|
||||
if ( name == "h" )
|
||||
return Unit( name, 60*60 );
|
||||
@ -51,43 +51,43 @@ Unit Unit::byName( const QString& name)
|
||||
}
|
||||
|
||||
SpeedUnit::SpeedUnit() :
|
||||
mTimeUnit("",1), mDistanceUnit("",1)
|
||||
mTimeUnit( "", 1 ), mDistanceUnit( "", 1 )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
SpeedUnit::SpeedUnit( const Unit& distanceUnit, const Unit& timeUnit) :
|
||||
mTimeUnit( timeUnit ), mDistanceUnit( distanceUnit )
|
||||
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() + QString("/") + mTimeUnit.name();
|
||||
return mDistanceUnit.name() + QString( "/" ) + mTimeUnit.name();
|
||||
}
|
||||
|
||||
SpeedUnit SpeedUnit::byName( const QString& name )
|
||||
{
|
||||
if ( name=="km/h" )
|
||||
return SpeedUnit( Unit::byName("km"), Unit::byName("h") );
|
||||
else if ( name=="m/s" )
|
||||
return SpeedUnit( Unit::byName("m"), Unit::byName("s") );
|
||||
if ( name == "km/h" )
|
||||
return SpeedUnit( Unit::byName( "km" ), Unit::byName( "h" ) );
|
||||
else if ( name == "m/s" )
|
||||
return SpeedUnit( Unit::byName( "m" ), Unit::byName( "s" ) );
|
||||
return SpeedUnit();
|
||||
}
|
||||
|
||||
double SpeedUnit::multipler() const
|
||||
{
|
||||
return mDistanceUnit.multipler()/mTimeUnit.multipler();
|
||||
{
|
||||
return mDistanceUnit.multipler() / mTimeUnit.multipler();
|
||||
}
|
||||
|
||||
Unit SpeedUnit::timeUnit() const
|
||||
{
|
||||
return mTimeUnit;
|
||||
{
|
||||
return mTimeUnit;
|
||||
}
|
||||
|
||||
Unit SpeedUnit::distanceUnit() const
|
||||
{
|
||||
return mDistanceUnit;
|
||||
{
|
||||
return mDistanceUnit;
|
||||
}
|
||||
|
@ -32,59 +32,59 @@
|
||||
*/
|
||||
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;
|
||||
public:
|
||||
/**
|
||||
* default constructor
|
||||
*/
|
||||
Unit();
|
||||
|
||||
/**
|
||||
* return unit by name
|
||||
*/
|
||||
static Unit byName( const QString& name );
|
||||
private:
|
||||
|
||||
/**
|
||||
* units name
|
||||
*/
|
||||
QString mName;
|
||||
|
||||
/**
|
||||
* units multipler
|
||||
*/
|
||||
double mMultipler;
|
||||
/**
|
||||
* 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 );
|
||||
public:
|
||||
SpeedUnit();
|
||||
SpeedUnit( const Unit& distanceUnit, const Unit& timeUnit );
|
||||
|
||||
QString name() const;
|
||||
double multipler() const;
|
||||
QString name() const;
|
||||
double multipler() const;
|
||||
|
||||
Unit timeUnit() const;
|
||||
Unit distanceUnit() const;
|
||||
|
||||
static SpeedUnit byName( const QString& name );
|
||||
protected:
|
||||
Unit mTimeUnit;
|
||||
Unit mDistanceUnit;
|
||||
Unit timeUnit() const;
|
||||
Unit distanceUnit() const;
|
||||
|
||||
static SpeedUnit byName( const QString& name );
|
||||
protected:
|
||||
Unit mTimeUnit;
|
||||
Unit mDistanceUnit;
|
||||
};
|
||||
#endif
|
||||
|
@ -22,7 +22,7 @@
|
||||
// Qgis includes
|
||||
#include <qgspoint.h>
|
||||
|
||||
// standart includes
|
||||
// standard includes
|
||||
#include <set>
|
||||
#include <cmath>
|
||||
|
||||
@ -34,35 +34,35 @@ double infinity()
|
||||
// return distance between line of two points and center
|
||||
double distance( const QgsPoint& p1, const QgsPoint& p2, const QgsPoint& p, QgsPoint& center )
|
||||
{
|
||||
|
||||
|
||||
// first line
|
||||
double A1,B1,C1;
|
||||
double A1, B1, C1;
|
||||
A1 = p1.y() - p2.y();
|
||||
B1 = p2.x() - p1.x();
|
||||
C1 = p1.x()*(-A1) + p1.y()*(-B1);
|
||||
|
||||
C1 = p1.x() * ( -A1 ) + p1.y() * ( -B1 );
|
||||
|
||||
// second line. First and second line is perpendicular.
|
||||
double A2,B2,C2;
|
||||
double A2, B2, C2;
|
||||
A2 = B1;
|
||||
B2 = -A1;
|
||||
C2 = -p.x()*A2 - p.y()*B2;
|
||||
C2 = -p.x() * A2 - p.y() * B2;
|
||||
|
||||
// union point
|
||||
double x,y,det;
|
||||
det = A1*B2 - B1*A2;
|
||||
x = (C2*B1 - B2*C1)/det;
|
||||
y = (-A1*C2 + C1*A2)/det;
|
||||
|
||||
center = QgsPoint(x,y);
|
||||
|
||||
det = sqrt(A1*A1+B1*B1);
|
||||
double x, y, det;
|
||||
det = A1 * B2 - B1 * A2;
|
||||
x = ( C2 * B1 - B2 * C1 ) / det;
|
||||
y = ( -A1 * C2 + C1 * A2 ) / det;
|
||||
|
||||
center = QgsPoint( x, y );
|
||||
|
||||
det = sqrt( A1 * A1 + B1 * B1 );
|
||||
A1 /= det;
|
||||
B1 /= det;
|
||||
C1 /= det;
|
||||
if ( std::min( p1.x(), p2.x() ) <= x && std::max( p1.x(), p2.x() ) >= x &&
|
||||
std::min( p1.y(), p2.y() ) <= y && std::max( p1.y(), p2.y() ) >= y )
|
||||
return std::abs( A1*p.x()+B1*p.y()+C1 );
|
||||
|
||||
std::min( p1.y(), p2.y() ) <= y && std::max( p1.y(), p2.y() ) >= y )
|
||||
return std::abs( A1*p.x() + B1*p.y() + C1 );
|
||||
|
||||
return infinity();
|
||||
}// RoadGraphPlugin::distance()
|
||||
|
||||
@ -78,14 +78,14 @@ ArcAttributes::ArcAttributes()
|
||||
mTime = infinity();
|
||||
}
|
||||
ArcAttributes::ArcAttributes( double cost, double time, int featureId ) :
|
||||
mCost( cost ), mTime( time ), mFeatureId( featureId )
|
||||
mCost( cost ), mTime( time ), mFeatureId( featureId )
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
DijkstraFinder::DijkstraFinder( const AdjacencyMatrix& m, DijkstraFinder::OptimizationCriterion c ):
|
||||
mAdjacencyMatrix (m), mCriterion(c)
|
||||
mAdjacencyMatrix( m ), mCriterion( c )
|
||||
{
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ std::map< QgsPoint , DijkstraFinder::DijkstraIterator, QgsPointCompare> Dijkstra
|
||||
std::set< DijkstraIterator, CompareDijkstraIterator > not_begin( ci );
|
||||
std::set< DijkstraIterator, CompareDijkstraIterator >::iterator it;
|
||||
std::map< QgsPoint, DijkstraIterator, QgsPointCompare> res;
|
||||
if (mAdjacencyMatrix.find( p ) == mAdjacencyMatrix.end() )
|
||||
if ( mAdjacencyMatrix.find( p ) == mAdjacencyMatrix.end() )
|
||||
{
|
||||
return res;
|
||||
}
|
||||
@ -122,13 +122,13 @@ std::map< QgsPoint , DijkstraFinder::DijkstraIterator, QgsPointCompare> Dijkstra
|
||||
continue;
|
||||
}
|
||||
end = mAdjacencyMatrix.find( i.mBackPoint )->second.end();
|
||||
for (arcIt = mAdjacencyMatrix.find( i.mBackPoint )->second.begin(); arcIt != end; ++arcIt)
|
||||
for ( arcIt = mAdjacencyMatrix.find( i.mBackPoint )->second.begin(); arcIt != end; ++arcIt )
|
||||
{
|
||||
DijkstraIterator di = i;
|
||||
di.mCost += arcIt->second.mCost;
|
||||
di.mTime += arcIt->second.mTime;
|
||||
|
||||
if ( ci(di, res[ arcIt->first ] ) )
|
||||
if ( ci( di, res[ arcIt->first ] ) )
|
||||
{
|
||||
di.mFrontPoint = di.mBackPoint;
|
||||
di.mBackPoint = arcIt->first;
|
||||
@ -151,7 +151,7 @@ AdjacencyMatrix DijkstraFinder::find( const QgsPoint& frontPoint, const QgsPoint
|
||||
|
||||
AdjacencyMatrix m;
|
||||
QgsPoint nextPoint = backPoint;
|
||||
QgsPoint firstPoint = backPoint;
|
||||
QgsPoint firstPoint = backPoint;
|
||||
while ( true )
|
||||
{
|
||||
if ( firstPoint != nextPoint )
|
||||
|
@ -18,7 +18,7 @@
|
||||
// Qgis includes
|
||||
#include "qgspoint.h"
|
||||
|
||||
// standart includes
|
||||
// standard includes
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
double infinity();
|
||||
|
||||
/**
|
||||
* return distance from lenght <x1,y1><x2,y2> to point <x,y> or infinity() value
|
||||
* return distance from length <x1,y1><x2,y2> to point <x,y> or infinity() value
|
||||
* in union point
|
||||
*/
|
||||
double distance( const QgsPoint& p1, const QgsPoint& p2, const QgsPoint& p, QgsPoint& center );
|
||||
@ -47,8 +47,8 @@ double distance( const QgsPoint& p1, const QgsPoint& p2, const QgsPoint& p, QgsP
|
||||
*/
|
||||
class QgsPointCompare
|
||||
{
|
||||
public:
|
||||
bool operator()( const QgsPoint& a, const QgsPoint& b ) const;
|
||||
public:
|
||||
bool operator()( const QgsPoint& a, const QgsPoint& b ) const;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -57,13 +57,13 @@ public:
|
||||
*/
|
||||
class ArcAttributes
|
||||
{
|
||||
public:
|
||||
ArcAttributes();
|
||||
ArcAttributes( double cost, double time, int mFeatureId );
|
||||
public:
|
||||
double mCost;
|
||||
double mTime;
|
||||
int mFeatureId;
|
||||
public:
|
||||
ArcAttributes();
|
||||
ArcAttributes( double cost, double time, int mFeatureId );
|
||||
public:
|
||||
double mCost;
|
||||
double mTime;
|
||||
int mFeatureId;
|
||||
};
|
||||
|
||||
typedef std::map< QgsPoint, ArcAttributes, QgsPointCompare > AdjacencyMatrixString;
|
||||
@ -74,63 +74,65 @@ typedef std::map< QgsPoint, AdjacencyMatrixString, QgsPointCompare > AdjacencyM
|
||||
* \class DijkstraFinder
|
||||
* \brief This class find shortest path via two points using Dijkstra's algorithm
|
||||
*/
|
||||
class DijkstraFinder
|
||||
class DijkstraFinder
|
||||
{
|
||||
public:
|
||||
enum OptimizationCriterion { byTime=1, byCost=2 };
|
||||
private:
|
||||
class DijkstraIterator {
|
||||
public:
|
||||
DijkstraIterator()
|
||||
{
|
||||
mCost = infinity();
|
||||
mTime = infinity();
|
||||
}
|
||||
double mCost;
|
||||
double mTime;
|
||||
QgsPoint mBackPoint;
|
||||
QgsPoint mFrontPoint;
|
||||
};
|
||||
class CompareDijkstraIterator {
|
||||
public:
|
||||
CompareDijkstraIterator( OptimizationCriterion criterion = byCost ) :
|
||||
mCriterion( criterion )
|
||||
{ }
|
||||
bool operator()( const DijkstraIterator& a, const DijkstraIterator& b ) const
|
||||
{
|
||||
if ( mCriterion == byCost )
|
||||
{
|
||||
return a.mCost < b.mCost;
|
||||
}
|
||||
return a.mTime < b.mTime;
|
||||
}
|
||||
bool operator==( const CompareDijkstraIterator& a ) const
|
||||
{
|
||||
return mCriterion == a.mCriterion;
|
||||
}
|
||||
enum OptimizationCriterion { byTime = 1, byCost = 2 };
|
||||
private:
|
||||
OptimizationCriterion mCriterion;
|
||||
};
|
||||
public:
|
||||
/**
|
||||
* constructor.
|
||||
* m is adjacency matrix of graph, criterion is a citerion of shortest path
|
||||
*/
|
||||
DijkstraFinder( const AdjacencyMatrix &m, OptimizationCriterion criterion );
|
||||
class DijkstraIterator
|
||||
{
|
||||
public:
|
||||
DijkstraIterator()
|
||||
{
|
||||
mCost = infinity();
|
||||
mTime = infinity();
|
||||
}
|
||||
double mCost;
|
||||
double mTime;
|
||||
QgsPoint mBackPoint;
|
||||
QgsPoint mFrontPoint;
|
||||
};
|
||||
class CompareDijkstraIterator
|
||||
{
|
||||
public:
|
||||
CompareDijkstraIterator( OptimizationCriterion criterion = byCost ) :
|
||||
mCriterion( criterion )
|
||||
{ }
|
||||
bool operator()( const DijkstraIterator& a, const DijkstraIterator& b ) const
|
||||
{
|
||||
if ( mCriterion == byCost )
|
||||
{
|
||||
return a.mCost < b.mCost;
|
||||
}
|
||||
return a.mTime < b.mTime;
|
||||
}
|
||||
bool operator==( const CompareDijkstraIterator& a ) const
|
||||
{
|
||||
return mCriterion == a.mCriterion;
|
||||
}
|
||||
private:
|
||||
OptimizationCriterion mCriterion;
|
||||
};
|
||||
public:
|
||||
/**
|
||||
* constructor.
|
||||
* m is adjacency matrix of graph, criterion is a citerion of shortest path
|
||||
*/
|
||||
DijkstraFinder( const AdjacencyMatrix &m, OptimizationCriterion criterion );
|
||||
|
||||
/**
|
||||
* find all shortest path from point frontPoint to all points of graph.
|
||||
* return tree.
|
||||
*/
|
||||
std::map< QgsPoint , DijkstraIterator, QgsPointCompare > find( const QgsPoint& p );
|
||||
|
||||
/**
|
||||
* return shortest path form point frontPoint to endPoint
|
||||
*/
|
||||
AdjacencyMatrix find( const QgsPoint& frontPoint, const QgsPoint& endPoint );
|
||||
|
||||
private:
|
||||
const AdjacencyMatrix& mAdjacencyMatrix;
|
||||
OptimizationCriterion mCriterion;
|
||||
/**
|
||||
* find all shortest path from point frontPoint to all points of graph.
|
||||
* return tree.
|
||||
*/
|
||||
std::map< QgsPoint , DijkstraIterator, QgsPointCompare > find( const QgsPoint& p );
|
||||
|
||||
/**
|
||||
* return shortest path form point frontPoint to endPoint
|
||||
*/
|
||||
AdjacencyMatrix find( const QgsPoint& frontPoint, const QgsPoint& endPoint );
|
||||
|
||||
private:
|
||||
const AdjacencyMatrix& mAdjacencyMatrix;
|
||||
OptimizationCriterion mCriterion;
|
||||
};
|
||||
#endif
|
||||
|
@ -1140,7 +1140,7 @@ QgsSqlAnywhereProvider::addFeatures( QgsFeatureList & flist )
|
||||
|
||||
if ( ok )
|
||||
{
|
||||
// expand extents to accomodate new geometries
|
||||
// expand extents to accommodate new geometries
|
||||
mSrsExtent.unionRect( rect );
|
||||
if ( !mLayerExtent.isEmpty() )
|
||||
{
|
||||
@ -1565,7 +1565,7 @@ QgsSqlAnywhereProvider::changeGeometryValues( QgsGeometryMap & gmap )
|
||||
|
||||
if ( ok )
|
||||
{
|
||||
// expand SRS and layer extents to accomodate new geometries
|
||||
// expand SRS and layer extents to accommodate new geometries
|
||||
mSrsExtent.unionRect( rect );
|
||||
if ( !mLayerExtent.isEmpty() )
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user