10 changes: 5 additions & 5 deletions python/plugins/sextante/modeler/ModelerAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,19 +216,19 @@ def removeAlgorithm(self, index):
del self.algOutputs[index]
del self.algPos[index]

index = -1
i = -1
for paramValues in self.algParameters:
index += 1
newValues = []
for name, value in paramValues[index]:
i += 1
newValues = {}
for name, value in paramValues.iteritems():
if value:
if value.alg > index:
newValues[name] = AlgorithmAndParameter(value.alg - 1, value.param, value.algName, value.paramName)
else:
newValues[name] = value
else:
newValues[name] = value

self.algParameters[i] = newValues
self.updateModelerView()
return True

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* *
***************************************************************************
"""
from sextante.parameters.ParameterFile import ParameterFile

__author__ = 'Victor Olaya'
__date__ = 'August 2012'
Expand Down Expand Up @@ -48,12 +49,13 @@ class ModelerParameterDefinitionDialog(QtGui.QDialog):
PARAMETER_BOOLEAN="Boolean"
PARAMETER_TABLE_FIELD="Table field"
PARAMETER_EXTENT="Extent"
PARAMETER_FILE="File"
#TO ADD
PARAMETER_MULTIPLE="Multiple input"
PARAMETER_FIXED_TABLE="Fixed table"

paramTypes = [PARAMETER_BOOLEAN,PARAMETER_NUMBER, PARAMETER_RASTER, PARAMETER_EXTENT,
PARAMETER_STRING, PARAMETER_VECTOR, PARAMETER_TABLE, PARAMETER_TABLE_FIELD]
paramTypes = [PARAMETER_BOOLEAN, PARAMETER_EXTENT, PARAMETER_FILE, PARAMETER_NUMBER, PARAMETER_RASTER,
PARAMETER_STRING, PARAMETER_TABLE, PARAMETER_TABLE_FIELD, PARAMETER_VECTOR]

def __init__(self, alg, paramType = None, param = None):
self.alg = alg;
Expand Down Expand Up @@ -194,10 +196,17 @@ def setupUi(self):
self.defaultTextBox = QtGui.QLineEdit()
if self.param is not None:
self.defaultTextBox.setText(self.param.default)
self.minTextBox.setText(self.param.min if self.param.min is not None else "")
self.maxTextBox.setText(self.param.max if self.param.max is not None else "")
self.horizontalLayout2.addWidget(self.defaultTextBox)
self.verticalLayout.addLayout(self.horizontalLayout2)
elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_FILE \
or isinstance(self.param, ParameterFile):
self.horizontalLayout2.addWidget(QtGui.QLabel("Type"))
self.fileFolderCombo = QtGui.QComboBox()
self.fileFolderCombo.addItem("File")
self.fileFolderCombo.addItem("Folder")
self.horizontalLayout2.addWidget(self.fileFolderCombo)
if self.param is not None:
self.fileFolderCombo.setCurrentIndex(1 if self.param.isFolder else 0)

self.buttonBox = QtGui.QDialogButtonBox(self)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
Expand Down Expand Up @@ -251,12 +260,14 @@ def okPressed(self):
vmax = float(vmax)
self.param = ParameterNumber(name, description, vmin, vmax, float(str(self.defaultTextBox.text())))
except:
QMessageBox.critical(self, "Unable to define parameter", "Wrong or missing parameter values")
return
QMessageBox.critical(self, "Unable to define parameter", "Wrong or missing parameter values")
return
elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_STRING or isinstance(self.param, ParameterString):
self.param = ParameterString(name, description, str(self.defaultTextBox.text()))
elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_EXTENT or isinstance(self.param, ParameterExtent):
self.param = ParameterExtent(name, description)
elif self.paramType == ModelerParameterDefinitionDialog.PARAMETER_FILE or isinstance(self.param, ParameterFile):
self.param = ParameterFile(name, description)
self.close()

def cancelPressed(self):
Expand Down
12 changes: 4 additions & 8 deletions python/plugins/sextante/modeler/ModelerParametersDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def setParamValues(self):
selectedOptions = self.dependenciesPanel.selectedoptions
#this index are based on the list of available dependencies.
#we translate them into indices based on the whole set of algorithm in the model
#We just take the values in the begining of the string representing the algorithm
#We just take the values in the beginning of the string representing the algorithm
availableDependencies = self.getAvailableDependencies()
self.dependencies = []
for selected in selectedOptions:
Expand All @@ -627,17 +627,13 @@ def setParamValues(self):


def setParamValueLayerOrTable(self, param, widget):
idx = widget.findText(widget.currentText())
idx = widget.currentIndex()
if idx < 0:
name = self.getSafeNameForHarcodedParameter(param)
value = AlgorithmAndParameter(AlgorithmAndParameter.PARENT_MODEL_ALGORITHM, name)
self.params[param.name] = value
s = str(widget.currentText())
self.values[name] = s
return False
else:
value = widget.itemData(widget.currentIndex()).toPyObject()
self.params[param.name] = value
return True
return True

def setParamBooleanValue(self, param, widget):
if widget.currentIndex() < 2:
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/otb/OTBAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def processAlgorithm(self, progress):
self.roiVectors[param.value] = roiFile
else:
commands.append(param.value)
if isinstance(param, ParameterRaster):
elif isinstance(param, ParameterRaster):
commands.append(param.name)
if self.hasROI:
roiFile = SextanteUtils.getTempFilename('tif')
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/sextante/r/RAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def defineCharacteristicsFromFile(self):
self.commands=[]
self.showPlots = False
self.showConsoleOutput = False
self.useRasterPackage = False
self.useRasterPackage = True
self.passFileNames = False
self.verboseCommands = []
filename = os.path.basename(self.descriptionFile)
Expand Down Expand Up @@ -136,8 +136,8 @@ def processParameterLine(self,line):
self.showPlots = True
self.addOutput(OutputHTML(RAlgorithm.RPLOTS, "R Plots"));
return
if line.lower().strip().startswith("userasterpackage"):
self.useRasterPackage = True
if line.lower().strip().startswith("usereadgdal"):
self.useRasterPackage = False
return
if line.lower().strip().startswith("passfilenames"):
self.passFileNames = True
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
##userasterpackage
##[Example scripts]=group
##Layer = raster
##no_data_value = number 0
Expand Down
13 changes: 11 additions & 2 deletions python/plugins/sextante/saga/SagaAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@
from sextante.parameters.ParameterNumber import ParameterNumber
from sextante.parameters.ParameterSelection import ParameterSelection
from sextante.core.LayerExporter import LayerExporter
import subprocess
from sextante.parameters.ParameterExtent import ParameterExtent
from PyQt4 import QtGui
from sextante.parameters.ParameterFixedTable import ParameterFixedTable
from sextante.core.SextanteLog import SextanteLog

Expand Down Expand Up @@ -367,6 +365,17 @@ def exportRasterLayer(self, layer):

def checkBeforeOpeningParametersDialog(self):
return SagaUtils.checkSagaIsInstalled()


def checkParameterValuesBeforeExecuting(self):
'''We check that there are no multiband layers, which are not supported by SAGA'''
for param in self.parameters:
if isinstance(param, ParameterRaster):
value = param.value
layer = QGisLayers.getObjectFromUri(value)
if layer is not None and layer.bandCount() > 1:
return ("Input layer " + str(layer.name()) + " has more than one band.\n"
+ "Multiband layers are not supported by SAGA")


def helpFile(self):
Expand Down
7 changes: 6 additions & 1 deletion python/plugins/sextante/saga/SplitRGBBands.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ def defineCharacteristics(self):
def processAlgorithm(self, progress):
#TODO:check correct num of bands
input = self.getParameterValue(SplitRGBBands.INPUT)
temp = SextanteUtils.getTempFilename();
temp = SextanteUtils.getTempFilename(None).replace('.','');
basename = os.path.basename(temp)
validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
safeBasename = ''.join(c for c in basename if c in validChars)
temp = os.path.join(os.path.dirname(temp), safeBasename)

r = self.getOutputValue(SplitRGBBands.R)
g = self.getOutputValue(SplitRGBBands.G)
b = self.getOutputValue(SplitRGBBands.B)
Expand Down
2 changes: 1 addition & 1 deletion scripts/astyle-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export elcr="$(tput el)$(tput cr)"

find python src tests -type f -print | while read f; do
case "$f" in
src/app/gps/qwtpolar-*|src/app/qtmain_android.cpp|src/core/spatialite/*|src/core/spatialindex/src/*|src/core/gps/qextserialport/*|src/plugins/grass/qtermwidget/*|src/astyle/*|python/pyspatialite/*|src/providers/sqlanywhere/sqlanyconnection/*|src/providers/spatialite/qspatialite/*|src/plugins/dxf2shp_converter/dxflib/src/*|src/plugins/globe/osgEarthQt/*|src/plugins/globe/osgEarthUtil/*)
src/app/gps/qwtpolar-*|src/core/spatialite/*|src/core/spatialindex/src/*|src/core/gps/qextserialport/*|src/plugins/grass/qtermwidget/*|src/astyle/*|python/pyspatialite/*|src/providers/sqlanywhere/sqlanyconnection/*|src/providers/spatialite/qspatialite/*|src/plugins/dxf2shp_converter/dxflib/src/*|src/plugins/globe/osgEarthQt/*|src/plugins/globe/osgEarthUtil/*)
echo $f skipped
continue
;;
Expand Down
10 changes: 1 addition & 9 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ SET(QGIS_APP_SRCS
qgsmaptoolsplitfeatures.cpp
qgsmaptoolsvgannotation.cpp
qgsmaptooltextannotation.cpp
qgsmaptoolvertexedit.cpp
qgsmaptoolvertexedit.cpp

nodetool/qgsmaptoolnodetool.cpp
nodetool/qgsselectedfeature.cpp
Expand Down Expand Up @@ -160,14 +160,6 @@ SET(QGIS_APP_SRCS
openstreetmap/qgsosmexportdialog.cpp
)

IF (ANDROID)
SET(QGIS_APP_SRCS
${QGIS_APP_SRCS}
qtmain_android.cpp
)
ENDIF (ANDROID)


SET (QGIS_APP_MOC_HDRS
qgisapp.h
qgisappinterface.h
Expand Down
2 changes: 2 additions & 0 deletions src/app/legend/qgslegend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1849,10 +1849,12 @@ bool QgsLegend::readXML( QgsLegendGroup *parent, const QDomNode &node )
}
else
{
blockSignals( true );
if ( parent )
theGroup = new QgsLegendGroup( parent, name );
else
theGroup = new QgsLegendGroup( this, name );
blockSignals( false );
}

if ( !theGroup )
Expand Down
6 changes: 3 additions & 3 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3638,7 +3638,7 @@ bool QgisApp::fileSave()
if ( path.isEmpty() )
return false;

QFileInfo fullPath( path );
fullPath.setFile( path );

// make sure we have the .qgs extension in the file name
if ( "qgs" != fullPath.suffix().toLower() )
Expand All @@ -3653,7 +3653,7 @@ bool QgisApp::fileSave()
if ( QgsProject::instance()->write() )
{
setTitleBarText_( *this ); // update title bar
statusBar()->showMessage( tr( "Saved project to: %1" ).arg( QgsProject::instance()->fileName() ) );
statusBar()->showMessage( tr( "Saved project to: %1" ).arg( QgsProject::instance()->fileName() ), 5000 );

if ( isNewProject )
{
Expand Down Expand Up @@ -3712,7 +3712,7 @@ void QgisApp::fileSaveAs()
if ( QgsProject::instance()->write() )
{
setTitleBarText_( *this ); // update title bar
statusBar()->showMessage( tr( "Saved project to: %1" ).arg( QgsProject::instance()->fileName() ) );
statusBar()->showMessage( tr( "Saved project to: %1" ).arg( QgsProject::instance()->fileName() ), 5000 );
// add this to the list of recently used project files
saveRecentProjectPath( fullPath.filePath(), settings );
}
Expand Down
6 changes: 6 additions & 0 deletions src/app/qgisappinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,12 @@ bool QgisAppInterface::openFeatureForm( QgsVectorLayer *vlayer, QgsFeature &f, b
return action.editFeature();
}

QDialog* QgisAppInterface::getFeatureForm( QgsVectorLayer *l, QgsFeature &f )
{
QgsAttributeDialog *dialog = new QgsAttributeDialog( l, &f, false );
return dialog->dialog();
}

QList<QgsMapLayer *> QgisAppInterface::editableLayers( bool modified ) const
{
return qgis->editableLayers( modified );
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgisappinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ class QgisAppInterface : public QgisInterface
// @added in 1.6
virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false );

virtual QDialog* getFeatureForm(QgsVectorLayer *l, QgsFeature &f);

/** Return vector layers in edit mode
* @param modified whether to return only layers that have been modified
* @returns list of layers in legend order, or empty list
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsattributedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat

if ( vl->editType( fldIdx ) != QgsVectorLayer::Immutable )
{
myWidget->setEnabled( vl->isEditable() );
myWidget->setEnabled( vl->isEditable() && vl->fieldEditable(fldIdx) );
}

mypInnerLayout->addWidget( myWidget, index, 1 );
Expand Down Expand Up @@ -239,7 +239,7 @@ QgsAttributeDialog::QgsAttributeDialog( QgsVectorLayer *vl, QgsFeature *thepFeat

if ( vl->editType( fldIdx ) != QgsVectorLayer::Immutable )
{
( *itw )->setEnabled(( *itw )->isEnabled() && vl->isEditable() );
( *itw )->setEnabled( (*itw)->isEnabled() && vl->isEditable() && vl->fieldEditable( fldIdx ) );
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/app/qgsattributetypedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ QMap<QString, QVariant> &QgsAttributeTypeDialog::valueMap()
return mValueMap;
}

bool QgsAttributeTypeDialog::fieldEditable()
{
return isFieldEditableCheckBox->isChecked();
}

void QgsAttributeTypeDialog::setFieldEditable(bool editable)
{
isFieldEditableCheckBox->setChecked( editable );
}

QPair<QString, QString> QgsAttributeTypeDialog::checkedState()
{
return QPair<QString, QString>( leCheckedState->text(), leUncheckedState->text() );
Expand Down Expand Up @@ -538,6 +548,8 @@ void QgsAttributeTypeDialog::setStackPage( int index )
void QgsAttributeTypeDialog::accept()
{
//store data to output variables
mFieldEditable = isFieldEditableCheckBox->isChecked();

switch ( selectionListWidget->currentRow() )
{
default:
Expand Down
12 changes: 12 additions & 0 deletions src/app/qgsattributetypedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ class QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttributeTypeDialog
*/
void setValueRelation( QgsVectorLayer::ValueRelationData valueRelationData );

/**
* Setter for checkbox for editable state of field
* @param bool editable
*/
void setFieldEditable( bool editable );

/**
* Getter for checked state after editing
* @return string representing the checked
Expand All @@ -105,6 +111,11 @@ class QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttributeTypeDialog
*/
QgsVectorLayer::ValueRelationData valueRelationData();

/**
* Getter for checkbox for editable state of field
*/
bool fieldEditable();

private slots:
/**
* Slot to handle change of index in combobox to select correct page
Expand Down Expand Up @@ -160,6 +171,7 @@ class QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttributeTypeDialog
*/
void updateMap( const QMap<QString, QVariant> &map );

bool mFieldEditable;

QMap<QString, QVariant> mValueMap;

Expand Down
8 changes: 7 additions & 1 deletion src/app/qgsfieldsproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,13 +489,17 @@ void QgsFieldsProperties::attributeTypeDialog()

attributeTypeDialog.setIndex( index, mEditTypeMap.value( index, mLayer->editType( index ) ) );

attributeTypeDialog.setFieldEditable( mLayer->fieldEditable( index ) );

if ( !attributeTypeDialog.exec() )
return;

QgsVectorLayer::EditType editType = attributeTypeDialog.editType();

mEditTypeMap.insert( index, editType );

bool isFieldEditable = attributeTypeDialog.fieldEditable();
mFieldEditables.insert( index, isFieldEditable );

QString buttonText;
switch ( editType )
{
Expand Down Expand Up @@ -816,6 +820,8 @@ void QgsFieldsProperties::apply()
QgsVectorLayer::EditType editType = editTypeFromButtonText( pb->text() );
mLayer->setEditType( idx, editType );

mLayer->setFieldEditable( idx, mFieldEditables.value( idx, true ));

switch ( editType )
{
case QgsVectorLayer::ValueMap:
Expand Down
1 change: 1 addition & 0 deletions src/app/qgsfieldsproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class QgsFieldsProperties : public QWidget, private Ui_QgsFieldsPropertiesBase
QgsAttributesTree* mAttributesTree;
QgsAttributesList* mAttributesList;

QMap<int, bool> mFieldEditables;
QMap<int, QgsVectorLayer::ValueRelationData> mValueRelationData;
QMap<int, QMap<QString, QVariant> > mValueMaps;
QMap<int, QgsVectorLayer::RangeData> mRanges;
Expand Down
129 changes: 99 additions & 30 deletions src/app/qgsidentifyresultsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsMapToolIdentify::IdentifyResult re
}
else if ( result.mLayer->type() == QgsMapLayer::RasterLayer )
{
addFeature( qobject_cast<QgsRasterLayer *>( result.mLayer ), result.mLabel, result.mAttributes, result.mDerivedAttributes, result.mFields, result.mFeature );
addFeature( qobject_cast<QgsRasterLayer *>( result.mLayer ), result.mLabel, result.mAttributes, result.mDerivedAttributes, result.mFields, result.mFeature, result.mParams );
}
}

Expand Down Expand Up @@ -425,7 +425,8 @@ void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer,
const QMap<QString, QString> &attributes,
const QMap<QString, QString> &derivedAttributes,
const QgsFields &fields,
const QgsFeature &feature )
const QgsFeature &feature,
const QMap<QString, QVariant> &params )
{
QgsDebugMsg( QString( "feature.isValid() = %1" ).arg( feature.isValid() ) );
QTreeWidgetItem *layItem = layerItem( layer );
Expand All @@ -436,6 +437,8 @@ void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer,
{
layItem = new QTreeWidgetItem( QStringList() << QString::number( lstResults->topLevelItemCount() ) << layer->name() );
layItem->setData( 0, Qt::UserRole, QVariant::fromValue( qobject_cast<QObject *>( layer ) ) );

layItem->setData( 0, GetFeatureInfoUrlRole, params.value( "getFeatureInfoUrl" ) );
lstResults->addTopLevelItem( layItem );

QComboBox *formatCombo = new QComboBox();
Expand Down Expand Up @@ -647,39 +650,66 @@ void QgsIdentifyResultsDialog::itemClicked( QTreeWidgetItem *item, int column )

void QgsIdentifyResultsDialog::contextMenuEvent( QContextMenuEvent* event )
{
QgsDebugMsg( "Entered" );
QTreeWidgetItem *item = lstResults->itemAt( lstResults->viewport()->mapFrom( this, event->pos() ) );
// if the user clicked below the end of the attribute list, just return
if ( !item )
return;

QgsVectorLayer *vlayer = vectorLayer( item );
if ( vlayer == 0 )
QgsRasterLayer *rlayer = rasterLayer( item );
if ( vlayer == 0 && rlayer == 0 )
{
QgsDebugMsg( "Item does not belong to a layer." );
return;
}

if ( mActionPopup )
delete mActionPopup;

mActionPopup = new QMenu();

int idx = -1;
QTreeWidgetItem *featItem = featureItem( item );
//QTreeWidgetItem *featItem = featureItem( item );
QgsIdentifyResultsFeatureItem *featItem = dynamic_cast<QgsIdentifyResultsFeatureItem *>( featureItem( item ) );
if ( featItem )
{
mActionPopup->addAction(
QgsApplication::getThemeIcon( vlayer->isEditable() ? "/mIconEditable.png" : "/mIconEditable.png" ),
vlayer->isEditable() ? tr( "Edit feature form" ) : tr( "View feature form" ),
this, SLOT( featureForm() ) );
mActionPopup->addAction( tr( "Zoom to feature" ), this, SLOT( zoomToFeature() ) );
if ( vlayer )
{
mActionPopup->addAction(
QgsApplication::getThemeIcon( vlayer->isEditable() ? "/mIconEditable.png" : "/mIconEditable.png" ),
vlayer->isEditable() ? tr( "Edit feature form" ) : tr( "View feature form" ),
this, SLOT( featureForm() ) );
}

if ( featItem->feature().isValid() )
{
mActionPopup->addAction( tr( "Zoom to feature" ), this, SLOT( zoomToFeature() ) );
mActionPopup->addAction( tr( "Copy feature" ), this, SLOT( copyFeature() ) );
}

mActionPopup->addAction( tr( "Copy attribute value" ), this, SLOT( copyAttributeValue() ) );
mActionPopup->addAction( tr( "Copy feature attributes" ), this, SLOT( copyFeatureAttributes() ) );
mActionPopup->addSeparator();

if ( item->parent() == featItem && item->childCount() == 0 )
{
idx = item->data( 0, Qt::UserRole + 1 ).toInt();
}
}

if ( rlayer )
{
QTreeWidgetItem *layItem = layerItem( item );
if ( layItem && !layItem->data( 0, GetFeatureInfoUrlRole ).toString().isEmpty() )
{
mActionPopup->addAction( tr( "Copy GetFeatureInfo request URL" ), this, SLOT( copyGetFeatureInfoUrl() ) );
}
}
if ( mActionPopup->children().size() > 0 )
{
mActionPopup->addSeparator();
}

mActionPopup->addAction( tr( "Clear results" ), this, SLOT( clear() ) );
mActionPopup->addAction( tr( "Clear highlights" ), this, SLOT( clearHighlights() ) );
mActionPopup->addAction( tr( "Highlight all" ), this, SLOT( highlightAll() ) );
Expand All @@ -690,7 +720,7 @@ void QgsIdentifyResultsDialog::contextMenuEvent( QContextMenuEvent* event )
mActionPopup->addAction( tr( "Collapse all" ), this, SLOT( collapseAll() ) );
mActionPopup->addSeparator();

if ( featItem && vlayer->actions()->size() > 0 )
if ( featItem && vlayer && vlayer->actions()->size() > 0 )
{
mActionPopup->addSeparator();

Expand Down Expand Up @@ -1104,27 +1134,29 @@ void QgsIdentifyResultsDialog::zoomToFeature()
{
QTreeWidgetItem *item = lstResults->currentItem();

QgsVectorLayer *layer = vectorLayer( item );
if ( !layer )
return;

QTreeWidgetItem *featItem = featureItem( item );
if ( !featItem )
QgsMapLayer *layer;
QgsVectorLayer *vlayer = vectorLayer( item );
QgsRasterLayer *rlayer = rasterLayer( item );
if ( !vlayer && !rlayer )
{
return;
}

int fid = STRING_TO_FID( featItem->data( 0, Qt::UserRole ) );
layer = vlayer ? ( QgsMapLayer * )vlayer : ( QgsMapLayer * )rlayer;

QgsFeature feat;
if ( ! layer->getFeatures( QgsFeatureRequest().setFilterFid( fid ).setSubsetOfAttributes( QgsAttributeList() ) ).nextFeature( feat ) )
QgsIdentifyResultsFeatureItem *featItem = dynamic_cast<QgsIdentifyResultsFeatureItem *>( featureItem( item ) );
if ( !featItem )
{
return;
}

QgsFeature feat = featItem->feature();
if ( !feat.geometry() )
{
return;
}

// TODO: verify CRS for raster WMS features
QgsRectangle rect = mCanvas->mapRenderer()->layerExtentToOutputExtent( layer, feat.geometry()->boundingBox() );

if ( rect.isEmpty() )
Expand Down Expand Up @@ -1237,32 +1269,59 @@ void QgsIdentifyResultsDialog::copyAttributeValue()

void QgsIdentifyResultsDialog::copyFeatureAttributes()
{
QgsDebugMsg( "Entered" );
QClipboard *clipboard = QApplication::clipboard();
QString text;

QgsVectorLayer *vlayer = vectorLayer( lstResults->currentItem() );
if ( !vlayer )
QgsRasterLayer *rlayer = rasterLayer( lstResults->currentItem() );
if ( !vlayer & !rlayer )
{
return;
}
if ( vlayer )
{
int idx;
QgsAttributeMap attributes;
retrieveAttributes( lstResults->currentItem(), attributes, idx );

int idx;
QgsAttributeMap attributes;
retrieveAttributes( lstResults->currentItem(), attributes, idx );
const QgsFields &fields = vlayer->pendingFields();

const QgsFields &fields = vlayer->pendingFields();
for ( QgsAttributeMap::const_iterator it = attributes.begin(); it != attributes.end(); it++ )
{
int attrIdx = it.key();
if ( attrIdx < 0 || attrIdx >= fields.count() )
continue;

for ( QgsAttributeMap::const_iterator it = attributes.begin(); it != attributes.end(); it++ )
text += QString( "%1: %2\n" ).arg( fields[attrIdx].name() ).arg( it.value().toString() );
}
}
else if ( rlayer )
{
int attrIdx = it.key();
if ( attrIdx < 0 || attrIdx >= fields.count() )
continue;
QTreeWidgetItem *featItem = featureItem( lstResults->currentItem() );
if ( !featItem ) return;

text += QString( "%1: %2\n" ).arg( fields[attrIdx].name() ).arg( it.value().toString() );
for ( int i = 0; i < featItem->childCount(); i++ )
{
QTreeWidgetItem *item = featItem->child( i );
if ( item->childCount() > 0 ) continue;
text += QString( "%1: %2\n" ).arg( item->data( 0, Qt::DisplayRole ).toString() ).arg( item->data( 1, Qt::DisplayRole ).toString() );
}
}

QgsDebugMsg( QString( "set clipboard: %1" ).arg( text ) );
clipboard->setText( text );
}

void QgsIdentifyResultsDialog::copyGetFeatureInfoUrl()
{
QClipboard *clipboard = QApplication::clipboard();
QTreeWidgetItem *item = lstResults->currentItem();
QTreeWidgetItem *layItem = layerItem( item );
if ( !layItem ) { return; }
clipboard->setText( layItem->data( 0, GetFeatureInfoUrlRole ).toString() );
}

void QgsIdentifyResultsDialog::openUrl( const QUrl &url )
{
if ( !QDesktopServices::openUrl( url ) )
Expand Down Expand Up @@ -1301,6 +1360,11 @@ void QgsIdentifyResultsDialog::on_mExpandNewToolButton_toggled( bool checked )
void QgsIdentifyResultsDialog::on_mCopyToolButton_clicked( bool checked )
{
Q_UNUSED( checked );
copyFeature();
}

void QgsIdentifyResultsDialog::copyFeature()
{
QgsDebugMsg( "Entered" );

QgsIdentifyResultsFeatureItem *item = dynamic_cast<QgsIdentifyResultsFeatureItem *>( featureItem( lstResults->selectedItems().value( 0 ) ) );
Expand Down Expand Up @@ -1338,6 +1402,11 @@ void QgsIdentifyResultsDialog::formatChanged( int index )

// remove all childs of that layer from results, except the first (format)
QTreeWidgetItem *layItem = layerItem(( QObject * )layer );
if ( !layItem )
{
QgsDebugMsg( "cannot get layer item" );
return;
}
for ( int i = layItem->childCount() - 1; i > 0; i-- )
{
layItem->removeChild( layItem->child( i ) );
Expand Down
9 changes: 8 additions & 1 deletion src/app/qgsidentifyresultsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ class QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdentifyResultsBa
const QMap< QString, QString > &attributes,
const QMap< QString, QString > &derivedAttributes,
const QgsFields &fields = QgsFields(),
const QgsFeature &feature = QgsFeature() );
const QgsFeature &feature = QgsFeature(),
const QMap<QString, QVariant> &params = ( QMap<QString, QVariant>() ) );

/** Add feature from identify results */
void addFeature( QgsMapToolIdentify::IdentifyResult result );
Expand Down Expand Up @@ -150,7 +151,9 @@ class QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdentifyResultsBa
void featureForm();
void zoomToFeature();
void copyAttributeValue();
void copyFeature();
void copyFeatureAttributes();
void copyGetFeatureInfoUrl();
void highlightAll();
void highlightLayer();
void layerProperties();
Expand Down Expand Up @@ -184,6 +187,10 @@ class QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdentifyResultsBa
void printCurrentItem();

private:
enum ItemDataRole
{
GetFeatureInfoUrlRole = Qt::UserRole + 10
};

QMenu *mActionPopup;
QMap<QTreeWidgetItem *, QgsHighlight * > mHighlights;
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolidentifyaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void QgsMapToolIdentifyAction::handleChangedRasterResults( QList<IdentifyResult>
{
if ( rresult->mLayer->type() == QgsMapLayer::RasterLayer )
{
resultsDialog()->addFeature( qobject_cast<QgsRasterLayer *>( rresult->mLayer ), rresult->mLabel, rresult->mAttributes, rresult->mDerivedAttributes, rresult->mFields, rresult->mFeature );
resultsDialog()->addFeature( *rresult );
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ SET(QGIS_CORE_SRCS
qgsnetworkreplyparser.cpp
qgscredentials.cpp
qgsofflineediting.cpp
qgsogcutils.cpp
qgsoverlayobject.cpp
qgsowsconnection.cpp
qgspalgeometry.cpp
Expand Down Expand Up @@ -404,6 +405,7 @@ SET(QGIS_CORE_HDRS
qgsnetworkreplyparser.h
qgscredentials.h
qgsofflineediting.h
qgsogcutils.h
qgsoverlayobjectpositionmanager.h
qgsowsconnection.h
qgspallabeling.h
Expand Down
18 changes: 9 additions & 9 deletions src/core/composer/qgscomposerlegend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ QSizeF QgsComposerLegend::paintAndDetermineSize( QPainter* painter )

setColumns( atomList );

double maxColumnWidth = 0;
qreal maxColumnWidth = 0;
if ( mEqualColumnWidth )
{
foreach ( Atom atom, atomList )
Expand All @@ -112,7 +112,7 @@ QSizeF QgsComposerLegend::paintAndDetermineSize( QPainter* painter )
QPointF point( mBoxSpace, columnTop );
bool firstInColumn = true;
double columnMaxHeight = 0;
double columnWidth = 0;
qreal columnWidth = 0;
int column = 0;
foreach ( Atom atom, atomList )
{
Expand Down Expand Up @@ -212,8 +212,8 @@ QSizeF QgsComposerLegend::drawTitle( QPainter* painter, QPointF point, Qt::Align
for ( QStringList::Iterator titlePart = lines.begin(); titlePart != lines.end(); ++titlePart )
{
// it does not draw the last world if rectangle width is exactly text width
double width = textWidthMillimeters( mTitleFont, *titlePart ) + 1;
double height = fontAscentMillimeters( mTitleFont ) + fontDescentMillimeters( mTitleFont );
qreal width = textWidthMillimeters( mTitleFont, *titlePart ) + 1;
qreal height = fontAscentMillimeters( mTitleFont ) + fontDescentMillimeters( mTitleFont );

double left = halignment == Qt::AlignLeft ? point.x() : point.x() - width / 2;

Expand Down Expand Up @@ -249,7 +249,7 @@ QSizeF QgsComposerLegend::drawGroupItemTitle( QgsComposerGroupItem* groupItem, Q
{
y += fontAscentMillimeters( mGroupFont );
if ( painter ) drawText( painter, point.x(), y, *groupPart, mGroupFont );
double width = textWidthMillimeters( mGroupFont, *groupPart );
qreal width = textWidthMillimeters( mGroupFont, *groupPart );
size.rwidth() = qMax( width, size.width() );
if ( groupPart != lines.end() )
{
Expand Down Expand Up @@ -277,7 +277,7 @@ QSizeF QgsComposerLegend::drawLayerItemTitle( QgsComposerLayerItem* layerItem, Q
{
y += fontAscentMillimeters( mLayerFont );
if ( painter ) drawText( painter, point.x(), y, *layerItemPart , mLayerFont );
double width = textWidthMillimeters( mLayerFont, *layerItemPart );
qreal width = textWidthMillimeters( mLayerFont, *layerItemPart );
size.rwidth() = qMax( width, size.width() );
if ( layerItemPart != lines.end() )
{
Expand Down Expand Up @@ -401,7 +401,7 @@ QgsComposerLegend::Nucleon QgsComposerLegend::drawSymbolItem( QgsComposerLegendI
for ( QStringList::Iterator itemPart = lines.begin(); itemPart != lines.end(); ++itemPart )
{
if ( painter ) drawText( painter, labelX, labelY, *itemPart , mItemFont );
labelSize.rwidth() = qMax( textWidthMillimeters( mItemFont, *itemPart ), labelSize.width() );
labelSize.rwidth() = qMax( textWidthMillimeters( mItemFont, *itemPart ), double(labelSize.width()) );
if ( itemPart != lines.end() )
{
labelY += mlineSpacing + textHeight;
Expand Down Expand Up @@ -1012,7 +1012,7 @@ void QgsComposerLegend::setColumns( QList<Atom>& atomList )
// Divide atoms to columns
double totalHeight = 0;
bool first = true;
double maxAtomHeight = 0;
qreal maxAtomHeight = 0;
foreach ( Atom atom, atomList )
{
if ( !first )
Expand Down Expand Up @@ -1073,7 +1073,7 @@ void QgsComposerLegend::setColumns( QList<Atom>& atomList )
}

// Alling labels of symbols for each layr/column to the same labelXOffset
QMap<QString, double> maxSymbolWidth;
QMap<QString, qreal> maxSymbolWidth;
for ( int i = 0; i < atomList.size(); i++ )
{
for ( int j = 0; j < atomList[i].nucleons.size(); j++ )
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposerlegend.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class CORE_EXPORT QgsComposerLegend : public QgsComposerItem
QColor mFontColor;

/**Space between item box and contents*/
double mBoxSpace;
qreal mBoxSpace;
/**Space between columns*/
double mColumnSpace;
/**Vertical space between group entries*/
Expand Down
7 changes: 4 additions & 3 deletions src/core/qgscoordinatetransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,10 @@ void QgsCoordinateTransform::transformPolygon( QPolygonF& poly, TransformDirecti
{
//create x, y arrays
int nVertices = poly.size();
QVector<qreal> x( nVertices );
QVector<qreal> y( nVertices );
QVector<qreal> z( nVertices );

QVector<double> x( nVertices );
QVector<double> y( nVertices );
QVector<double> z( nVertices );

for ( int i = 0; i < nVertices; ++i )
{
Expand Down
10 changes: 5 additions & 5 deletions src/core/qgsexpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "qgsfeature.h"
#include "qgsgeometry.h"
#include "qgslogger.h"
#include "qgsogcutils.h"

// from parser
extern QgsExpression::Node* parseExpression( const QString& str, QString& parserErrorMsg );
Expand Down Expand Up @@ -796,7 +797,7 @@ static QVariant fcnGeomFromWKT( const QVariantList& values, QgsFeature*, QgsExpr
static QVariant fcnGeomFromGML2( const QVariantList& values, QgsFeature*, QgsExpression* parent )
{
QString gml = getStringValue( values.at( 0 ), parent );
QgsGeometry* geom = QgsGeometry::fromGML2( gml );
QgsGeometry* geom = QgsOgcUtils::geometryFromGML2( gml );

if ( geom )
return QVariant::fromValue( *geom );
Expand Down Expand Up @@ -2268,11 +2269,10 @@ void QgsExpression::NodeFunction::toOgcFilter( QDomDocument &doc, QDomElement &e
{
if ( childElem.attribute( "name" ) == "geomFromWKT" )
{
QgsGeometry* geom = 0;
geom = QgsGeometry::fromWkt( childElem.firstChildElement().text() );
QgsGeometry* geom = QgsGeometry::fromWkt( childElem.firstChildElement().text() );
if ( geom )
funcElem.appendChild( geom->exportToGML2( doc ) );

funcElem.appendChild( QgsOgcUtils::geometryToGML2( geom, doc ) );
delete geom;
}
else if ( childElem.attribute( "name" ) == "geomFromGML2" )
{
Expand Down
929 changes: 0 additions & 929 deletions src/core/qgsgeometry.cpp

Large diffs are not rendered by default.

36 changes: 0 additions & 36 deletions src/core/qgsgeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,6 @@ class CORE_EXPORT QgsGeometry
/** static method that creates geometry from Wkt */
static QgsGeometry* fromWkt( QString wkt );

/** static method that creates geometry from GML2
@param XML representation of the geometry. GML elements are expected to be
in default namespace (<Point>...</Point>) or in "gml" namespace (<gml:Point>...</gml:Point>)
@note added in 1.9
*/
static QgsGeometry* fromGML2( const QString& xmlString );

/** static method that creates geometry from GML2
@note added in 1.9
*/
static QgsGeometry* fromGML2( const QDomNode& geometryNode );

/** construct geometry from a point */
static QgsGeometry* fromPoint( const QgsPoint& point );
/** construct geometry from a multipoint */
Expand Down Expand Up @@ -395,12 +383,6 @@ class CORE_EXPORT QgsGeometry
*/
QString exportToGeoJSON();

/** Exports the geometry to mGML2
@return true in case of success and false else
* @note added in 1.9
*/
QDomElement exportToGML2( QDomDocument& doc );

/* Accessor functions for getting geometry data */

/** return contents of the geometry as a point
Expand Down Expand Up @@ -506,24 +488,6 @@ class CORE_EXPORT QgsGeometry

// Private functions

/** static method that creates geometry from GML2 Point */
bool setFromGML2Point( const QDomElement& geometryElement );
/** static method that creates geometry from GML2 LineString */
bool setFromGML2LineString( const QDomElement& geometryElement );
/** static method that creates geometry from GML2 Polygon */
bool setFromGML2Polygon( const QDomElement& geometryElement );
/** static method that creates geometry from GML2 MultiPoint */
bool setFromGML2MultiPoint( const QDomElement& geometryElement );
/** static method that creates geometry from GML2 MultiLineString */
bool setFromGML2MultiLineString( const QDomElement& geometryElement );
/** static method that creates geometry from GML2 MultiPolygon */
bool setFromGML2MultiPolygon( const QDomElement& geometryElement );
/**Reads the <gml:coordinates> element and extracts the coordinates as points
@param coords list where the found coordinates are appended
@param elem the <gml:coordinates> element
@return boolean for success*/
bool readGML2Coordinates( std::list<QgsPoint>& coords, const QDomElement elem ) const;

/** Converts from the WKB geometry to the GEOS geometry.
@return true in case of success and false else
*/
Expand Down
969 changes: 969 additions & 0 deletions src/core/qgsogcutils.cpp

Large diffs are not rendered by default.

67 changes: 67 additions & 0 deletions src/core/qgsogcutils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#ifndef QGSOGCUTILS_H
#define QGSOGCUTILS_H

class QDomNode;
class QDomElement;
class QDomDocument;
class QString;

#include <list>

class QgsGeometry;
class QgsPoint;
class QgsRectangle;

/**
* @brief The QgsOgcUtils class provides various utility functions for conversion between
* OGC (Open Geospatial Consortium) standards and QGIS internal representations.
*
* Currently supported standards:
* - GML2 - Geography Markup Language (import, export)
*
* @note added in 2.0
*/
class CORE_EXPORT QgsOgcUtils
{
public:


/** static method that creates geometry from GML2
@param XML representation of the geometry. GML elements are expected to be
in default namespace (<Point>...</Point>) or in "gml" namespace (<gml:Point>...</gml:Point>)
*/
static QgsGeometry* geometryFromGML2( const QString& xmlString );

/** static method that creates geometry from GML2
*/
static QgsGeometry* geometryFromGML2( const QDomNode& geometryNode );

/** Exports the geometry to mGML2
@return true in case of success and false else
*/
static QDomElement geometryToGML2( QgsGeometry* geometry, QDomDocument& doc );

/** read rectangle from GML2 Box */
static QgsRectangle rectangleFromGMLBox( const QDomNode& boxNode );

private:
/** static method that creates geometry from GML2 Point */
static QgsGeometry* geometryFromGML2Point( const QDomElement& geometryElement );
/** static method that creates geometry from GML2 LineString */
static QgsGeometry* geometryFromGML2LineString( const QDomElement& geometryElement );
/** static method that creates geometry from GML2 Polygon */
static QgsGeometry* geometryFromGML2Polygon( const QDomElement& geometryElement );
/** static method that creates geometry from GML2 MultiPoint */
static QgsGeometry* geometryFromGML2MultiPoint( const QDomElement& geometryElement );
/** static method that creates geometry from GML2 MultiLineString */
static QgsGeometry* geometryFromGML2MultiLineString( const QDomElement& geometryElement );
/** static method that creates geometry from GML2 MultiPolygon */
static QgsGeometry* geometryFromGML2MultiPolygon( const QDomElement& geometryElement );
/** Reads the <gml:coordinates> element and extracts the coordinates as points
@param coords list where the found coordinates are appended
@param elem the <gml:coordinates> element
@return boolean for success*/
static bool readGML2Coordinates( std::list<QgsPoint>& coords, const QDomElement elem );
};

#endif // QGSOGCUTILS_H
31 changes: 25 additions & 6 deletions src/core/qgsproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "qgsprojectversion.h"
#include "qgspluginlayer.h"
#include "qgspluginlayerregistry.h"
#include "qgsdatasourceuri.h"

#include <QApplication>
#include <QFileInfo>
Expand Down Expand Up @@ -1597,13 +1598,31 @@ bool QgsProject::createEmbeddedLayer( const QString& layerId, const QString& pro
//change datasource path from relative to absolute if necessary
if ( !useAbsolutePathes )
{
QDomElement dsElem = mapLayerElem.firstChildElement( "datasource" );
QString debug( QFileInfo( projectFilePath ).absolutePath() + "/" + dsElem.text() );
QFileInfo absoluteDs( QFileInfo( projectFilePath ).absolutePath() + "/" + dsElem.text() );
if ( absoluteDs.exists() )
QDomElement provider = mapLayerElem.firstChildElement( "provider" );
if ( provider.text() == "spatialite" )
{
dsElem.removeChild( dsElem.childNodes().at( 0 ) );
dsElem.appendChild( projectDocument.createTextNode( absoluteDs.absoluteFilePath() ) );
QDomElement dsElem = mapLayerElem.firstChildElement( "datasource" );

QgsDataSourceURI uri( dsElem.text() );

QFileInfo absoluteDs( QFileInfo( projectFilePath ).absolutePath() + "/" + uri.database() );
if ( absoluteDs.exists() )
{
uri.setDatabase( absoluteDs.absoluteFilePath() );
dsElem.removeChild( dsElem.childNodes().at( 0 ) );
dsElem.appendChild( projectDocument.createTextNode( uri.uri() ) );
}
}
else
{
QDomElement dsElem = mapLayerElem.firstChildElement( "datasource" );
QString debug( QFileInfo( projectFilePath ).absolutePath() + "/" + dsElem.text() );
QFileInfo absoluteDs( QFileInfo( projectFilePath ).absolutePath() + "/" + dsElem.text() );
if ( absoluteDs.exists() )
{
dsElem.removeChild( dsElem.childNodes().at( 0 ) );
dsElem.appendChild( projectDocument.createTextNode( absoluteDs.absoluteFilePath() ) );
}
}
}

Expand Down
26 changes: 0 additions & 26 deletions src/core/qgsrectangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,32 +55,6 @@ QgsRectangle::QgsRectangle( const QgsRectangle &r )
ymax = r.yMaximum();
}

QgsRectangle::QgsRectangle( const QDomNode& boxNode )
{
QDomElement boxElem = boxNode.toElement();
if ( boxElem.tagName() == "Box" )
{
QDomElement bElem = boxElem.firstChild().toElement();
QString coordSeparator = ",";
QString tupelSeparator = " ";
if ( bElem.hasAttribute( "cs" ) )
{
coordSeparator = bElem.attribute( "cs" );
}
if ( bElem.hasAttribute( "ts" ) )
{
tupelSeparator = bElem.attribute( "ts" );
}

QString bString = bElem.text();
bool conversionSuccess;
xmin = bString.section( tupelSeparator, 0, 0 ).section( coordSeparator, 0, 0 ).toDouble( &conversionSuccess );
ymin = bString.section( tupelSeparator, 0, 0 ).section( coordSeparator, 1, 1 ).toDouble( &conversionSuccess );
xmax = bString.section( tupelSeparator, 1, 1 ).section( coordSeparator, 0, 0 ).toDouble( &conversionSuccess );
ymax = bString.section( tupelSeparator, 1, 1 ).section( coordSeparator, 1, 1 ).toDouble( &conversionSuccess );
}
normalize();
}

void QgsRectangle::set( const QgsPoint& p1, const QgsPoint& p2 )
{
Expand Down
3 changes: 0 additions & 3 deletions src/core/qgsrectangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ class CORE_EXPORT QgsRectangle
QgsRectangle( const QRectF & qRectF );
//! Copy constructor
QgsRectangle( const QgsRectangle &other );
//! GML2 constructor
//@note added in 1.9
QgsRectangle( const QDomNode& boxNode );
//! Destructor
~QgsRectangle();
//! Set the rectangle from two QgsPoints. The rectangle is
Expand Down
21 changes: 20 additions & 1 deletion src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2313,7 +2313,6 @@ bool QgsVectorLayer::readXml( const QDomNode& layer_node )
} // void QgsVectorLayer::readXml



bool QgsVectorLayer::setDataProvider( QString const & provider )
{
// XXX should I check for and possibly delete any pre-existing providers?
Expand Down Expand Up @@ -2618,6 +2617,9 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
EditType editType = ( EditType ) editTypeElement.attribute( "type" ).toInt();
mEditTypes.insert( name, editType );

int editable = editTypeElement.attribute( "editable" , "1" ).toInt();
mFieldEditables.insert( name, editable == 1 );

switch ( editType )
{
case ValueMap:
Expand Down Expand Up @@ -2933,6 +2935,7 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
QDomElement editTypeElement = doc.createElement( "edittype" );
editTypeElement.setAttribute( "name", it.key() );
editTypeElement.setAttribute( "type", it.value() );
editTypeElement.setAttribute( "editable", mFieldEditables[ it.key()] ? 1 : 0 );

switch (( EditType ) it.value() )
{
Expand Down Expand Up @@ -3895,6 +3898,22 @@ QgsVectorLayer::RangeData &QgsVectorLayer::range( int idx )
return mRanges[fieldName];
}

bool QgsVectorLayer::fieldEditable( int idx )
{
const QgsFields &fields = pendingFields();
if ( idx >= 0 && idx < fields.count() && mEditTypes.contains( fields[idx].name() ) )
return mFieldEditables[ fields[idx].name()];
else
return false;
}

void QgsVectorLayer::setFieldEditable( int idx, bool editable )
{
const QgsFields &fields = pendingFields();
if ( idx >= 0 && idx < fields.count() && mEditTypes.contains( fields[idx].name() ) )
mFieldEditables[ fields[idx].name()] = editable;
}

void QgsVectorLayer::addOverlay( QgsVectorOverlay* overlay )
{
mOverlays.push_back( overlay );
Expand Down
12 changes: 12 additions & 0 deletions src/core/qgsvectorlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,17 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
**/
ValueRelationData &valueRelation( int idx );

/**is edit widget editable
* @note added in 1.9
**/
bool fieldEditable( int idx );

/**set edit widget editable
* @note added in 1.9
**/
void setFieldEditable( int idx, bool editable );


/**Adds a new overlay to this class. QgsVectorLayer takes ownership of the object
@note this method was added in version 1.1
*/
Expand Down Expand Up @@ -1058,6 +1069,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
QStringList mCommitErrors;

QMap< QString, EditType > mEditTypes;
QMap< QString, bool> mFieldEditables;
QMap< QString, QMap<QString, QVariant> > mValueMaps;
QMap< QString, RangeData > mRanges;
QMap< QString, QPair<QString, QString> > mCheckedStates;
Expand Down
7 changes: 5 additions & 2 deletions src/core/raster/qgspalettedrasterrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@ class CORE_EXPORT QgsPalettedRasterRenderer: public QgsRasterRenderer

void draw( QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* theQgsMapToPixel );

QgsRasterBlock * block( int bandNo, QgsRectangle const & extent, int width, int height );
QgsRasterBlock *block( int bandNo, const QgsRectangle & extent, int width, int height );

/**Returns number of colors*/
int nColors() const { return mNColors; }
/**Returns copy of color array (caller takes ownership)*/
QColor* colors() const;
/**Returns copy of rgb array (caller takes ownership)*/

/**Returns copy of rgb array (caller takes ownership)
@note not available in python bindings
*/
QRgb* rgbArray() const;

void writeXML( QDomDocument& doc, QDomElement& parentElem ) const;
Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology-ng/qgsrendererv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ void QgsFeatureRendererV2::renderFeatureWithSymbol( QgsFeature& feature, QgsSymb
break;

default:
QgsDebugMsg( QString( "unsupported wkb type 0x%1 for rendering" ).arg( geom->wkbType(), 0, 16 ) );
QgsDebugMsg( QString( "feature %1: unsupported wkb type 0x%2 for rendering" ).arg( feature.id() ).arg( geom->wkbType(), 0, 16 ) );
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/gui/qgisinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,8 @@ class GUI_EXPORT QgisInterface : public QObject
// @added in 1.6
virtual bool openFeatureForm( QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly = false ) = 0;

virtual QDialog* getFeatureForm( QgsVectorLayer *l, QgsFeature &f ) = 0;

/** Return vector layers in edit mode
* @param modified whether to return only layers that have been modified
* @returns list of layers in legend order, or empty list
Expand Down
7 changes: 6 additions & 1 deletion src/gui/qgsmaptoolidentify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,12 +487,17 @@ bool QgsMapToolIdentify::identifyRasterLayer( QList<IdentifyResult> *results, Qg
if ( featureType.compare( sublayer, Qt::CaseInsensitive ) != 0 || labels.isEmpty() )
{
labels << featureType;


}

QMap< QString, QString > derAttributes = derivedAttributes;
derAttributes.unite( featureDerivedAttributes( &feature, layer ) );

results->append( IdentifyResult( qobject_cast<QgsMapLayer *>( layer ), labels.join( " / " ), featureStore.fields(), feature, derAttributes ) );
IdentifyResult identifyResult( qobject_cast<QgsMapLayer *>( layer ), labels.join( " / " ), featureStore.fields(), feature, derAttributes );

identifyResult.mParams.insert( "getFeatureInfoUrl", featureStore.params().value( "getFeatureInfoUrl" ) );
results->append( identifyResult );
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgsmaptoolidentify.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class GUI_EXPORT QgsMapToolIdentify : public QgsMapTool
QgsFeature mFeature;
QMap< QString, QString > mAttributes;
QMap< QString, QString > mDerivedAttributes;
QMap< QString, QVariant > mParams;
};

//! constructor
Expand Down
14 changes: 8 additions & 6 deletions src/mapserver/qgsfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "qgslogicalfilter.h"
#include "qgsspatialfilter.h"
#include "qgsvectordataprovider.h"
#include "qgsogcutils.h"

#include <QDomElement>
#include <QStringList>
#include "qgsvectorlayer.h"
Expand Down Expand Up @@ -129,7 +131,7 @@ QgsFilter* QgsFilter::createFilterFromXml( const QDomElement& filterElem, QgsVec
if ( gNodes.size() > 0 )
{
QDomElement gElem = gNodes.at( 0 ).toElement();
geom = QgsGeometry::fromGML2( gElem );
geom = QgsOgcUtils::geometryFromGML2( gElem );
}
}

Expand All @@ -139,7 +141,7 @@ QgsFilter* QgsFilter::createFilterFromXml( const QDomElement& filterElem, QgsVec
if ( gNodes.size() > 0 )
{
QDomElement gElem = gNodes.at( 0 ).toElement();
geom = QgsGeometry::fromGML2( gElem );
geom = QgsOgcUtils::geometryFromGML2( gElem );
}
}

Expand All @@ -149,7 +151,7 @@ QgsFilter* QgsFilter::createFilterFromXml( const QDomElement& filterElem, QgsVec
if ( gNodes.size() > 0 )
{
QDomElement gElem = gNodes.at( 0 ).toElement();
geom = QgsGeometry::fromGML2( gElem );
geom = QgsOgcUtils::geometryFromGML2( gElem );
}
}

Expand All @@ -159,7 +161,7 @@ QgsFilter* QgsFilter::createFilterFromXml( const QDomElement& filterElem, QgsVec
if ( gNodes.size() > 0 )
{
QDomElement gElem = gNodes.at( 0 ).toElement();
geom = QgsGeometry::fromGML2( gElem );
geom = QgsOgcUtils::geometryFromGML2( gElem );
}
}

Expand All @@ -169,7 +171,7 @@ QgsFilter* QgsFilter::createFilterFromXml( const QDomElement& filterElem, QgsVec
if ( gNodes.size() > 0 )
{
QDomElement gElem = gNodes.at( 0 ).toElement();
geom = QgsGeometry::fromGML2( gElem );
geom = QgsOgcUtils::geometryFromGML2( gElem );
}
}

Expand All @@ -179,7 +181,7 @@ QgsFilter* QgsFilter::createFilterFromXml( const QDomElement& filterElem, QgsVec
if ( gNodes.size() > 0 )
{
QDomElement gElem = gNodes.at( 0 ).toElement();
geom = QgsGeometry::fromGML2( gElem );
geom = QgsOgcUtils::geometryFromGML2( gElem );
}
}

Expand Down
16 changes: 9 additions & 7 deletions src/mapserver/qgswfsserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#include "qgslegendmodel.h"
#include "qgscomposerlegenditem.h"
#include "qgsrequesthandler.h"
#include "qgsogcutils.h"

#include <QImage>
#include <QPainter>
#include <QStringList>
Expand Down Expand Up @@ -509,11 +511,11 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
{
if ( childElem.tagName() == "Box" )
{
req.setFilterRect( QgsRectangle( childElem ) );
req.setFilterRect( QgsOgcUtils::rectangleFromGMLBox( childElem ) );
}
else if ( childElem.tagName() != "PropertyName" )
{
QgsGeometry *geom = QgsGeometry::fromGML2( childElem );
QgsGeometry *geom = QgsOgcUtils::geometryFromGML2( childElem );
req.setFilterRect( geom->boundingBox() );
delete geom;
}
Expand Down Expand Up @@ -892,11 +894,11 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
{
if ( childElem.tagName() == "Box" )
{
req.setFilterRect( QgsRectangle( childElem ) );
req.setFilterRect( QgsOgcUtils::rectangleFromGMLBox( childElem ) );
}
else if ( childElem.tagName() != "PropertyName" )
{
QgsGeometry* geom = QgsGeometry::fromGML2( childElem );
QgsGeometry* geom = QgsOgcUtils::geometryFromGML2( childElem );
req.setFilterRect( geom->boundingBox() );
delete geom;
}
Expand Down Expand Up @@ -1335,7 +1337,7 @@ QDomDocument QgsWFSServer::transaction( const QString& requestBody )

if ( !geometryElem.isNull() )
{
if ( !layer->changeGeometry( *fidIt, QgsGeometry::fromGML2( geometryElem ) ) )
if ( !layer->changeGeometry( *fidIt, QgsOgcUtils::geometryFromGML2( geometryElem ) ) )
throw QgsMapServiceException( "RequestNotWellFormed", "Error in change geometry" );
}
}
Expand Down Expand Up @@ -1451,7 +1453,7 @@ QDomDocument QgsWFSServer::transaction( const QString& requestBody )
}
else //a geometry attribute
{
f->setGeometry( QgsGeometry::fromGML2( currentAttributeElement ) );
f->setGeometry( QgsOgcUtils::geometryFromGML2( currentAttributeElement ) );
}
}
currentAttributeChild = currentAttributeChild.nextSibling();
Expand Down Expand Up @@ -1649,7 +1651,7 @@ QDomElement QgsWFSServer::createFeatureGML2( QgsFeature* feat, QDomDocument& doc
QgsGeometry* geom = feat->geometry();

QDomElement geomElem = doc.createElement( "qgs:geometry" );
QDomElement gmlElem = geom->exportToGML2( doc );
QDomElement gmlElem = QgsOgcUtils::geometryToGML2( geom, doc );
if ( !gmlElem.isNull() )
{
QgsRectangle box = geom->boundingBox();
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/heatmap/heatmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void Heatmap::run()
rField = d.radiusField();
myAttrList.append( rField );
QgsDebugMsg( QString( "Radius Field index received: %1" ).arg( rField ) );

// If not using map units, then calculate a conversion factor to convert the radii to map units
if ( d.radiusUnit() == HeatmapGui::Meters )
{
Expand All @@ -188,13 +188,13 @@ void Heatmap::run()
radius = d.radius(); // radius returned by d.radius() is already in map units
myBuffer = bufferSize( radius, cellsize );
}

if ( d.weighted() )
{
wField = d.weightField();
myAttrList.append( wField );
}

// This might have attributes or mightnot have attibutes at all
// based on the variableRadius() and weighted()
QgsFeatureIterator fit = inputLayer->getFeatures( QgsFeatureRequest().setSubsetOfAttributes( myAttrList ) );
Expand Down Expand Up @@ -226,14 +226,14 @@ void Heatmap::run()
{
continue;
}

// If radius is variable then fetch it and calculate new pixel buffer size
if ( d.variableRadius() )
{
radius = myFeature.attribute( rField ).toFloat() * radiusToMapUnits;
myBuffer = bufferSize( radius, cellsize );
}

int blockSize = 2 * myBuffer + 1; //Block SIDE would be more appropriate
// calculate the pixel position
unsigned int xPosition, yPosition;
Expand All @@ -256,7 +256,7 @@ void Heatmap::run()
for ( int yp = 0; yp <= myBuffer; yp++ )
{
float distance = sqrt( pow( xp, 2.0 ) + pow( yp, 2.0 ) );

// is pixel outside search bandwidth of feature?
if ( distance > myBuffer )
{
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/heatmap/heatmapgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ bool HeatmapGui::variableRadius()

float HeatmapGui::radius()
{
float radius = mBufferLineEdit->text().toInt();
float radius = mBufferLineEdit->text().toFloat();
if ( mRadiusUnitCombo->currentIndex() == HeatmapGui::Meters )
{
radius = mapUnitsOf( radius, inputVectorLayer()->crs() );
Expand Down
124 changes: 55 additions & 69 deletions src/providers/oracle/ocispatial/qsql_ocispatial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ class enter
}
};

#ifdef _MSC_VER
#define ENTER enter here(__FUNCTION__,__FILE__,__LINE__);
#else
#define ENTER enter here(__PRETTY_FUNCTION__,__FILE__,__LINE__);
#endif

int enter::level = 0;
#else
Expand Down Expand Up @@ -1152,8 +1156,7 @@ class QOCISpatialCols
bool getValue( OCINumber *num, int &value );
bool getValue( OCINumber *num, double &value );
bool getArraySize( OCIColl *coll, int &nSize );
bool getArrayItem( OCIArray *coll, int elem, int &item );
bool getElemInfoElem( int elem, int nElems, int nOrds, int &startOffset, int &endOffset, int &etype, int &interpretation );
bool getElemInfoElem( int elem, const QVector<int> &vElem, int nOrds, int &startOffset, int &endOffset, int &etype, int &interpretation );
static int byteorder() { static char littleEndian = htonl( 1 ) != 1; return littleEndian; }

#ifdef QOCISPATIAL_DEBUG
Expand Down Expand Up @@ -2289,46 +2292,21 @@ bool QOCISpatialCols::getArraySize( OCIColl *coll, int &nSize )
return false;
}

bool QOCISpatialCols::getArrayItem( OCIArray *coll, int elem, int &item )
{
OCINumber *num;
boolean exists;

try
{
OCI_VERIFY_E( d->err, OCICollGetElem( d->env, d->err, coll, elem, &exists, ( dvoid ** ) &num, 0 ) );

if ( !exists )
{
qWarning( "item %d does not exists.", elem );
throw OCI_ERROR;
}

return getValue( num, item );
}
catch ( int )
{
return false;
}
}

bool QOCISpatialCols::getElemInfoElem( int iElem, int nElems, int nOrds,
bool QOCISpatialCols::getElemInfoElem( int iElem, const QVector<int> &vElems, int nOrds,
int &startOffset, int &endOffset,
int &etype, int &interpretation )
{
if ( !getArrayItem( d->sdoobj->elem_info, iElem + 0, startOffset ) ||
!getArrayItem( d->sdoobj->elem_info, iElem + 1, etype ) ||
!getArrayItem( d->sdoobj->elem_info, iElem + 2, interpretation ) )
return false;
startOffset = vElems[ iElem + 0 ];
etype = vElems[ iElem + 1 ];
interpretation = vElems[ iElem + 2 ];

if ( iElem + 3 == nElems )
if ( iElem + 3 >= vElems.size() )
{
endOffset = nOrds + 1;
}
else if ( !getArrayItem( d->sdoobj->elem_info, iElem + 3, endOffset ) )
else
{
qWarning() << "end offset not found";
return false;
endOffset = vElems[ iElem + 3 ];
}

--startOffset;
Expand Down Expand Up @@ -2470,41 +2448,49 @@ bool QOCISpatialCols::convertToWkb( QVariant &v )
return false;
}

QVector<double> ordinates( nOrds );
boolean exists;
QVector<int> elems( nElems );

try
{
#if 0
// TODO figure this out - quicker, but occasionally crashes
QVector<OCINumber*> numbers( nOrds, 0 );
uword nords = nOrds;
OCI_VERIFY_E( d->err, OCICollGetElemArray( d->env, d->err, d->sdoobj->ordinates, 0, &exists, ( void** ) numbers.data(), 0, &nords ) );
if ( !exists )
QVector<boolean> exists( nElems );
QVector<OCINumber*> numbers( nElems );
uword nelems = nElems;
OCI_VERIFY_E( d->err, OCICollGetElemArray( d->env, d->err, d->sdoobj->elem_info, 0, exists.data(), ( void** ) numbers.data(), 0, &nelems ) );
if ( !exists[0] )
{
qWarning() << "ordinate array does not exists";
qWarning() << "element info array does not exists";
throw OCI_ERROR;
}
OCI_VERIFY_E( d->err, OCINumberToRealArray( d->err, ( const OCINumber ** ) numbers.data(), nOrds, sizeof( double ), ordinates.data() ) );
#else
for ( int i = 0; i < nOrds; i++ )
{
OCINumber *num;

OCI_VERIFY_E( d->err, OCICollGetElem( d->env, d->err, d->sdoobj->ordinates, i, &exists, ( dvoid ** ) &num, 0 ) );

if ( !exists )
for ( unsigned int i = 0; i < nelems; i++ )
{
if ( !getValue( numbers[i], elems[i] ) )
{
qWarning( "item %d does not exists.", i );
qWarning() << "get value of element info item" << i << "failed";
throw OCI_ERROR;
}
}
}
catch ( int )
{
return false;
}

if ( !getValue( num, ordinates[i] ) )
{
throw OCI_ERROR;
}

QVector<double> ordinates( nOrds );

try
{
QVector<boolean> exists( nOrds );
QVector<OCINumber*> numbers( nOrds );
uword nords = nOrds;
OCI_VERIFY_E( d->err, OCICollGetElemArray( d->env, d->err, d->sdoobj->ordinates, 0, exists.data(), ( void** ) numbers.data(), 0, &nords ) );
if ( !exists[0] )
{
qWarning() << "ordinate array does not exists";
throw OCI_ERROR;
}
#endif
OCI_VERIFY_E( d->err, OCINumberToRealArray( d->err, ( const OCINumber ** ) numbers.data(), nords, sizeof( double ), ordinates.data() ) );
}
catch ( int )
{
Expand All @@ -2518,7 +2504,7 @@ bool QOCISpatialCols::convertToWkb( QVariant &v )
for ( int i = 0; i < nElems; i += 3 )
{
int startOffset, endOffset, etype, n;
if ( !getElemInfoElem( i, nElems, nOrds, startOffset, endOffset, etype, n ) )
if ( !getElemInfoElem( i, elems, nOrds, startOffset, endOffset, etype, n ) )
{
qDebug() << "could not fetch element info" << i;
return false;
Expand Down Expand Up @@ -2552,7 +2538,7 @@ bool QOCISpatialCols::convertToWkb( QVariant &v )
for ( int i = 0; i < nElems; i += 3 )
{
int startOffset, endOffset, etype, n;
if ( !getElemInfoElem( i, nElems, nOrds, startOffset, endOffset, etype, n ) )
if ( !getElemInfoElem( i, elems, nOrds, startOffset, endOffset, etype, n ) )
{
qDebug() << "could not fetch element info" << i;
return false;
Expand Down Expand Up @@ -2595,9 +2581,9 @@ bool QOCISpatialCols::convertToWkb( QVariant &v )
for ( int i = 0; i < nElems; i += 3 )
{
int startOffset, endOffset, etype, n;
if ( !getElemInfoElem( i, nElems, nOrds, startOffset, endOffset, etype, n ) )
if ( !getElemInfoElem( i, elems, nOrds, startOffset, endOffset, etype, n ) )
{
qDebug() << "could not fetch element info" << i;
qWarning() << "could not fetch element info" << i;
return false;
}

Expand All @@ -2608,7 +2594,7 @@ bool QOCISpatialCols::convertToWkb( QVariant &v )
}
else
{
qDebug() << "unsupported line element - etype:" << etype << "n:" << n << "skipped";
qWarning( "skipped unsupported line element: etype=%08x n=%d", etype, n );
}
}

Expand All @@ -2634,9 +2620,9 @@ bool QOCISpatialCols::convertToWkb( QVariant &v )
for ( int i = 0; i < nElems; i += 3 )
{
int startOffset, endOffset, etype, n;
if ( !getElemInfoElem( i, nElems, nOrds, startOffset, endOffset, etype, n ) )
if ( !getElemInfoElem( i, elems, nOrds, startOffset, endOffset, etype, n ) )
{
qDebug() << "could not fetch element info" << i;
qWarning() << "could not fetch element info" << i;
return false;
}

Expand Down Expand Up @@ -2667,9 +2653,9 @@ bool QOCISpatialCols::convertToWkb( QVariant &v )
for ( int i = 0; i < nElems; i += 3 )
{
int startOffset, endOffset, etype, n;
if ( !getElemInfoElem( i, nElems, nOrds, startOffset, endOffset, etype, n ) )
if ( !getElemInfoElem( i, elems, nOrds, startOffset, endOffset, etype, n ) )
{
qDebug() << "could not fetch element info" << i;
qWarning() << "could not fetch element info" << i;
return false;
}

Expand All @@ -2695,7 +2681,7 @@ bool QOCISpatialCols::convertToWkb( QVariant &v )
}
else
{
qDebug() << "unsupported polygon element - etype:" << etype << "n:" << n << "skipped";
qWarning( "skipped unsupported polygon element: etype=%08x n=%d", etype, n );
}
}

Expand Down Expand Up @@ -2727,9 +2713,9 @@ bool QOCISpatialCols::convertToWkb( QVariant &v )
for ( int i = 0; i < nElems; i += 3 )
{
int startOffset, endOffset, etype, n;
if ( !getElemInfoElem( i, nElems, nOrds, startOffset, endOffset, etype, n ) )
if ( !getElemInfoElem( i, elems, nOrds, startOffset, endOffset, etype, n ) )
{
qDebug() << "could not fetch element info" << i;
qWarning() << "could not fetch element info" << i;
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/providers/postgres/qgspostgresdataitems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ QVector<QgsDataItem*> QgsPGConnectionItem::createChildren()
{
if ( !dontResolveType )
{
QgsDebugMsg( QString( "Skip column %1.%2 without type constraint" ).arg( layerProperty.schemaName ).arg( layerProperty.tableName ).arg( layerProperty.geometryColName ) );
QgsDebugMsg( QString( "Skip column %1.%2.%3 without type constraint" ).arg( layerProperty.schemaName ).arg( layerProperty.tableName ).arg( layerProperty.geometryColName ) );
continue;
}

Expand Down
8 changes: 5 additions & 3 deletions src/providers/wfs/qgswfsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include "qgsspatialindex.h"
#include "qgslogger.h"
#include "qgsnetworkaccessmanager.h"
#include "qgsogcutils.h"

#include <QDomDocument>
#include <QMessageBox>
#include <QDomNodeList>
Expand Down Expand Up @@ -418,7 +420,7 @@ bool QgsWFSProvider::addFeatures( QgsFeatureList &flist )

//add geometry column (as gml)
QDomElement geomElem = transactionDoc.createElementNS( mWfsNamespace, mGeometryAttribute );
QDomElement gmlElem = featureIt->geometry()->exportToGML2( transactionDoc );
QDomElement gmlElem = QgsOgcUtils::geometryToGML2( featureIt->geometry(), transactionDoc );
if ( !gmlElem.isNull() )
{
geomElem.appendChild( gmlElem );
Expand Down Expand Up @@ -569,7 +571,7 @@ bool QgsWFSProvider::changeGeometryValues( QgsGeometryMap & geometry_map )
nameElem.appendChild( nameText );
propertyElem.appendChild( nameElem );
QDomElement valueElem = transactionDoc.createElementNS( "http://www.opengis.net/wfs", "Value" );
QDomElement gmlElem = ( &geomIt.value() )->exportToGML2( transactionDoc );
QDomElement gmlElem = QgsOgcUtils::geometryToGML2( &geomIt.value(), transactionDoc );
valueElem.appendChild( gmlElem );
propertyElem.appendChild( valueElem );
updateElem.appendChild( propertyElem );
Expand Down Expand Up @@ -1287,7 +1289,7 @@ int QgsWFSProvider::getFeaturesFromGML2( const QDomElement& wfsCollectionElement
}
else //a geometry attribute
{
f->setGeometry( QgsGeometry::fromGML2( currentAttributeElement ) );
f->setGeometry( QgsOgcUtils::geometryFromGML2( currentAttributeElement ) );
}
}
currentAttributeChild = currentAttributeChild.nextSibling();
Expand Down
53 changes: 33 additions & 20 deletions src/providers/wms/qgswmsprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1451,26 +1451,37 @@ void QgsWmsProvider::capabilitiesReplyFinished()
{
emit statusChanged( tr( "Capabilities request redirected." ) );

QNetworkRequest request( redirect.toUrl() );
setAuthorization( request );
request.setAttribute( QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork );
request.setAttribute( QNetworkRequest::CacheSaveControlAttribute, true );

mCapabilitiesReply->deleteLater();
QgsDebugMsg( QString( "redirected getcapabilities: %1" ).arg( redirect.toString() ) );
mCapabilitiesReply = QgsNetworkAccessManager::instance()->get( request );

connect( mCapabilitiesReply, SIGNAL( finished() ), this, SLOT( capabilitiesReplyFinished() ) );
connect( mCapabilitiesReply, SIGNAL( downloadProgress( qint64, qint64 ) ), this, SLOT( capabilitiesReplyProgress( qint64, qint64 ) ) );
return;
const QUrl& toUrl = redirect.toUrl();
mCapabilitiesReply->request();
if ( toUrl == mCapabilitiesReply->url() ) {
mErrorFormat = "text/plain";
mError = tr( "Redirect loop detected: %1" ).arg( toUrl.toString() );
QgsMessageLog::logMessage( mError, tr( "WMS" ) );
mHttpCapabilitiesResponse.clear();
} else {
QNetworkRequest request( toUrl );
setAuthorization( request );
request.setAttribute( QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork );
request.setAttribute( QNetworkRequest::CacheSaveControlAttribute, true );

mCapabilitiesReply->deleteLater();
QgsDebugMsg( QString( "redirected getcapabilities: %1" ).arg( redirect.toString() ) );
mCapabilitiesReply = QgsNetworkAccessManager::instance()->get( request );

connect( mCapabilitiesReply, SIGNAL( finished() ), this, SLOT( capabilitiesReplyFinished() ) );
connect( mCapabilitiesReply, SIGNAL( downloadProgress( qint64, qint64 ) ), this, SLOT( capabilitiesReplyProgress( qint64, qint64 ) ) );
return;
}
}

mHttpCapabilitiesResponse = mCapabilitiesReply->readAll();

if ( mHttpCapabilitiesResponse.isEmpty() )
else
{
mErrorFormat = "text/plain";
mError = tr( "empty of capabilities: %1" ).arg( mCapabilitiesReply->errorString() );
mHttpCapabilitiesResponse = mCapabilitiesReply->readAll();

if ( mHttpCapabilitiesResponse.isEmpty() )
{
mErrorFormat = "text/plain";
mError = tr( "empty of capabilities: %1" ).arg( mCapabilitiesReply->errorString() );
}
}
}
else
Expand All @@ -1481,7 +1492,6 @@ void QgsWmsProvider::capabilitiesReplyFinished()
mHttpCapabilitiesResponse.clear();
}


mCapabilitiesReply->deleteLater();
mCapabilitiesReply = 0;
}
Expand Down Expand Up @@ -4197,12 +4207,15 @@ QMap<int, QVariant> QgsWmsProvider::identify( const QgsPoint & thePoint, Identif
#else
Q_UNUSED( ret );
#endif

// TODO: all features coming from this layer should probably have the same CRS
// the same as this layer, because layerExtentToOutputExtent() may be used
// for results -> verify CRS and reprojects if necessary
QMap<QgsFeatureId, QgsFeature* > features = gml.featuresMap();
QgsDebugMsg( QString( "%1 features read" ).arg( features.size() ) );
QgsFeatureStore featureStore( fields, crs() );
featureStore.params().insert( "sublayer", *layers );
featureStore.params().insert( "featureType", featureTypeName );
featureStore.params().insert( "getFeatureInfoUrl", requestUrl.toString() );
foreach ( QgsFeatureId id, features.keys() )
{
QgsFeature * feature = features.value( id );
Expand Down
16 changes: 13 additions & 3 deletions src/ui/qgsattributetypeedit.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>615</width>
<height>421</height>
<width>620</width>
<height>418</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -23,7 +23,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>12</number>
<number>0</number>
</property>
<widget class="QWidget" name="lineEditPage">
<layout class="QVBoxLayout" name="verticalLayout_1">
Expand Down Expand Up @@ -753,6 +753,16 @@
</item>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="isFieldEditableCheckBox">
<property name="text">
<string>Editable</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
Expand Down
1 change: 1 addition & 0 deletions tests/src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,4 @@ ADD_QGIS_TEST(stylev2test testqgsstylev2.cpp)
ADD_QGIS_TEST(composerhtmltest testqgscomposerhtml.cpp )
ADD_QGIS_TEST(rectangletest testqgsrectangle.cpp)
ADD_QGIS_TEST(composerscalebartest testqgscomposerscalebar.cpp )
ADD_QGIS_TEST(ogcutilstest testqgsogcutils.cpp)
14 changes: 0 additions & 14 deletions tests/src/core/testqgsgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ class TestQgsGeometry: public QObject
void differenceCheck2();
void bufferCheck();

void gmlTest();

private:
/** A helper method to do a render check to see if the geometry op is as expected */
bool renderCheck( QString theTestName, QString theComment = "" );
Expand Down Expand Up @@ -372,18 +370,6 @@ void TestQgsGeometry::dumpPolyline( QgsPolyline &thePolyline )
mpPainter->drawPolyline( myPoints );
}

void TestQgsGeometry::gmlTest()
{
QgsGeometry* geom = QgsGeometry::fromGML2( "<Point><coordinates>123,456</coordinates></Point>" );
QVERIFY( geom );
QVERIFY( geom->wkbType() == QGis::WKBPoint );
QVERIFY( geom->asPoint() == QgsPoint( 123, 456 ) );

QgsGeometry* geomBox = QgsGeometry::fromGML2( "<gml:Box srsName=\"foo\"><gml:coordinates>135.2239,34.4879 135.8578,34.8471</gml:coordinates></gml:Box>" );
QVERIFY( geomBox );
QVERIFY( geomBox->wkbType() == QGis::WKBPolygon );
}


QTEST_MAIN( TestQgsGeometry )
#include "moc_testqgsgeometry.cxx"
Expand Down
67 changes: 67 additions & 0 deletions tests/src/core/testqgsogcutils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

/***************************************************************************
testqgsogcutils.cpp
--------------------------------------
Date : March 2013
Copyright : (C) 2013 Martin Dobias
Email : wonder.sk at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include <QtTest>

//qgis includes...
#include <qgsgeometry.h>
#include <qgsogcutils.h>


/** \ingroup UnitTests
* This is a unit test for OGC utilities
*/
class TestQgsOgcUtils : public QObject
{
Q_OBJECT
private slots:

void testGeometryFromGML();
void testGeometryToGML();
};


void TestQgsOgcUtils::testGeometryFromGML()
{
QgsGeometry* geom = QgsOgcUtils::geometryFromGML2( "<Point><coordinates>123,456</coordinates></Point>" );
QVERIFY( geom );
QVERIFY( geom->wkbType() == QGis::WKBPoint );
QVERIFY( geom->asPoint() == QgsPoint( 123, 456 ) );

QgsGeometry* geomBox = QgsOgcUtils::geometryFromGML2( "<gml:Box srsName=\"foo\"><gml:coordinates>135.2239,34.4879 135.8578,34.8471</gml:coordinates></gml:Box>" );
QVERIFY( geomBox );
QVERIFY( geomBox->wkbType() == QGis::WKBPolygon );
}

void TestQgsOgcUtils::testGeometryToGML()
{
QDomDocument doc;

QDomElement elemInvalid = QgsOgcUtils::geometryToGML2( 0, doc );
QVERIFY( elemInvalid.isNull() );

QgsGeometry* geomPoint = QgsGeometry::fromPoint( QgsPoint( 111, 222 ) );
QDomElement elemPoint = QgsOgcUtils::geometryToGML2( geomPoint, doc );
delete geomPoint;
QVERIFY( !elemPoint.isNull() );

doc.appendChild( elemPoint );
QCOMPARE( doc.toString( -1 ), QString( "<gml:Point><gml:coordinates cs=\",\" ts=\" \">111.0,222.0</gml:coordinates></gml:Point>" ) );
}


QTEST_MAIN( TestQgsOgcUtils )
#include "moc_testqgsogcutils.cxx"