Skip to content

Commit

Permalink
Raster reprojection in QGIS server
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@15724 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Apr 16, 2011
1 parent b93e54e commit f8e10a3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 36 deletions.
52 changes: 21 additions & 31 deletions src/mapserver/qgsconfigparser.cpp
Expand Up @@ -122,41 +122,31 @@ void QgsConfigParser::appendExGeographicBoundingBox( QDomElement& layerElem,
QStringList QgsConfigParser::createCRSListForLayer( QgsMapLayer* theMapLayer ) const
{
QStringList crsNumbers;
QgsVectorLayer* theVectorLayer = dynamic_cast<QgsVectorLayer*>( theMapLayer );

if ( theVectorLayer ) //append the source SRS. In future, all systems supported by proj4 should be appended
QString myDatabaseFileName = QgsApplication::srsDbFilePath();
sqlite3 *myDatabase;
const char *myTail;
sqlite3_stmt *myPreparedStatement;
int myResult;

//check the db is available
myResult = sqlite3_open( myDatabaseFileName.toLocal8Bit().data(), &myDatabase );
if ( myResult )
{
QString myDatabaseFileName = QgsApplication::srsDbFilePath();
sqlite3 *myDatabase;
const char *myTail;
sqlite3_stmt *myPreparedStatement;
int myResult;

//check the db is available
myResult = sqlite3_open( myDatabaseFileName.toLocal8Bit().data(), &myDatabase );
if ( myResult )
{
//if the database cannot be opened, add at least the epsg number of the source coordinate system
crsNumbers.push_back( theMapLayer->crs().authid() );
return crsNumbers;
};
QString mySql = "select upper(auth_name||':'||auth_id) from tbl_srs";
myResult = sqlite3_prepare( myDatabase, mySql.toUtf8(), mySql.length(), &myPreparedStatement, &myTail );
if ( myResult == SQLITE_OK )
//if the database cannot be opened, add at least the epsg number of the source coordinate system
crsNumbers.push_back( theMapLayer->crs().authid() );
return crsNumbers;
};
QString mySql = "select upper(auth_name||':'||auth_id) from tbl_srs";
myResult = sqlite3_prepare( myDatabase, mySql.toUtf8(), mySql.length(), &myPreparedStatement, &myTail );
if ( myResult == SQLITE_OK )
{
while ( sqlite3_step( myPreparedStatement ) == SQLITE_ROW )
{
while ( sqlite3_step( myPreparedStatement ) == SQLITE_ROW )
{
crsNumbers.push_back( QString::fromUtf8(( char * )sqlite3_column_text( myPreparedStatement, 0 ) ) );
}
crsNumbers.push_back( QString::fromUtf8(( char * )sqlite3_column_text( myPreparedStatement, 0 ) ) );
}
sqlite3_finalize( myPreparedStatement );
sqlite3_close( myDatabase );
}
else //rasters cannot be reprojected. Use the epsg number of the layers native CRS
{
crsNumbers.push_back( theMapLayer->crs().authid() );
}
return crsNumbers;
sqlite3_finalize( myPreparedStatement );
sqlite3_close( myDatabase );
}

bool QgsConfigParser::exGeographicBoundingBox( const QDomElement& layerElement, QgsRectangle& rect ) const
Expand Down
5 changes: 0 additions & 5 deletions src/mapserver/qgswmsserver.cpp
Expand Up @@ -1179,11 +1179,6 @@ QStringList QgsWMSServer::layerSet( const QStringList& layersList,
theMapLayer = layerList.at( listIndex );
if ( theMapLayer )
{
if ( theMapLayer->type() == QgsMapLayer::RasterLayer )
{
//set the sourceSRS to the same as the destSRS
theMapLayer->setCrs( destCRS );
}
layerKeys.push_front( theMapLayer->id() );
QgsMapLayerRegistry::instance()->addMapLayer( theMapLayer, false );
}
Expand Down

0 comments on commit f8e10a3

Please sign in to comment.