Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
##Basic statistics=group
##Layer=vector
##Field=Field Layer
library(nortest)
>lillie.test(Layer[[Field]])
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
(dp0
S'Field'
p1
VA numeric field.
p2
sS'ALG_DESC'
p3
VThis script performs the Lilliefors (Kolmogrov-Smirnov) test for the composite hypothesis of normality.\u000a\u000aR dependencies: library "nortest"\u000a\u000a
p4
sS'R_CONSOLE_OUTPUT'
p5
VThe results of the Lilliefors (Kolmogrov-Smirnov) test.
p6
sS'Layer'
p7
VA vector containing at least one numeric field.
p8
sNV
p9
s.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
##Home Range Analysis=group
##Layer=vector
##Percentage=number 10
##Field=Field Layer
##Home_ranges=Output vector
library(adehabitatHR)
Home_ranges<-mcp(Layer[,Field],percent=Percentage)
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
(dp0
S'Layer'
p1
VAn vector layer containing the relocations of one or more animals.
p2
sS'Home_ranges'
p3
VThe home ranges of the animals calculated according to the selected "Percentage" parameter.
p4
sS'ALG_CREATOR'
p5
VThis algorithm was written by Filipe S. Dias using the functions written by Clement Calenge, creator of the package "adehabitatHR".
p6
sS'ALG_DESC'
p7
VThis tool computes the home range of one or more animals with the Minimum Convex Polygon estimator.\u000a\u000aR depencies: library "adehabitatHR"
p8
sS'Field'
p9
VA field containing a unique identifier for each animal (type "string").\u000a\u000a\u000a
p10
sS'ALG_HELP_CREATOR'
p11
VFilipe S. Dias
p12
sS'Output'
p13
VThe ouput is a shapefile containing the home range of each animal.
p14
sS'Percentage'
p15
V100 minus the proportion of outliers to be excluded from the computation. E.g. Percentage = 95 means that 5% of the outlier locations will be excluded from the calculations.\u000a\u000a\u000a
p16
sNV
p17
s.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
##Point pattern analysis=group
##Layer=vector
##Simulations=number 100
##Optional_plot_name=string
##showplots
library(spatstat)
library(maptools)
sp <- as(Layer, "SpatialPoints")
sp <- as(sp, "ppp")
e <- envelope(sp, Kest, nsim = Simulations)
>e
plot(e, main = Optional_plot_name)
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
(dp0
S'ALG_DESC'
p1
VThis is a Monte Carlo test for the point patterns. It is based on simulations from the null hypothesis. It generates randomly dinstributed points within the study region and uses K-function for each set of generated points and compares them to the K-function for the original set of points. Detailed description can be found in correspondin section of this book: http://www.csiro.au/resources/pf16h.\u000a\u000aThis script will provide both graphical ('R plots') and verbose ('R console output') output.\u000a\u000aR dependencies: library "maptools" and "spatstat"
p2
sS'R_CONSOLE_OUTPUT'
p3
VDescription of the test results.
p4
sS'Layer'
p5
VPoint layer to be tested.
p6
sS'ALG_CREATOR'
p7
VYury Ryabov\u000ariabovv at gmail dot com\u000a2013\u000aGPLv3
p8
sS'RPLOTS'
p9
VGraph showing test results.
p10
sS'ALG_HELP_CREATOR'
p11
VYury Ryabov\u000ariabovv at gmail dot com\u000a2013\u000aCC-0
p12
sS'Simulations'
p13
VNumber of simulations for random points distributions. Positive integer must be provided here.
p14
sS'Optional_plot_name'
p15
VAn Optional name for the graph. It is Ok to leave this field blank.
p16
s.
8 changes: 4 additions & 4 deletions python/plugins/processing/r/scripts/Quadrat_analysis.rsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
##[Example scripts]=group
##points=vector
##Point pattern analysis=group
##Layer=vector
##showplots
library("maptools")
library("spatstat")
ppp=as(as(points, "SpatialPoints"),"ppp")
ppp=as(as(Layer, "SpatialPoints"),"ppp")
qc=quadratcount(ppp)
plot(points)
plot(Layer)
plot(qc, add=TRUE)
>quadrat.test(ppp);
26 changes: 26 additions & 0 deletions python/plugins/processing/r/scripts/Quadrat_analysis.rsx.help
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(dp0
S'ALG_DESC'
p1
VThe script divides the window into quadrats and counts the numbers of points in each quadrat. Then it performs a test of Complete Spatial Randomness based on the quadrat counts.\u000a\u000aR dependencies: library "maptools" and "spatstat"
p2
sS'R_CONSOLE_OUTPUT'
p3
VThe results of the Chi-squared test of complete spatial randomness (CSR) using quadrat counts.\u000a
p4
sS'ALG_CREATOR'
p5
VVictor Olaya, volayaf(at)gmail.com
p6
sS'Layer'
p7
VA vector containg a point pattern.
p8
sS'RPLOTS'
p9
VA display containing the number of points per quadrat.
p10
sS'ALG_HELP_CREATOR'
p11
VFilipe S. Dias, filipesdias(at)gmail.com
p12
s.
6 changes: 6 additions & 0 deletions python/plugins/processing/r/scripts/Random_sampling_grid.rsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
##Point pattern analysis=group
##Layer=vector
##Size=number 10
##Output= output vector
pts=spsample(Layer,Size,type="random")
Output=SpatialPointsDataFrame(pts, as.data.frame(pts))
26 changes: 26 additions & 0 deletions python/plugins/processing/r/scripts/Random_sampling_grid.rsx.help
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(dp0
S'ALG_DESC'
p1
VThis scripts samples point location within a given polygon(s) using a random sampling method. The used methods assume that the geometry used is not spherical, so objects should be in planar coordinates.\u000a\u000a
p2
sS'ALG_CREATOR'
p3
VVictor Olaya
p4
sS'Layer'
p5
VA vector layer containing polygons.
p6
sS'ALG_HELP_CREATOR'
p7
VFilipe Dias
p8
sS'Output'
p9
VRandomly generated random points.
p10
sS'Size'
p11
VNumber of sample points to be randomly generated
p12
s.
6 changes: 3 additions & 3 deletions python/plugins/processing/r/scripts/Raster_histogram.rsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
##[Example scripts]=group
##layer = raster
##Raster processing=group
##Layer = raster
##showplots
hist(as.matrix(layer))
hist(as.matrix(Layer),main="Histogram",xlab="Layer")
22 changes: 22 additions & 0 deletions python/plugins/processing/r/scripts/Raster_histogram.rsx.help
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(dp0
S'ALG_CREATOR'
p1
VVictor Olaya, volayaf(at)gmail.com
p2
sS'ALG_DESC'
p3
VThe script creates a raster histogram.
p4
sS'Layer '
p5
VAn input raster.
p6
sS'RPLOTS'
p7
VHistogram
p8
sS'ALG_HELP_CREATOR'
p9
VFilipe S. Dias, filipesdias(at)gmail.co
p10
s.
6 changes: 6 additions & 0 deletions python/plugins/processing/r/scripts/Regular_sampling_grid.rsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
##Point pattern analysis=group
##Layer=vector
##Size=number 10
##Output= output vector
pts=spsample(Layer,Size,type="regular")
Output=SpatialPointsDataFrame(pts, as.data.frame(pts))
18 changes: 18 additions & 0 deletions python/plugins/processing/r/scripts/Regular_sampling_grid.rsx.help
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(dp0
S'Output'
p1
VSampled points
p2
sS'ALG_DESC'
p3
VThis scripts samples point location within a given polygon(s) using a regular (systematically aligned) sampling method. The methods used assume that the geometry used is not spherical, so objects should be in planar coordinates.
p4
sS'Layer'
p5
VA vector layer containing polygons.\u000a
p6
sS'Size'
p7
VNumber of sample points to be generated.\u000a
p8
s.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
(dp0
S'ALG_DESC'
p1
VThis algorithm creates a graph that demonstrates the dependency of the intensity of the point process on the value of covariate. In this algorithm the covariate is the distance to the certain objects. The functionality is based on 'rhohat' function of the 'spatstat' package. \u000a\u000aR dependencies: library "maptools", "spatstat" and "rpanel".
p2
sS'ALG_CREATOR'
p3
VYury Ryabov\u000a2013\u000ariabovvv@gmail.com
p4
sS'Layer'
p5
VThe point process which distribution will be investigated.
p6
sS'Covariate_name'
p7
VThis field is mandatory. Enter the name of the covariate. It will appear at the graph.
p8
sS'Legend_position'
p9
VThis field defines the position of the legend at the graph. 'float' means that the legend will be placed at the position that would not overlap the graph itself (or will try at least). Other options are: 'topleft', 'topright', 'bottomleft', 'bottomright'.
p10
sS'x_label'
p11
VOptional label for the X axis. Note that units at the X axis will be the same as in the input layers.
p12
sS'RPLOTS'
p13
VThe empirical graph of the dependency of the intensity of the point process on the distance to the given objects.
p14
sS'ALG_HELP_CREATOR'
p15
VYury Ryabov\u000a2013\u000ariabovvv@gmail.com
p16
sS'Plot_name'
p17
VOptional plot name.
p18
sS'Covariate'
p19
VThe set of objects the distance from which will be calculated and used as a spatial covariate to the point process.
p20
s.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
(dp0
S'ALG_DESC'
p1
VThis algorithm creates a graph that demonstrates the dependency of the intensity of the point process on the value of covariate. In this algorithm the covariate is the distance to the certain objects. The functionality is based on 'rhohat' function of the 'spatstat' package. \u000a\u000aR dependencies: library "maptools", "spatstat" and "rpanel".
p2
sS'ALG_CREATOR'
p3
VYury Ryabov\u000a2013\u000ariabovvv@gmail.com
p4
sS'Layer'
p5
VThe point process which distribution will be investigated.
p6
sS'Covariate_name'
p7
VThis field is mandatory. Enter the name of the covariate. It will appear at the graph.
p8
sS'Legend_position'
p9
VThis field defines the position of the legend at the graph. 'float' means that the legend will be placed at the position that would not overlap the graph itself (or will try at least). Other options are: 'topleft', 'topright', 'bottomleft', 'bottomright'.
p10
sS'x_label'
p11
VOptional label for the X axis. Note that units at the X axis will be the same as in the input layers.
p12
sS'RPLOTS'
p13
VThe empirical graph of the dependency of the intensity of the point process on the distance to the given objects.
p14
sS'ALG_HELP_CREATOR'
p15
VYury Ryabov\u000a2013\u000ariabovvv@gmail.com
p16
sS'Plot_name'
p17
VOptional plot name.
p18
sS'Covariate'
p19
VThe set of objects the distance from which will be calculated and used as a spatial covariate to the point process.
p20
s.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
##Point pattern analysis=group
##points=vector
##covariate=raster
##covariate_name=string mandatory_covariate_name_(no_spaces)
##x_label=string
##plot_name=string
##legend_position=string float
##showplots
library(geostatsp)
library(maptools)
library(rpanel)
if (covariate_name == "") {
rp.messagebox('"covariate name" must not be empty!', title = 'oops!')
}
else {
S <- points
SP <- as(S, "SpatialPoints")
P <- as(SP, "ppp")
covariate <- raster(covariate, layer = 1)
covariate <- as.im(covariate)
library(spatstat)
S <- points
SP <- as(S, "SpatialPoints")
P <- as(SP, "ppp")
plot(rhohat(P, covariate, covname=covariate_name), xlab= x_label,
legendpos = legend_position,
legendargs=list(bg="transparent"),
main = plot_name)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
(dp0
S'ALG_DESC'
p1
VThis algorithm creates a graph that demonstrates the dependency of the intensity of the point process on the value of the given covariate. In this algorithm the covariate must be represented as a raster. The functionality is based on 'rhohat' function of the 'spatstat' package. \u000a\u000aR dependencies: library "geostatsp", "maptools", "rpanel", "spatstat"
p2
sS'legend_position'
p3
VThis field defines the position of the legend at the graph. 'float' means that the legend will be placed at the position that would not overlap the graph itself (or will try at least). Other options are: 'topleft', 'topright', 'bottomleft', 'bottomright'.
p4
sS'ALG_CREATOR'
p5
VYury Ryabov\u000a2013\u000ariabovvv@gmail.com
p6
sS'covariate_name'
p7
VThis field is mandatory. Enter the name of the covariate. It will appear at the graph.
p8
sS'x_label'
p9
VOptional label for the X axis. Note that units at the X axis will be the same as in the input layers.
p10
sS'points'
p11
VThe point process which distribution will be investigated.
p12
sS'RPLOTS'
p13
VThe empirical graph of the dependency of the intensity of the point process on the distance to the given objects.
p14
sS'ALG_HELP_CREATOR'
p15
VYury Ryabov\u000a2013\u000ariabovvv@gmail.com
p16
sS'plot_name'
p17
VOptional plot name.
p18
sS'covariate'
p19
VThe spatial covariate to the point process. The raster must not have discrete values, i.e. it may not be classified. Only rasters that represent continious phenomena (e.g. DEM, distance maps, etc.) are allowed. Though classified rasters will be processed if supplied, but the results will be meaningless.
p20
s.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
##Point pattern analysis=group
##Layer=vector
##Output=output vector
library("spatstat")
library("maptools")
proj4string(Layer)->crs
spatpoints = as(Layer,"SpatialPoints")
ripras=ripras(as(spatpoints,"ppp"))
polyg=as(ripras,"SpatialPolygons")
Output1= SpatialPolygonsDataFrame(polyg, data.frame(1))
proj4string(Output1)<-crs
Output<-Output1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(dp0
S'ALG_CREATOR'
p1
VVictor Olaya, volayaf(at)gmail.com
p2
sS'Output'
p3
VRiplay-Rasson estimate of the spatial domain.
p4
sS'ALG_DESC'
p5
VThis script computes the Ripley-Rasson estimate of the spatial domain from which an observed pattern of points came.\u000a\u000aR dependencies: library "maptools" and "spatstat"
p6
sS'Layer'
p7
VA vector layer contain a point pattern.
p8
sS'ALG_HELP_CREATOR'
p9
VFilipe S. Dias, filipesdias(at)gmail.com
p10
s.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
##Home Range Analysis=group
##showplots
##Layer=vector
##Field=Field Layer
##Percentage=number 10
##Home_ranges=Output vector
library(adehabitatHR)
uu<-clusthr(Layer[,Field])
Home_ranges<-getverticeshr(uu,percent=Percentage)
ii <- MCHu2hrsize(uu, percent=seq(50, 100, by=5))
par(mar=c(2,2,2,2))
plot(ii)
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
(dp0
S'ALG_DESC'
p1
VThis script estimates the home range of one or more animals by single-linkage cluster analysis.\u000a\u000aR depencies: library "adehabitatHR"
p2
sS'Home_ranges'
p3
VA multipart vector layer containing the home ranges of each animal, according to the selected "Percentage" value.
p4
sS'ALG_CREATOR'
p5
VFilipe S. Dias, filipesdias(at)gmail.com
p6
sS'Layer'
p7
VA vector layer containing the relocations of one or more animals.
p8
sS'Field'
p9
VThe field that contains the unique identifier (type "string") for each animal.
p10
sS'RPLOTS'
p11
VA plot showing the relationship between the home range size and the percentage of relocations included in the home range.\u000a
p12
sS'ALG_HELP_CREATOR'
p13
VFilipe S. Dias, filipesdias(at)gmail.com
p14
sS'Percentage'
p15
VPercentage of the relocations used in the calculations.
p16
s.
14 changes: 14 additions & 0 deletions python/plugins/processing/r/scripts/Summary_statistics.rsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
##Basic statistics=group
##Layer=vector
##Field=Field Layer
Summary_statistics<-data.frame(rbind(sum(Layer[[Field]]),
length(Layer[[Field]]),
length(unique(Layer[[Field]])),
min(Layer[[Field]]),
max(Layer[[Field]]),
max(Layer[[Field]])-min(Layer[[Field]]),
mean(Layer[[Field]]),
median(Layer[[Field]]),
sd(Layer[[Field]])),row.names=c("Sum:","Count:","Unique values:","Minimum value:","Maximum value:","Range:","Mean value:","Median value:","Standard deviation:"))
colnames(Summary_statistics)<-c(Field)
>Summary_statistics
26 changes: 26 additions & 0 deletions python/plugins/processing/r/scripts/Summary_statistics.rsx.help
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
(dp0
S'ALG_DESC'
p1
VThis tool calculates the following summary statistics for a numeric field: (1) Sum, (2) Count, (3) Unique values, (4) Minimum value, (5) Maximum value, (6) Range, (7) Mean, (8) Median and (9) Standard deviation.\u000a\u000a
p2
sS'R_CONSOLE_OUTPUT'
p3
VSummary statistics table
p4
sS'ALG_CREATOR'
p5
VFilipe S. Dias, filipesdias(at)gmail.com
p6
sS'Layer'
p7
VInput vector with at least one numeric field
p8
sS'Field'
p9
VNumeric field
p10
sS'ALG_HELP_CREATOR'
p11
VFilipe S. Dias, filipesdias(at)gmail.com
p12
s.
8 changes: 7 additions & 1 deletion python/plugins/processing/script/ScriptAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from processing.parameters.ParameterVector import ParameterVector
from processing.parameters.ParameterMultipleInput import ParameterMultipleInput
from processing.parameters.ParameterString import ParameterString
from processing.parameters.ParameterCrs import ParameterCrs
from processing.parameters.ParameterNumber import ParameterNumber
from processing.parameters.ParameterBoolean import ParameterBoolean
from processing.parameters.ParameterSelection import ParameterSelection
Expand Down Expand Up @@ -127,7 +128,7 @@ def processParameterLine(self, line):
if '|' in line:
self.processDescriptionParameterLine(line)
return
tokens = line.split('=')
tokens = line.split('=', 1)
desc = self.createDescriptiveName(tokens[0])
if tokens[1].lower().strip() == 'group':
self.group = tokens[0]
Expand Down Expand Up @@ -186,6 +187,11 @@ def processParameterLine(self, line):
elif tokens[1].lower().strip().startswith('string'):
default = tokens[1].strip()[len('string') + 1:]
param = ParameterString(tokens[0], desc, default)
elif tokens[1].lower().strip().startswith('crs'):
default = tokens[1].strip()[len('crs') + 1:]
if not default:
default = 'EPSG:4326'
param = ParameterCrs(tokens[0], desc, default)
elif tokens[1].lower().strip().startswith('output raster'):
out = OutputRaster()
elif tokens[1].lower().strip().startswith('output vector'):
Expand Down
2 changes: 1 addition & 1 deletion scripts/tsstat.pl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
fi => 'Kari Salovaara, Marko Järvenpää',
fr => 'Eve Rousseau, Marc Monnerat, Lionel Roubeyrie, Jean Roc Morreale, Benjamin Bohard, Jeremy Garniaux, Yves Jacolin, Benjamin Lerre, Stéphane Morel, Marie Silvestre, Tahir Tamba, Xavier M, Mayeul Kauffmann, Mehdi Semchaoui, Robin Cura, Etienne Tourigny, Mathieu Bossaert',
gl => 'Xan Vieiro',
hi => '',
hi => 'Harish Kumar Solanki',
hu => 'Zoltan Siki',
hr_HR => 'Zoran Jankovic',
is => 'Thordur Ivarsson',
Expand Down
1 change: 1 addition & 0 deletions src/core/qgscoordinatereferencesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2019,6 +2019,7 @@ bool QgsCoordinateReferenceSystem::syncDatumTransform( const QString& dbPath )
sql = QString( "UPDATE tbl_datum_transform SET source_crs = %2, target_crs = %3, coord_op_method = %4, p1 = %5, p2 = %6, p3 = %7, p4 = %8, p5 = %9, p6 = %10, p7 = %11 WHERE coord_op = %1" )
.arg( coord_op ).arg( source_crs ).arg( target_crs ).arg( coord_op_method ).arg( p1 ).arg( p2 ).arg( p3 ).arg( p4 ).arg( p5 ).arg( p6 ).arg( p7 );
}
else
{
//not yet in database, do insert
QgsDebugMsg( "Trying datum transform insert" );
Expand Down
1 change: 1 addition & 0 deletions src/core/qgsexpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1619,6 +1619,7 @@ QgsExpression::QgsExpression( const QString& expr )
: mRowNumber( 0 )
, mScale( 0 )
, mCalc( 0 )
, mExp( expr )
{
mRootNode = ::parseExpression( expr, mParserErrorString );

Expand Down
9 changes: 6 additions & 3 deletions src/core/qgsexpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,12 @@ class CORE_EXPORT QgsExpression

int scale() {return mScale; }

//! Alias for {@link dump()}
const QString expression() const { return dump(); }
//! Return the expression string that was given when created.
const QString expression() const { return mExp; }

//! Return the parsed expression as a string - useful for debugging
//! Return the a debugging string of the expression.
//! This can be used for debugging. Use {@link expression()}
//! if you need the full expression string.
QString dump() const;

//! Return calculator used for distance and area calculations
Expand Down Expand Up @@ -608,6 +610,7 @@ class CORE_EXPORT QgsExpression

int mRowNumber;
double mScale;
QString mExp;

static QMap<QString, QVariant> gmSpecialColumns;
QgsDistanceArea *mCalc;
Expand Down
4 changes: 2 additions & 2 deletions src/core/qgsfeaturerequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ QgsFeatureRequest::QgsFeatureRequest( const QgsRectangle& rect )

QgsFeatureRequest::QgsFeatureRequest( const QgsExpression& expr )
: mFilter( FilterExpression )
, mFilterExpression( new QgsExpression( expr.dump() ) )
, mFilterExpression( new QgsExpression( expr.expression() ) )
, mFlags( 0 )
, mMapCoordTransform( NULL )
, mMapToPixel( NULL )
Expand All @@ -76,7 +76,7 @@ QgsFeatureRequest& QgsFeatureRequest::operator=( const QgsFeatureRequest & rh )
mFilterFids = rh.mFilterFids;
if ( rh.mFilterExpression )
{
mFilterExpression = new QgsExpression( rh.mFilterExpression->dump() );
mFilterExpression = new QgsExpression( rh.mFilterExpression->expression() );
}
else
{
Expand Down
9 changes: 9 additions & 0 deletions src/core/qgsproject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,15 @@ bool QgsProject::write()
{
clearError();

// Create backup file
if ( QFile::exists( fileName() ) )
{
QString backup = fileName() + "~";
if ( QFile::exists( backup ) )
QFile::remove( backup );
QFile::rename( fileName(), backup );
}

// if we have problems creating or otherwise writing to the project file,
// let's find out up front before we go through all the hand-waving
// necessary to create all the Dom objects
Expand Down
4 changes: 2 additions & 2 deletions src/core/symbology-ng/qgsellipsesymbollayerv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,15 @@ void QgsEllipseSymbolLayerV2::writeSldMarker( QDomDocument &doc, QDomElement &el
{

if ( rotationExpression )
angleFunc = rotationExpression->dump();
angleFunc = rotationExpression->expression();
else if ( !qgsDoubleNear( mAngle, 0.0 ) )
angleFunc = QString::number( mAngle );
}
else if ( rotationExpression )
{
// the symbol has an angle and the symbol layer have a rotation
// property set
angleFunc = QString( "%1 + %2" ).arg( angleFunc ).arg( rotationExpression->dump() );
angleFunc = QString( "%1 + %2" ).arg( angleFunc ).arg( rotationExpression->expression() );
}
else if ( !qgsDoubleNear( mAngle, 0.0 ) )
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology-ng/qgsrulebasedrendererv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ QgsRuleBasedRendererV2::Rule* QgsRuleBasedRendererV2::Rule::createFromSld( QDomE
}
else
{
filterExp = filter->dump();
filterExp = filter->expression();
}
delete filter;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/symbology-ng/qgssymbollayerv2utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2259,7 +2259,7 @@ bool QgsSymbolLayerV2Utils::functionFromSldElement( QDomElement &element, QStrin
}
else
{
function = expr->dump();
function = expr->expression();
}

delete expr;
Expand Down
2 changes: 2 additions & 0 deletions src/gui/qgisinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ class GUI_EXPORT QgisInterface : public QObject
virtual QAction *actionSelectRadius() = 0;
//! Get access to the native identify action. Call trigger() on it to set the default identify map tool.
virtual QAction *actionIdentify() = 0;
//! Get access to the native run action feature action. Call trigger() on it to set the default run feature action map tool.
virtual QAction *actionFeatureAction() = 0;
//! Get access to the native measure action. Call trigger() on it to set the default measure map tool.
virtual QAction *actionMeasure() = 0;
//! Get access to the native measure area action. Call trigger() on it to set the default measure area map tool.
Expand Down
80 changes: 80 additions & 0 deletions src/gui/qgsdatumtransformdialog.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
/***************************************************************************
qgsdatumtransformdialog.cpp
---------------------------
begin : November 2013
copyright : (C) 2013 by Marco Hugentobler
email : marco.hugentobler at sourcepole dot ch
***************************************************************************/

/***************************************************************************
* *
* 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 "qgsdatumtransformdialog.h"
#include "qgscoordinatetransform.h"
#include <QDir>

QgsDatumTransformDialog::QgsDatumTransformDialog( const QString& layerName, const QList< QList< int > >& dt, QWidget* parent, Qt::WindowFlags f ): QDialog( parent, f )
{
Expand All @@ -9,6 +27,8 @@ QgsDatumTransformDialog::QgsDatumTransformDialog( const QString& layerName, cons
for ( ; it != dt.constEnd(); ++it )
{
QTreeWidgetItem* item = new QTreeWidgetItem();
bool itemDisabled = false;

for ( int i = 0; i < 2; ++i )
{
if ( i >= it->size() )
Expand All @@ -22,7 +42,13 @@ QgsDatumTransformDialog::QgsDatumTransformDialog( const QString& layerName, cons
{
item->setText( i, QgsCoordinateTransform::datumTransformString( nr ) );
}

if ( gridShiftTransformation( item->text( i ) ) && !testGridShiftFileAvailability( item, i ) )
{
itemDisabled = true;
}
}
item->setDisabled( itemDisabled );
mDatumTransformTreeWidget->addTopLevelItem( item );
}
}
Expand Down Expand Up @@ -58,3 +84,57 @@ bool QgsDatumTransformDialog::rememberSelection() const
{
return mRememberSelectionCheckBox->isChecked();
}

bool QgsDatumTransformDialog::gridShiftTransformation( const QString& itemText ) const
{
return ( !itemText.isEmpty() && !itemText.contains( "towgs84", Qt::CaseInsensitive ) );
}

bool QgsDatumTransformDialog::testGridShiftFileAvailability( QTreeWidgetItem* item, int col ) const
{
if ( !item )
{
return true;
}

QString itemText = item->text( col );
if ( itemText.isEmpty() )
{
return true;
}

char* projLib = getenv( "PROJ_LIB" );
if ( !projLib ) //no information about installation directory
{
return true;
}

QStringList itemEqualSplit = itemText.split( "=" );
QString filename;
for ( int i = 1; i < itemEqualSplit.size(); ++i )
{
if ( i > 1 )
{
filename.append( "=" );
}
filename.append( itemEqualSplit.at( i ) );
}

QDir projDir( projLib );
if ( projDir.exists() )
{
//look if filename in directory
QStringList fileList = projDir.entryList();
QStringList::const_iterator fileIt = fileList.constBegin();
for ( ; fileIt != fileList.constEnd(); ++fileIt )
{
if ( *fileIt == filename )
{
return true;
}
}
item->setToolTip( col, tr( "File '%1' not found in directory '%2'" ).arg( filename ).arg( projDir.absolutePath() ) );
return false; //not found in PROJ_LIB directory
}
return true;
}
20 changes: 20 additions & 0 deletions src/gui/qgsdatumtransformdialog.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/***************************************************************************
qgsdatumtransformdialog.h
-------------------------
begin : November 2013
copyright : (C) 2013 by Marco Hugentobler
email : marco.hugentobler at sourcepole dot ch
***************************************************************************/

/***************************************************************************
* *
* 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. *
* *
***************************************************************************/

#ifndef QGSDATUMTRANSFORMDIALOG_H
#define QGSDATUMTRANSFORMDIALOG_H

Expand All @@ -15,6 +32,9 @@ class GUI_EXPORT QgsDatumTransformDialog: public QDialog, private Ui::QgsDatumTr

private:
QgsDatumTransformDialog();
bool gridShiftTransformation( const QString& itemText ) const;
/**Returns false if the location of the grid shift files is known (PROJ_LIB) and the shift file is not there*/
bool testGridShiftFileAvailability( QTreeWidgetItem* item, int col ) const;
};

#endif // QGSDATUMTRANSFORMDIALOG_H
4 changes: 2 additions & 2 deletions src/plugins/georeferencer/qgsgeorefplugingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ void QgsGeorefPluginGui::layerWillBeRemoved( QString theLayerId )
void QgsGeorefPluginGui::createActions()
{
// File actions
mActionOpenRaster->setIcon( getThemeIcon( "/mActionOpenRaster.png" ) );
mActionOpenRaster->setIcon( getThemeIcon( "/mActionAddRasterLayer.svg" ) );
connect( mActionOpenRaster, SIGNAL( triggered() ), this, SLOT( openRaster() ) );

mActionStartGeoref->setIcon( getThemeIcon( "/mActionStartGeoref.png" ) );
Expand Down Expand Up @@ -1076,7 +1076,7 @@ void QgsGeorefPluginGui::updateIconTheme( QString theme )
{
Q_UNUSED( theme );
// File actions
mActionOpenRaster->setIcon( getThemeIcon( "/mActionOpenRaster.png" ) );
mActionOpenRaster->setIcon( getThemeIcon( "/mActionAddRasterLayer.svg" ) );
mActionStartGeoref->setIcon( getThemeIcon( "/mActionStartGeoref.png" ) );
mActionGDALScript->setIcon( getThemeIcon( "/mActionGDALScript.png" ) );
mActionLoadGCPpoints->setIcon( getThemeIcon( "/mActionLoadGCPpoints.png" ) );
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/georeferencer/qgstransformsettingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ QgsTransformSettingsDialog::QgsTransformSettingsDialog( const QString &raster, c
cmbResampling->setCurrentIndex( s.value( "/Plugin-GeoReferencer/lastresampling", 0 ).toInt() );
cmbCompressionComboBox->setCurrentIndex( s.value( "/Plugin-GeoReferencer/lastcompression", 0 ).toInt() );
leTargetSRS->setText( s.value( "/Plugin-GeoReferencer/targetsrs" ).toString() );
mWorldFileCheckBox->setChecked( s.value( "/Plugin-Georeferencer/word_file_checkbox", false ).toBool() );

cbxUserResolution->setChecked( s.value( "/Plugin-Georeferencer/user_specified_resolution", false ).toBool() );
bool ok;
Expand Down Expand Up @@ -137,6 +138,7 @@ void QgsTransformSettingsDialog::resetSettings()
s.setValue( "/Plugin-GeoReferencer/user_specified_resolution", false );
s.setValue( "/Plugin-GeoReferencer/user_specified_resx", 1.0 );
s.setValue( "/Plugin-GeoReferencer/user_specified_resy", -1.0 );
s.setValue( "/Plugin-GeoReferencer/word_file_checkbox", false );
s.setValue( "/Plugin-GeoReferencer/lastPDFReportDir", "" );
}

Expand All @@ -158,7 +160,7 @@ void QgsTransformSettingsDialog::accept()
int minGCPpoints;
if ( checkGCPpoints( cmbTransformType->itemData( cmbTransformType->currentIndex() ).toInt(), minGCPpoints ) )
{
if ( leOutputRaster->text().isEmpty() )
if ( leOutputRaster->text().isEmpty() && !mWorldFileCheckBox->isChecked() )
{
QMessageBox::information( this, tr( "Info" ), tr( "Please set output name" ) );
return;
Expand Down Expand Up @@ -195,6 +197,7 @@ void QgsTransformSettingsDialog::accept()
s.setValue( "/Plugin-GeoReferencer/user_specified_resolution", cbxUserResolution->isChecked() );
s.setValue( "/Plugin-GeoReferencer/user_specified_resx", dsbHorizRes->value() );
s.setValue( "/Plugin-GeoReferencer/user_specified_resy", dsbVerticalRes->value() );
s.setValue( "/Plugin-GeoReferencer/word_file_checkbox", mWorldFileCheckBox->isChecked() );
QString pdfReportFileName = mReportFileLineEdit->text();
if ( !pdfReportFileName.isEmpty() )
{
Expand Down
43 changes: 32 additions & 11 deletions src/plugins/globe/globe_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <qgsdistancearea.h>

#include <QAction>
#include <QDir>
#include <QToolBar>
#include <QMessageBox>

Expand Down Expand Up @@ -96,11 +97,23 @@ GlobePlugin::GlobePlugin( QgisInterface* theQgisInterface )
setObjectName( "globePlugin" );
setParent( theQgisInterface->mainWindow() );

// add internal osg plugin path if bundled osg on OS X
#ifdef HAVE_MACAPP_BUNDLED_OSG
if ( !QgsApplication::isRunningFromBuildDir() )
// update path to osg plugins on Mac OS X
#ifdef Q_OS_MACX
if ( !getenv( "OSG_LIBRARY_PATH" ) )
{
osgDB::Registry::instance()->setLibraryFilePathList( QDir::cleanPath( QgsApplication::pluginPath() + "/../osgPlugins" ).toStdString() );
// OSG_PLUGINS_PATH value set by CMake option
QString ogsPlugins( OSG_PLUGINS_PATH );
#ifdef HAVE_MACAPP_BUNDLED_OSG
if ( !QgsApplication::isRunningFromBuildDir() )
{
// add internal osg plugin path if bundled osg
ogsPlugins = QgsApplication::pluginPath() + "/../osgPlugins";
}
#endif
if ( QFile::exists( ogsPlugins ) )
{
osgDB::Registry::instance()->setLibraryFilePathList( QDir::cleanPath( ogsPlugins ).toStdString() );
}
}
#endif

Expand Down Expand Up @@ -494,15 +507,20 @@ double GlobePlugin::getSelectedElevation()

void GlobePlugin::syncExtent()
{
QgsMapCanvas* mapCanvas = mQGisIface->mapCanvas();
QgsMapRenderer* mapRenderer = mapCanvas->mapRenderer();
QgsRectangle extent = mapCanvas->extent();

osgEarth::Util::EarthManipulator* manip = dynamic_cast<osgEarth::Util::EarthManipulator*>( mOsgViewer->getCameraManipulator() );
//rotate earth to north and perpendicular to camera
manip->setRotation( osg::Quat() );

//get mapCanvas->extent().height() in meters
QgsRectangle extent = mQGisIface->mapCanvas()->extent();
QgsDistanceArea dist;
dist.setEllipsoidalMode( true );
//dist.setProjectionsEnabled( true );

dist.setSourceCrs( mapRenderer->destinationCrs().srsid() );
dist.setEllipsoidalMode( mapRenderer->hasCrsTransformEnabled() );
dist.setEllipsoid( QgsProject::instance()->readEntry( "Measure", "/Ellipsoid", GEO_NONE ) );

QgsPoint ll = QgsPoint( extent.xMinimum(), extent.yMinimum() );
QgsPoint ul = QgsPoint( extent.xMinimum(), extent.yMaximum() );
double height = dist.measureLine( ll, ul );
Expand Down Expand Up @@ -645,26 +663,29 @@ void GlobePlugin::setupControls()
mControlCanvas->addControl( backgroundGrp2 );

//Zoom Reset
#if ENABLE_HOME_BUTTON
osg::Image* homeImg = osgDB::readImageFile( imgDir + "/zoom-home.png" );
ImageControl* home = new NavigationControl( homeImg );
home->setPosition( imgLeft + 12 + 3, imgTop + 2 );
imgTop = imgTop + 23 + 2;
home->addEventHandler( new HomeControlHandler( manip ) );
mControlCanvas->addControl( home );
#endif

//refresh layers
osg::Image* refreshImg = osgDB::readImageFile( imgDir + "/refresh-view.png" );
ImageControl* refresh = new NavigationControl( refreshImg );
refresh->setPosition( imgLeft + 12 + 3, imgTop + 2 + 23 + 2 );
refresh->setPosition( imgLeft + 12 + 3, imgTop + 3 );
imgTop = imgTop + 23 + 2;
refresh->addEventHandler( new RefreshControlHandler( this ) );
mControlCanvas->addControl( refresh );

//Sync Extent
#if ENABLE_SYNC_BUTTON
osg::Image* syncImg = osgDB::readImageFile( imgDir + "/sync-extent.png" );
ImageControl* sync = new NavigationControl( syncImg );
sync->setPosition( imgLeft + 12 + 3, imgTop + 2 );
sync->addEventHandler( new SyncExtentControlHandler( this ) );
mControlCanvas->addControl( sync );
#endif
}

void GlobePlugin::setupProxy()
Expand Down
Binary file modified src/plugins/globe/images/gui/sync-extent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/providers/ogr/qgsogrfeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void QgsOgrFeatureIterator::ensureRelevantFields()
{
mFetchGeometry = ( mRequest.filterType() == QgsFeatureRequest::FilterRect ) || !( mRequest.flags() & QgsFeatureRequest::NoGeometry );
QgsAttributeList attrs = ( mRequest.flags() & QgsFeatureRequest::SubsetOfAttributes ) ? mRequest.subsetOfAttributes() : P->attributeIndexes();
P->setRelevantFields( mFetchGeometry, attrs );
P->setRelevantFields( ogrLayer, mFetchGeometry, attrs );
P->mRelevantFieldsForNextFeature = true;
}

Expand Down
12 changes: 6 additions & 6 deletions src/providers/ogr/qgsogrprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ QStringList QgsOgrProvider::subLayers() const
// Count features for geometry types
QMap<OGRwkbGeometryType, int> fCount;
// TODO: avoid reading attributes, setRelevantFields cannot be called here because it is not constant
//setRelevantFields( true, QgsAttributeList() );
//setRelevantFields( ogrLayer, true, QgsAttributeList() );
OGR_L_ResetReading( layer );
OGRFeatureH fet;
while (( fet = OGR_L_GetNextFeature( layer ) ) )
Expand Down Expand Up @@ -714,7 +714,7 @@ QString QgsOgrProvider::storageType() const
return ogrDriverName;
}

void QgsOgrProvider::setRelevantFields( bool fetchGeometry, const QgsAttributeList &fetchAttributes )
void QgsOgrProvider::setRelevantFields( OGRLayerH ogrLayer, bool fetchGeometry, const QgsAttributeList &fetchAttributes )
{
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800
if ( OGR_L_TestCapability( ogrLayer, OLCIgnoreFields ) )
Expand Down Expand Up @@ -975,7 +975,7 @@ bool QgsOgrProvider::addFeature( QgsFeature& f )

bool QgsOgrProvider::addFeatures( QgsFeatureList & flist )
{
setRelevantFields( true, attributeIndexes() );
setRelevantFields( ogrLayer, true, attributeIndexes() );

bool returnvalue = true;
for ( QgsFeatureList::iterator it = flist.begin(); it != flist.end(); ++it )
Expand Down Expand Up @@ -1077,7 +1077,7 @@ bool QgsOgrProvider::changeAttributeValues( const QgsChangedAttributesMap & attr

clearMinMaxCache();

setRelevantFields( true, attributeIndexes() );
setRelevantFields( ogrLayer, true, attributeIndexes() );

for ( QgsChangedAttributesMap::const_iterator it = attr_map.begin(); it != attr_map.end(); ++it )
{
Expand Down Expand Up @@ -1173,7 +1173,7 @@ bool QgsOgrProvider::changeGeometryValues( QgsGeometryMap & geometry_map )
OGRFeatureH theOGRFeature = 0;
OGRGeometryH theNewGeometry = 0;

setRelevantFields( true, attributeIndexes() );
setRelevantFields( ogrLayer, true, attributeIndexes() );

for ( QgsGeometryMap::iterator it = geometry_map.begin(); it != geometry_map.end(); ++it )
{
Expand Down Expand Up @@ -2388,7 +2388,7 @@ void QgsOgrProvider::recalculateFeatureCount()
{
featuresCounted = 0;
OGR_L_ResetReading( ogrLayer );
setRelevantFields( true, QgsAttributeList() );
setRelevantFields( ogrLayer, true, QgsAttributeList() );
OGR_L_ResetReading( ogrLayer );
OGRFeatureH fet;
while (( fet = OGR_L_GetNextFeature( ogrLayer ) ) )
Expand Down
2 changes: 1 addition & 1 deletion src/providers/ogr/qgsogrprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class QgsOgrProvider : public QgsVectorDataProvider
void recalculateFeatureCount();

/** tell OGR, which fields to fetch in nextFeature/featureAtId (ie. which not to ignore) */
void setRelevantFields( bool fetchGeometry, const QgsAttributeList& fetchAttributes );
void setRelevantFields( OGRLayerH ogrLayer, bool fetchGeometry, const QgsAttributeList& fetchAttributes );

/** convert a QgsField to work with OGR */
static bool convertField( QgsField &field, const QTextCodec &encoding );
Expand Down
8 changes: 6 additions & 2 deletions src/providers/spatialite/qgsspatialitefeatureiterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ QString QgsSpatiaLiteFeatureIterator::whereClauseRect()
// handling a VirtualShape layer
whereClause += QString( "MbrIntersects(%1, BuildMbr(%2))" ).arg( P->quotedIdentifier( P->mGeometryColumn ) ).arg( mbr( rect ) );
}
else
else if ( rect.isFinite() )
{
if ( P->spatialIndexRTree && rect.isFinite() )
if ( P->spatialIndexRTree )
{
// using the RTree spatial index
QString mbrFilter = QString( "xmin <= %1 AND " ).arg( qgsDoubleToString( rect.xMaximum() ) );
Expand Down Expand Up @@ -251,6 +251,10 @@ QString QgsSpatiaLiteFeatureIterator::whereClauseRect()
whereClause += QString( "MbrIntersects(%1, BuildMbr(%2))" ).arg( P->quotedIdentifier( P->mGeometryColumn ) ).arg( mbr( rect ) );
}
}
else
{
whereClause = "1";
}
return whereClause;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/src/core/testqgsexpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class TestQgsExpression: public QObject
if ( exp.hasParserError() )
qDebug() << "Parser error: " << exp.parserErrorString();
else
qDebug() << "Parsed string: " << exp.dump();
qDebug() << "Parsed string: " << exp.expression();

QCOMPARE( !exp.hasParserError(), valid );
}
Expand Down
6 changes: 3 additions & 3 deletions tests/src/core/testqgsogcutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,13 @@ void TestQgsOgcUtils::testExpressionFromOgcFilter()
QVERIFY( expr );

qDebug( "OGC XML : %s", xmlText.toAscii().data() );
qDebug( "EXPR-DUMP: %s", expr->dump().toAscii().data() );
qDebug( "EXPR-DUMP: %s", expr->expression().toAscii().data() );

if ( expr->hasParserError() )
qDebug( "ERROR: %s ", expr->parserErrorString().toAscii().data() );
QVERIFY( !expr->hasParserError() );

QCOMPARE( dumpText, expr->dump() );
QCOMPARE( dumpText, expr->expression() );

delete expr;
}
Expand All @@ -234,7 +234,7 @@ void TestQgsOgcUtils::testExpressionToOgcFilter()

doc.appendChild( filterElem );

qDebug( "EXPR: %s", exp.dump().toAscii().data() );
qDebug( "EXPR: %s", exp.expression().toAscii().data() );
qDebug( "OGC : %s", doc.toString( -1 ).toAscii().data() );

QCOMPARE( xmlText, doc.toString( -1 ) );
Expand Down