-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-Contribution of the eVis plugin, version 1.1.0, to the QGIS project
-Documentation folks can find our original user guide at http://biodiversityinformatics.amnh.org/open_source/evis/documentation.php -Any questions can be sent to ersts at amnh dot org and horning at amnh dot org git-svn-id: http://svn.osgeo.org/qgis/trunk@10995 c8812cc2-4d05-0410-92ff-de0c093fc19c
- Loading branch information
ersts
committed
Jul 1, 2009
1 parent
40650bb
commit 27cb2ee
Showing
30 changed files
with
5,926 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
IF (WIN32) | ||
IF (MSVC) | ||
ADD_DEFINITIONS("-DGUI_EXPORT=__declspec(dllimport)") | ||
ADD_DEFINITIONS("-DCORE_EXPORT=__declspec(dllimport)") | ||
ELSE (MSVC) | ||
ADD_DEFINITIONS("\"-DGUI_EXPORT=__declspec(dllimport)\"") | ||
ADD_DEFINITIONS("\"-DCORE_EXPORT=__declspec(dllimport)\"") | ||
ENDIF (MSVC) | ||
ELSE (WIN32) | ||
ADD_DEFINITIONS(-DGUI_EXPORT=) | ||
ADD_DEFINITIONS(-DCORE_EXPORT=) | ||
ENDIF (WIN32) | ||
|
||
######################################################## | ||
# Files | ||
|
||
SET (evis_SRCS | ||
evis.cpp | ||
|
||
databaseconnection/evisdatabaseconnectiongui.cpp | ||
databaseconnection/evisdatabaseconnection.cpp | ||
databaseconnection/evisdatabaselayerfieldselectiongui.cpp | ||
databaseconnection/evisquerydefinition.cpp | ||
|
||
eventbrowser/evisconfiguration.cpp | ||
eventbrowser/evisgenericeventbrowsergui.cpp | ||
eventbrowser/evisimagedisplaywidget.cpp | ||
|
||
idtool/eviseventidtool.cpp | ||
|
||
) | ||
|
||
SET (evis_UIS | ||
ui/evisdatabaseconnectionguibase.ui | ||
ui/evisdatabaselayerfieldselectionguibase.ui | ||
ui/evisgenericeventbrowserguibase.ui | ||
) | ||
|
||
SET (evis_MOC_HDRS | ||
evis.h | ||
|
||
databaseconnection/evisdatabaseconnectiongui.h | ||
databaseconnection/evisdatabaselayerfieldselectiongui.h | ||
|
||
eventbrowser/evisgenericeventbrowsergui.h | ||
eventbrowser/evisimagedisplaywidget.h | ||
) | ||
|
||
SET (evis_RCCS resources/evis.qrc) | ||
|
||
SET (QT_USE_QT3SUPPORT FALSE) | ||
SET (QT_USE_QTGUI TRUE) | ||
SET (QT_USE_QTSQL TRUE) | ||
SET (QT_USE_QTSVG TRUE) | ||
SET (QT_USE_QTXML TRUE) | ||
SET (QT_USE_QTNETWORK TRUE) | ||
FIND_PACKAGE(Qt4 REQUIRED) | ||
INCLUDE( ${QT_USE_FILE} ) | ||
######################################################## | ||
# Build | ||
|
||
QT4_WRAP_UI (evis_UIS_H ${evis_UIS}) | ||
|
||
QT4_WRAP_CPP (evis_MOC_SRCS ${evis_MOC_HDRS}) | ||
|
||
QT4_ADD_RESOURCES(evis_RCC_SRCS ${evis_RCCS}) | ||
|
||
ADD_LIBRARY (evis MODULE ${evis_SRCS} ${evis_MOC_SRCS} ${evis_RCC_SRCS} ${evis_UIS_H}) | ||
|
||
INCLUDE_DIRECTORIES( | ||
${GDAL_INCLUDE_DIR} | ||
${GEOS_INCLUDE_DIR} | ||
${QT_INCLUDE_DIR} | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
${CMAKE_CURRENT_BINARY_DIR} | ||
${CMAKE_CURRENT_SOURCE_DIR}/databaseconnection | ||
${CMAKE_CURRENT_SOURCE_DIR}/eventbrowser | ||
${CMAKE_CURRENT_SOURCE_DIR}/idtool | ||
${CMAKE_CURRENT_SOURCE_DIR}/../../gui | ||
${CMAKE_CURRENT_SOURCE_DIR}/../../core | ||
${CMAKE_CURRENT_SOURCE_DIR}/../../core/raster | ||
${CMAKE_CURRENT_SOURCE_DIR}/.. | ||
) | ||
|
||
TARGET_LINK_LIBRARIES(evis | ||
${QT_LIBRARIES} | ||
qgis_core | ||
qgis_gui | ||
) | ||
|
||
|
||
######################################################## | ||
# Install | ||
|
||
INSTALL(TARGETS evis | ||
RUNTIME DESTINATION ${QGIS_PLUGIN_DIR} | ||
LIBRARY DESTINATION ${QGIS_PLUGIN_DIR}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
eVis - The Event Visualization Tool | ||
|
||
Lead Developer: Peter J. Ersts | ||
Concept and original documentation: Ned Horning and Kevin Koy | ||
|
||
This plugin was originally written and distributed by the Center for Biodiversity and Conservation's Biodiversity Informtics Facility at the American Museum of Natural History - | ||
http://biodiversityinformatics.amnh.org/open_source/evis/ | ||
eVis was contributed to the QGIS project on 2009-07-01. | ||
|
||
eVis was started in 2007 with QGIS v0.7.0. It was our first experience with QGIS and QT. Since its early beginings, the QGIS API has under gone many changes and advances, and as a result there are still some old ideas in this code and much room for improvement. Were we to start this plugin now, we would have done it quite differently! There is still much room for imporovement. We hope the QGIS community will find eVis useful and extend its capabilities to make it even more robust. | ||
|
||
|
||
|
||
A special "thank you" is extended to the following people who have contributed translations, comments, bug reports, and patches which have helped to make eVis a better tool: | ||
Tim Sutton, Magnus Homann, John Tull, Agustin Lobo, Donald Schrupp, Muslim Bandishoev, Anousak Souphavanh, Ha Quy Quynh, Roberto García-Yunta, Tom Gottfried | ||
|
||
This work was made possible through a grant by the the John D. and Catherine T. MacArthur Foundation. Additionally, these products were prepared by the American Museum of Natural History under award No. NA05SEC46391002 from the National Oceanic and Atmospheric Administration, U.S. Department of Commerce. The statements, findings, conclusions, and recommendations are those of the author(s) and do not necessarily reflect the views of the National Oceanic and Atmospheric Administration or the Department of Commerce. |
220 changes: 220 additions & 0 deletions
220
src/plugins/evis/databaseconnection/evisdatabaseconnection.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,220 @@ | ||
/* | ||
** File: evisdatabaseconnection.cpp | ||
** Author: Peter J. Ersts ( ersts at amnh.org ) | ||
** Creation Date: 2007-03-07 | ||
** | ||
** Copyright ( c ) 2007, American Museum of Natural History. All rights reserved. | ||
** | ||
** This library/program is free software; you can redistribute it | ||
** and/or modify it under the terms of the GNU Library General Public | ||
** License as published by the Free Software Foundation; either | ||
** version 2 of the License, or ( at your option ) any later version. | ||
** | ||
** This library/program is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
** Library General Public License for more details. | ||
** | ||
** This work was made possible through a grant by the the John D. and | ||
** Catherine T. MacArthur Foundation. Additionally, this program was prepared by | ||
** the American Museum of Natural History under award No. NA05SEC46391002 | ||
** from the National Oceanic and Atmospheric Administration, U.S. Department | ||
** of Commerce. The statements, findings, conclusions, and recommendations | ||
** are those of the author( s ) and do not necessarily reflect the views of the | ||
** National Oceanic and Atmospheric Administration or the Department of Commerce. | ||
** | ||
**/ | ||
/* $Id: $ */ | ||
#include "evisdatabaseconnection.h" | ||
|
||
#include <QStringList> | ||
|
||
/** | ||
* Constructor | ||
* @param hostname - Host name of the database server | ||
* @param port - The port number the database server is listening to | ||
* @param databasename - The name of the database to connect to | ||
* @param username - The username needed to access the database or database server | ||
* @param password - The password associate witht he username needed to access the database or database server | ||
* @param type - The type of database being connected to | ||
*/ | ||
eVisDatabaseConnection::eVisDatabaseConnection( QString hostname, int port, QString databasename, QString username, QString password, DATABASE_TYPE type ) | ||
{ | ||
mHostName = hostname; | ||
mPort = port; | ||
mDatabaseName = databasename; | ||
mUsername = username; | ||
mPassword = password; | ||
setDatabaseType( type ); | ||
mQuery.setForwardOnly( true ); | ||
} | ||
|
||
/** | ||
* Public method called to finalize a connection to a database | ||
*/ | ||
bool eVisDatabaseConnection::connect( ) | ||
{ | ||
//If a database is currnently open close the connection | ||
if( !mDatabase.isOpen( ) ) | ||
{ | ||
mDatabase.close( ); | ||
} | ||
|
||
//Add the correct database to the list of database connections, Reuse a connection if the connection exists in the list already. | ||
if( MSACCESS == databaseType( ) && !mDatabase.contains( "odbc" ) ) | ||
{ | ||
mDatabase = QSqlDatabase::addDatabase( "QODBC", "odbc" ); | ||
} | ||
else if ( MSACCESS == databaseType( ) ) | ||
{ | ||
mDatabase = QSqlDatabase::database( "odbc" ); | ||
} | ||
else if( QMYSQL == databaseType( ) && !mDatabase.contains( "mysql" ) ) | ||
{ | ||
mDatabase = QSqlDatabase::addDatabase( "QMYSQL", "mysql" ); | ||
} | ||
else if ( QMYSQL == databaseType( ) ) | ||
{ | ||
mDatabase = QSqlDatabase::database( "mysql" ); | ||
} | ||
else if( QODBC == databaseType( ) && !mDatabase.contains( "odbc" ) ) | ||
{ | ||
mDatabase = QSqlDatabase::addDatabase( "QODBC", "odbc" ); | ||
} | ||
else if ( QODBC == databaseType( ) ) | ||
{ | ||
mDatabase = QSqlDatabase::database( "odbc" ); | ||
} | ||
else if( QPSQL == databaseType( ) && !mDatabase.contains( "postgres" ) ) | ||
{ | ||
mDatabase = QSqlDatabase::addDatabase( "QPSQL", "postgres" ); | ||
} | ||
else if( QPSQL == databaseType( ) ) | ||
{ | ||
mDatabase = QSqlDatabase::database( "postgres" ); | ||
} | ||
else if( QSQLITE == databaseType( ) && !mDatabase.contains( "sqlite" ) ) | ||
{ | ||
mDatabase = QSqlDatabase::addDatabase( "QSQLITE", "sqlite" ); | ||
} | ||
else if ( QSQLITE == databaseType( ) ) | ||
{ | ||
mDatabase = QSqlDatabase::database( "sqlite" ); | ||
} | ||
else | ||
{ | ||
setLastError( "No matching DATABASE_TYPE found" ); | ||
return false; | ||
} | ||
|
||
//Do a little extra validation of connection information | ||
if( mHostName.isEmpty( ) && ( QMYSQL == databaseType( ) || QPSQL == databaseType( ) ) ) | ||
{ | ||
setLastError( "Host name was empty" ); | ||
return false; | ||
} | ||
else if( !mHostName.isEmpty( ) ) | ||
{ | ||
mDatabase.setHostName( mHostName ); | ||
} | ||
|
||
if( mPort != 0 ) | ||
{ | ||
mDatabase.setPort( mPort ); | ||
} | ||
|
||
if( mDatabaseName.isEmpty( ) ) | ||
{ | ||
setLastError( "Database name was empty" ); | ||
return false; | ||
} | ||
else if( MSACCESS == databaseType( ) ) | ||
{ | ||
mDatabase.setDatabaseName( "DRIVER = {Microsoft Access Driver ( *.mdb )};FIL = {MS Access};DBQ = "+mDatabaseName ); | ||
} | ||
else | ||
{ | ||
mDatabase.setDatabaseName( mDatabaseName ); | ||
} | ||
|
||
if( !mUsername.isEmpty( ) ) | ||
{ | ||
mDatabase.setUserName( mUsername ); | ||
} | ||
|
||
if( !mPassword.isEmpty( ) ) | ||
{ | ||
mDatabase.setPassword( mPassword ); | ||
} | ||
|
||
//Try to actually open the database | ||
if( !mDatabase.open( ) ) | ||
{ | ||
setLastError( mDatabase.lastError( ).text( ) ); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* Executes a query on the current active database connection | ||
* @param sqlStatement - QString containing the sql statement to execute | ||
*/ | ||
QSqlQuery* eVisDatabaseConnection::query( QString sqlStatement ) | ||
{ | ||
if( mDatabase.isOpen( ) ) | ||
{ | ||
//mQuery = QSqlQuery( sqlStatement, mDatabase ); //NOTE: A little against convention, the constructor also executes the query | ||
|
||
//set forward only is required for OBDC on linux | ||
mQuery = QSqlQuery( mDatabase ); | ||
mQuery.setForwardOnly( true ); | ||
mQuery.exec( sqlStatement ); | ||
if( mQuery.isActive( ) ) | ||
{ | ||
return &mQuery; | ||
} | ||
else | ||
{ | ||
setLastError( mQuery.lastError( ).text( ) ); | ||
return 0; | ||
} | ||
} | ||
|
||
setLastError( "Database connection was not open." ); | ||
return 0; | ||
} | ||
|
||
/** | ||
* Reset the connection parameters | ||
* @param hostname - Host name of the database server | ||
* @param port - The port number the database server is listening to | ||
* @param databasename - The name of the database to connect to | ||
* @param username - The username needed to access the database or database server | ||
* @param password - The password associate witht he username needed to access the database or database server | ||
* @param type - The type of database being connected to | ||
*/ | ||
void eVisDatabaseConnection::resetConnectionParameters( QString hostname, int port, QString databasename, QString username, QString password, DATABASE_TYPE type ) | ||
{ | ||
mHostName = hostname; | ||
mPort = port; | ||
mDatabaseName = databasename; | ||
mUsername = username; | ||
mPassword = password; | ||
setDatabaseType( type ); | ||
} | ||
|
||
/** | ||
* Returns a list of tables for the current active database connection | ||
*/ | ||
QStringList eVisDatabaseConnection::tables( ) | ||
{ | ||
if( mDatabase.isOpen( ) ) | ||
{ | ||
return mDatabase.tables( ); | ||
} | ||
|
||
setLastError( "Database connection was not open." ); | ||
return QStringList( ); | ||
} |
Oops, something went wrong.