Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix for #814
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7448 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Nov 18, 2007
1 parent 0858213 commit b9179b3
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 15 deletions.
5 changes: 5 additions & 0 deletions src/core/qgsvectorlayer.cpp
Expand Up @@ -1912,6 +1912,11 @@ bool QgsVectorLayer::setDataProvider( QString const & provider )

if ( myLabel )
{
dField = document.createElement( "labelfield" );
dFieldText = document.createTextNode( myLabel->labelField(QgsLabel::Text ) );
dField.appendChild( dFieldText );
layer_node.appendChild( dField );

std::stringstream labelXML;

myLabel->writeXML(labelXML);
Expand Down
16 changes: 9 additions & 7 deletions tools/mapserver_export/ms_export.py
Expand Up @@ -323,13 +323,16 @@ def writeMapLayers(self):
wmsStyles.append( '' )
# Create necesssary wms metadata
format = rasterProp.getElementsByTagName('wmsFormat')[0].childNodes[0].nodeValue.encode('utf-8')
ct = lyr.getElementsByTagName('coordinatetransform')[0]
srs = ct.getElementsByTagName('sourcesrs')[0].getElementsByTagName('spatialrefsys')[0]
epsg = srs.getElementsByTagName('epsg')[0].childNodes[0].nodeValue.encode('utf-8')
self.outFile.write(" METADATA\n")
self.outFile.write(" 'wms_name' '" + ','.join(wmsNames) + "'\n")
self.outFile.write(" 'wms_server_version' '1.1.1'\n")
self.outFile.write(" 'wms_srs' 'EPSG:4326 EPSG:" + epsg + "'\n")
try:
ct = lyr.getElementsByTagName('coordinatetransform')[0]
srs = ct.getElementsByTagName('sourcesrs')[0].getElementsByTagName('spatialrefsys')[0]
epsg = srs.getElementsByTagName('epsg')[0].childNodes[0].nodeValue.encode('utf-8')
self.outFile.write(" 'wms_srs' 'EPSG:4326 EPSG:" + epsg + "'\n")
except:
pass
self.outFile.write(" 'wms_format' '" + format + "'\n")
self.outFile.write(" 'wms_style' '" + ','.join(wmsStyles) + "'\n")
self.outFile.write(" END\n")
Expand Down Expand Up @@ -371,9 +374,8 @@ def writeMapLayers(self):

# Check for label field (ie LABELITEM) and label status
try:
labelOn = lyr.getElementsByTagName("label")[0].childNodes[0].nodeValue.encode('utf-8')
labelNode = lyr.getElementsByTagName('labelattributes')[0]
labelField = labelNode.getElementsByTagName('label')[0].getAttribute('field').encode('utf-8')
labelOn = lyr.getElementsByTagName( "label")[0].childNodes[0].nodeValue.encode('utf-8')
labelField = lyr.getElementsByTagName("labelfield")[0].childNodes[0].nodeValue.encode('utf-8')
if labelField != '' and labelField is not None and labelOn == "1":
self.outFile.write(" LABELITEM '" + labelField + "'\n");
except:
Expand Down
27 changes: 19 additions & 8 deletions tools/mapserver_export/qgsmapserverexport.cpp
Expand Up @@ -119,7 +119,11 @@ void QgsMapserverExport::apply()
#ifdef Q_WS_MACX
QString dataPath = prefixPath + "/../../../../share/qgis";
#elif WIN32
# ifndef _MSC_VER
QString dataPath = prefixPath + "/share/qgis";
# else
QString dataPath = prefixPath;
# endif
#else
QString dataPath ( PKGDATAPATH );
#endif
Expand All @@ -133,6 +137,10 @@ void QgsMapserverExport::apply()
// Import the module
std::cout << "Importing module" << std::endl;
pmod = PyImport_ImportModule("ms_export");
if(!pmod) {
QMessageBox::warning(this, "Map Export Error", "ms_export python module not found");
return;
}

std::cout << "Getting Qgis2Map constructor as python obj" << std::endl;
pclass = PyObject_GetAttrString(pmod, "Qgis2Map");
Expand Down Expand Up @@ -167,14 +175,17 @@ void QgsMapserverExport::apply()
pargs = Py_BuildValue("()");
// Execute the writeMapFile method to parse the QGIS project file and create the .map file
pstr = PyEval_CallObject(pmeth, pargs);
// Show the return value
PyArg_Parse(pstr, "s", &cstr);
std::cout << "Result: " << std::endl << cstr << std::endl;
// Show the results to the user
QMessageBox::information(this, "Results of Export", QString(cstr));

Py_DECREF(pstr);

if(pstr) {
// Show the return value
PyArg_Parse(pstr, "s", &cstr);
std::cout << "Result: " << std::endl << cstr << std::endl;

// Show the results to the user
QMessageBox::information(this, "Results of Export", QString(cstr));
Py_DECREF(pstr);
} else {
QMessageBox::warning(this, "Mapfile Export Error", "method call failed");
}
}
void QgsMapserverExport::on_buttonBox_helpRequested()
{
Expand Down

0 comments on commit b9179b3

Please sign in to comment.