mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-06 00:07:29 -04:00
889452 Fixed. Bug was caused by incorrect checking of feature type before trying to access fill color. Added a bunch of debug statements when debug mode is on.
git-svn-id: http://svn.osgeo.org/qgis/trunk@722 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
7891a6dad6
commit
2c3abab958
@ -79,7 +79,9 @@ QString QgsMapserverExport::fullPathName(){
|
|||||||
}
|
}
|
||||||
void QgsMapserverExport::writeMapFile(){
|
void QgsMapserverExport::writeMapFile(){
|
||||||
// write the map file, making massive assumptions about default values
|
// write the map file, making massive assumptions about default values
|
||||||
|
#ifdef DEBUG
|
||||||
std::cout << "Opening map file " << txtMapFilePath->text() << std::endl;
|
std::cout << "Opening map file " << txtMapFilePath->text() << std::endl;
|
||||||
|
#endif
|
||||||
std::ofstream mapFile(txtMapFilePath->text());
|
std::ofstream mapFile(txtMapFilePath->text());
|
||||||
if(!mapFile.fail()){
|
if(!mapFile.fail()){
|
||||||
mapFile << "# Map file generated by QGIS version " << QGis::qgisVersion << std::endl;
|
mapFile << "# Map file generated by QGIS version " << QGis::qgisVersion << std::endl;
|
||||||
@ -140,16 +142,22 @@ void QgsMapserverExport::writeMapFile(){
|
|||||||
mapFile << "# projection information based on Mapserver documentation." << std::endl;
|
mapFile << "# projection information based on Mapserver documentation." << std::endl;
|
||||||
mapFile << "#" << std::endl;
|
mapFile << "#" << std::endl;
|
||||||
|
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
mapFile << " # This file contains layer definitions only and is not a complete" << std::endl;
|
mapFile << " # This file contains layer definitions only and is not a complete" << std::endl;
|
||||||
mapFile << " # Mapserver map file." << std::endl;
|
mapFile << " # Mapserver map file." << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// write layer definitions
|
// write layer definitions
|
||||||
for(int i = 0; i < map->layerCount(); i++){
|
for(int i = 0; i < map->layerCount(); i++)
|
||||||
|
{
|
||||||
bool isPolygon =false;
|
bool isPolygon =false;
|
||||||
bool isLine = false;
|
bool isLine = false;
|
||||||
QgsMapLayer *lyr = map->getZpos(i);
|
QgsMapLayer *lyr = map->getZpos(i);
|
||||||
|
#ifdef DEBUG
|
||||||
|
std::cout << "Mapsrver Export Processing Layer" << std::endl;
|
||||||
|
#endif
|
||||||
mapFile << "LAYER" << std::endl;
|
mapFile << "LAYER" << std::endl;
|
||||||
QString name = lyr->name().lower();
|
QString name = lyr->name().lower();
|
||||||
// MapServer NAME must be < 20 char and unique
|
// MapServer NAME must be < 20 char and unique
|
||||||
@ -159,6 +167,9 @@ void QgsMapserverExport::writeMapFile(){
|
|||||||
name.replace(QRegExp("\\)"), "_");
|
name.replace(QRegExp("\\)"), "_");
|
||||||
mapFile << " NAME " << name << std::endl;
|
mapFile << " NAME " << name << std::endl;
|
||||||
// feature type
|
// feature type
|
||||||
|
#ifdef DEBUG
|
||||||
|
std::cout << "\tMapsrver Export checking feature type" << std::endl;
|
||||||
|
#endif
|
||||||
mapFile << " TYPE ";
|
mapFile << " TYPE ";
|
||||||
switch (lyr->featureType()) {
|
switch (lyr->featureType()) {
|
||||||
case QGis::WKBPoint:
|
case QGis::WKBPoint:
|
||||||
@ -178,6 +189,9 @@ void QgsMapserverExport::writeMapFile(){
|
|||||||
}
|
}
|
||||||
mapFile << std::endl;
|
mapFile << std::endl;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
std::cout << "\tMapsrver Export checking visibility" << std::endl;
|
||||||
|
#endif
|
||||||
// set visibility (STATUS)
|
// set visibility (STATUS)
|
||||||
mapFile << " STATUS ";
|
mapFile << " STATUS ";
|
||||||
if(lyr->visible()){
|
if(lyr->visible()){
|
||||||
@ -189,6 +203,9 @@ void QgsMapserverExport::writeMapFile(){
|
|||||||
|
|
||||||
// data source (DATA)
|
// data source (DATA)
|
||||||
// Data source spec depends on layer type
|
// Data source spec depends on layer type
|
||||||
|
#ifdef DEBUG
|
||||||
|
std::cout << "\tMapsrver Export checking layer type" << std::endl;
|
||||||
|
#endif
|
||||||
switch(lyr->type()){
|
switch(lyr->type()){
|
||||||
case QgsMapLayer::VECTOR:
|
case QgsMapLayer::VECTOR:
|
||||||
mapFile << " DATA " << lyr->source() << std::endl;
|
mapFile << " DATA " << lyr->source() << std::endl;
|
||||||
@ -206,19 +223,32 @@ void QgsMapserverExport::writeMapFile(){
|
|||||||
break;
|
break;
|
||||||
#endif */
|
#endif */
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
|
std::cout << "\tMapsrver Export creating symbol entries" << std::endl;
|
||||||
|
#endif
|
||||||
// create a simple class entry based on layer color
|
// create a simple class entry based on layer color
|
||||||
QgsSymbol *sym = lyr->symbol();
|
QgsSymbol *sym = lyr->symbol();
|
||||||
mapFile << " CLASS" << std::endl;
|
mapFile << " CLASS" << std::endl;
|
||||||
QgsLegend *lgd = map->getLegend();
|
QgsLegend *lgd = map->getLegend();
|
||||||
//QListViewItem *li = lgd->currentItem();
|
//QListViewItem *li = lgd->currentItem();
|
||||||
// return li->text(0);
|
// return li->text(0);
|
||||||
|
#ifdef DEBUG
|
||||||
|
std::cout << "\tMapsrver Export symbol name" << std::endl;
|
||||||
|
#endif
|
||||||
mapFile << " NAME \"" << lyr->name() << "\"" << std::endl;
|
mapFile << " NAME \"" << lyr->name() << "\"" << std::endl;
|
||||||
mapFile << " # TEMPLATE" << std::endl;
|
mapFile << " # TEMPLATE" << std::endl;
|
||||||
|
if(isPolygon)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
std::cout << "\tMapsrver Export symbol fill color" << std::endl;
|
||||||
|
#endif
|
||||||
QColor fillColor = sym->fillColor();
|
QColor fillColor = sym->fillColor();
|
||||||
if(!isLine){
|
|
||||||
mapFile << " COLOR " << fillColor.red() << " " <<
|
mapFile << " COLOR " << fillColor.red() << " " <<
|
||||||
fillColor.green() << " " << fillColor.blue() << std::endl;
|
fillColor.green() << " " << fillColor.blue() << std::endl;
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
|
std::cout << "\tMapsrver Export checking for line symbol " << std::endl;
|
||||||
|
#endif
|
||||||
if(isPolygon || isLine){
|
if(isPolygon || isLine){
|
||||||
QColor outlineColor = sym->color();
|
QColor outlineColor = sym->color();
|
||||||
mapFile << " OUTLINECOLOR " << outlineColor.red() << " "
|
mapFile << " OUTLINECOLOR " << outlineColor.red() << " "
|
||||||
@ -227,6 +257,9 @@ void QgsMapserverExport::writeMapFile(){
|
|||||||
}
|
}
|
||||||
mapFile << " END" << std::endl;
|
mapFile << " END" << std::endl;
|
||||||
mapFile << "END" << std::endl;
|
mapFile << "END" << std::endl;
|
||||||
|
#ifdef DEBUG
|
||||||
|
std::cout << "\tMapsrver Export layer definition done..." << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if(!chkExpLayersOnly->isChecked()){
|
if(!chkExpLayersOnly->isChecked()){
|
||||||
mapFile << "END # Map File";
|
mapFile << "END # Map File";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user