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:
timlinux 2004-02-06 22:08:37 +00:00
parent 7891a6dad6
commit 2c3abab958

View File

@ -79,7 +79,9 @@ QString QgsMapserverExport::fullPathName(){
}
void QgsMapserverExport::writeMapFile(){
// write the map file, making massive assumptions about default values
#ifdef DEBUG
std::cout << "Opening map file " << txtMapFilePath->text() << std::endl;
#endif
std::ofstream mapFile(txtMapFilePath->text());
if(!mapFile.fail()){
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 << "#" << std::endl;
}else{
}
else
{
mapFile << " # This file contains layer definitions only and is not a complete" << std::endl;
mapFile << " # Mapserver map file." << std::endl;
}
// write layer definitions
for(int i = 0; i < map->layerCount(); i++){
for(int i = 0; i < map->layerCount(); i++)
{
bool isPolygon =false;
bool isLine = false;
QgsMapLayer *lyr = map->getZpos(i);
#ifdef DEBUG
std::cout << "Mapsrver Export Processing Layer" << std::endl;
#endif
mapFile << "LAYER" << std::endl;
QString name = lyr->name().lower();
// MapServer NAME must be < 20 char and unique
@ -159,6 +167,9 @@ void QgsMapserverExport::writeMapFile(){
name.replace(QRegExp("\\)"), "_");
mapFile << " NAME " << name << std::endl;
// feature type
#ifdef DEBUG
std::cout << "\tMapsrver Export checking feature type" << std::endl;
#endif
mapFile << " TYPE ";
switch (lyr->featureType()) {
case QGis::WKBPoint:
@ -178,6 +189,9 @@ void QgsMapserverExport::writeMapFile(){
}
mapFile << std::endl;
#ifdef DEBUG
std::cout << "\tMapsrver Export checking visibility" << std::endl;
#endif
// set visibility (STATUS)
mapFile << " STATUS ";
if(lyr->visible()){
@ -189,6 +203,9 @@ void QgsMapserverExport::writeMapFile(){
// data source (DATA)
// Data source spec depends on layer type
#ifdef DEBUG
std::cout << "\tMapsrver Export checking layer type" << std::endl;
#endif
switch(lyr->type()){
case QgsMapLayer::VECTOR:
mapFile << " DATA " << lyr->source() << std::endl;
@ -206,19 +223,32 @@ void QgsMapserverExport::writeMapFile(){
break;
#endif */
}
#ifdef DEBUG
std::cout << "\tMapsrver Export creating symbol entries" << std::endl;
#endif
// create a simple class entry based on layer color
QgsSymbol *sym = lyr->symbol();
mapFile << " CLASS" << std::endl;
QgsLegend *lgd = map->getLegend();
//QListViewItem *li = lgd->currentItem();
// return li->text(0);
#ifdef DEBUG
std::cout << "\tMapsrver Export symbol name" << std::endl;
#endif
mapFile << " NAME \"" << lyr->name() << "\"" << std::endl;
mapFile << " # TEMPLATE" << std::endl;
if(isPolygon)
{
#ifdef DEBUG
std::cout << "\tMapsrver Export symbol fill color" << std::endl;
#endif
QColor fillColor = sym->fillColor();
if(!isLine){
mapFile << " COLOR " << fillColor.red() << " " <<
fillColor.green() << " " << fillColor.blue() << std::endl;
}
#ifdef DEBUG
std::cout << "\tMapsrver Export checking for line symbol " << std::endl;
#endif
if(isPolygon || isLine){
QColor outlineColor = sym->color();
mapFile << " OUTLINECOLOR " << outlineColor.red() << " "
@ -227,6 +257,9 @@ void QgsMapserverExport::writeMapFile(){
}
mapFile << " END" << std::endl;
mapFile << "END" << std::endl;
#ifdef DEBUG
std::cout << "\tMapsrver Export layer definition done..." << std::endl;
#endif
}
if(!chkExpLayersOnly->isChecked()){
mapFile << "END # Map File";