Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' of github.com:qgis/QGIS
  • Loading branch information
pcav committed Oct 1, 2013
2 parents dd914b8 + 96bd7e7 commit 7bc72d4
Show file tree
Hide file tree
Showing 30 changed files with 1,389 additions and 1,139 deletions.
2,204 changes: 1,095 additions & 1,109 deletions i18n/qgis_lt.ts

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions python/core/qgspallabeling.sip
Expand Up @@ -617,6 +617,9 @@ class QgsPalLabeling : QgsLabelingEngineInterface

bool isShowingAllLabels() const;
void setShowingAllLabels( bool showing );

bool isShowingPartialsLabels() const;
void setShowingPartialsLabels( bool showing );

// implemented methods from labeling engine interface

Expand Down
1 change: 1 addition & 0 deletions python/plugins/processing/admintools/ImportIntoPostGIS.py
Expand Up @@ -96,6 +96,7 @@ def defineCharacteristics(self):
self.group = "PostGIS management tools"
self.addParameter(ParameterVector(self.INPUT, "Layer to import"))
self.addParameter(ParameterString(self.DATABASE, "Database (connection name)"))
self.addParameter(ParameterString(self.SCHEMA, "Schema (schema name)"))
self.addParameter(ParameterString(self.TABLENAME, "Table to import to"))
self.addParameter(ParameterBoolean(self.OVERWRITE, "Overwrite", True))
self.addParameter(ParameterBoolean(self.CREATEINDEX, "Create spatial index", True))
Expand Down
3 changes: 2 additions & 1 deletion python/plugins/processing/gdal/GdalOgrAlgorithmProvider.py
Expand Up @@ -51,6 +51,7 @@
from processing.gdal.sieve import sieve
from processing.gdal.fillnodata import fillnodata
from processing.gdal.extractprojection import ExtractProjection
from processing.gdal.gdal2xyz import gdal2xyz

from processing.gdal.ogr2ogr import Ogr2Ogr
from processing.gdal.ogrinfo import OgrInfo
Expand Down Expand Up @@ -101,7 +102,7 @@ def createAlgsList(self):
rgb2pct(), pct2rgb(), merge(), polygonize(),
gdaladdo(), ClipByExtent(), ClipByMask(),
contour(), rasterize(), proximity(), sieve(),
fillnodata(), ExtractProjection(),
fillnodata(), ExtractProjection(), gdal2xyz(),
OgrInfo(), Ogr2Ogr(), OgrSql()]

#And then we add those that are created as python scripts
Expand Down
72 changes: 72 additions & 0 deletions python/plugins/processing/gdal/gdal2xyz.py
@@ -0,0 +1,72 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
gdal2xyz.py
---------------------
Date : September 2013
Copyright : (C) 2013 by Alexander Bruy
Email : alexander dot bruy 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. *
* *
***************************************************************************
"""

__author__ = 'Alexander Bruy'
__date__ = 'September 2013'
__copyright__ = '(C) 2013, Alexander Bruy'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import os
from PyQt4.QtGui import *
from PyQt4.QtCore import *

from processing.core.GeoAlgorithm import GeoAlgorithm

from processing.parameters.ParameterRaster import ParameterRaster
from processing.parameters.ParameterNumber import ParameterNumber
from processing.outputs.OutputTable import OutputTable

from processing.tools.system import *

from processing.gdal.GdalUtils import GdalUtils

class gdal2xyz(GeoAlgorithm):

INPUT = "INPUT"
BAND = "BAND"
OUTPUT = "OUTPUT"

#def getIcon(self):
# return QIcon(os.path.dirname(__file__) + "/icons/gdal2xyz.png")

def defineCharacteristics(self):
self.name = "gdal2xyz"
self.group = "[GDAL] Conversion"
self.addParameter(ParameterRaster(self.INPUT, "Input layer", False))
self.addParameter(ParameterNumber(self.BAND, "Band number", 1, 9999, 1))

self.addOutput(OutputTable(self.OUTPUT, "Output file"))

def processAlgorithm(self, progress):
arguments = []
arguments.append("-band")
arguments.append(str(self.getParameterValue(self.BAND)))

arguments.append("-csv")
arguments.append(self.getParameterValue(self.INPUT))
arguments.append(self.getOutputValue(self.OUTPUT))

commands = []
if isWindows():
commands = ["cmd.exe", "/C ", "gdal2xyz.bat", GdalUtils.escapeAndJoin(arguments)]
else:
commands = ["gdal2xyz.py", GdalUtils.escapeAndJoin(arguments)]

GdalUtils.runGdal(commands, progress)
2 changes: 1 addition & 1 deletion python/plugins/processing/grass/GrassAlgorithm.py
Expand Up @@ -336,7 +336,7 @@ def processAlgorithm(self, progress):

if isinstance(out, OutputVector):
filename = out.value
command = "v.out.ogr -e input=" + out.name + uniqueSufix
command = "v.out.ogr -c -e input=" + out.name + uniqueSufix
command += " dsn=\"" + os.path.dirname(out.value) + "\""
command += " format=ESRI_Shapefile"
command += " olayer=" + os.path.basename(out.value)[:-4]
Expand Down
12 changes: 8 additions & 4 deletions python/plugins/processing/saga/ext/supervisedclassification.py
Expand Up @@ -24,9 +24,13 @@
__revision__ = '$Format:%H$'

from processing.tests.TestData import table
from processing.core.ProcessingConfig import ProcessingConfig
from processing.saga.SagaUtils import SagaUtils

def editCommands(commands):
commands[-3] = commands[-3] + " -STATS " + table()
return commands


saga208 = ProcessingConfig.getSetting(SagaUtils.SAGA_208)
if not saga208:
commands[-3] = commands[-3] + " -STATS " + table()
return commands
else:
return commands
2 changes: 1 addition & 1 deletion python/plugins/processing/tools/dataobjects.py
Expand Up @@ -241,7 +241,7 @@ def exportVectorLayer(layer):
if idx != -1:
filename = filename[:idx]

filename = str(layer.name())
filename = unicode(layer.name())
validChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789:"
filename = ''.join(c for c in filename if c in validChars)
if len(filename) == 0:
Expand Down
2 changes: 2 additions & 0 deletions src/app/composer/qgscompositionwidget.cpp
Expand Up @@ -369,6 +369,7 @@ void QgsCompositionWidget::displayCompositionWidthHeight()
setSize( mPaperHeightDoubleSpinBox, paperHeight );

//set orientation
mPaperOrientationComboBox->blockSignals( true );
if ( paperWidth > paperHeight )
{
mPaperOrientationComboBox->setCurrentIndex( mPaperOrientationComboBox->findText( tr( "Landscape" ) ) );
Expand All @@ -377,6 +378,7 @@ void QgsCompositionWidget::displayCompositionWidthHeight()
{
mPaperOrientationComboBox->setCurrentIndex( mPaperOrientationComboBox->findText( tr( "Portrait" ) ) );
}
mPaperOrientationComboBox->blockSignals( false );

//set paper name
bool found = false;
Expand Down
9 changes: 6 additions & 3 deletions src/app/qgsidentifyresultsdialog.cpp
Expand Up @@ -1143,10 +1143,13 @@ void QgsIdentifyResultsDialog::attributeValueChanged( QgsFeatureId fid, int idx,

void QgsIdentifyResultsDialog::highlightFeature( QTreeWidgetItem *item )
{
QgsVectorLayer *layer = vectorLayer( item );
QgsMapLayer *layer;
QgsVectorLayer *vlayer = vectorLayer( item );
QgsRasterLayer *rlayer = rasterLayer( item );
if ( !layer && !rlayer )
return;

layer = vlayer ? static_cast<QgsMapLayer *>( vlayer ) : static_cast<QgsMapLayer *>( rlayer );

if ( !layer ) return;

QgsIdentifyResultsFeatureItem *featItem = dynamic_cast<QgsIdentifyResultsFeatureItem *>( featureItem( item ) );
if ( !featItem )
Expand Down
4 changes: 4 additions & 0 deletions src/app/qgslabelengineconfigdialog.cpp
Expand Up @@ -43,6 +43,8 @@ QgsLabelEngineConfigDialog::QgsLabelEngineConfigDialog( QgsPalLabeling* lbl, QWi
mShadowDebugRectChkBox->setChecked( mLBL->isShowingShadowRectangles() );

mSaveWithProjectChkBox->setChecked( mLBL->isStoredWithProject() );

chkShowPartialsLabels->setChecked( mLBL-> isShowingPartialsLabels() );
}


Expand All @@ -58,6 +60,7 @@ void QgsLabelEngineConfigDialog::onOK()
mLBL->setShowingCandidates( chkShowCandidates->isChecked() );
mLBL->setShowingShadowRectangles( mShadowDebugRectChkBox->isChecked() );
mLBL->setShowingAllLabels( chkShowAllLabels->isChecked() );
mLBL->setShowingPartialsLabels( chkShowPartialsLabels->isChecked() );

if ( mSaveWithProjectChkBox->isChecked() )
{
Expand All @@ -80,4 +83,5 @@ void QgsLabelEngineConfigDialog::setDefaults()
chkShowCandidates->setChecked( false );
chkShowAllLabels->setChecked( false );
mShadowDebugRectChkBox->setChecked( false );
chkShowPartialsLabels->setChecked( p.getShowPartial() );
}
7 changes: 6 additions & 1 deletion src/core/pal/feature.cpp
Expand Up @@ -1361,7 +1361,12 @@ namespace pal
// purge candidates that are outside the bbox
for ( i = 0; i < nbp; i++ )
{
if ( !( *lPos )[i]->isIn( bbox ) )
bool outside = false;
if ( f->layer->pal->getShowPartial() )
outside = !( *lPos )[i]->isIntersect( bbox );
else
outside = !( *lPos )[i]->isInside( bbox );
if ( outside )
{
rnbp--;
( *lPos )[i]->setCost( DBL_MAX ); // infinite cost => do not use
Expand Down
33 changes: 33 additions & 0 deletions src/core/pal/labelposition.cpp
Expand Up @@ -184,6 +184,39 @@ namespace pal
return false;

}

bool LabelPosition::isIntersect( double *bbox )
{
int i;

for ( i = 0; i < 4; i++ )
{
if ( x[i] >= bbox[0] && x[i] <= bbox[2] &&
y[i] >= bbox[1] && y[i] <= bbox[3] )
return true;
}

if ( nextPart )
return nextPart->isIntersect( bbox );
else
return false;
}

bool LabelPosition::isInside( double *bbox )
{
for (int i = 0; i < 4; i++ )
{
if ( !( x[i] >= bbox[0] && x[i] <= bbox[2] &&
y[i] >= bbox[1] && y[i] <= bbox[3] ) )
return false;
}

if ( nextPart )
return nextPart->isInside( bbox );
else
return true;

}

void LabelPosition::print()
{
Expand Down
16 changes: 15 additions & 1 deletion src/core/pal/labelposition.h
Expand Up @@ -109,12 +109,26 @@ namespace pal


/**
* \brief is the labelposition in the bounding-box ?
* \brief Is the labelposition in the bounding-box ? (intersect or inside????)
*
*\param bbox the bounding-box double[4] = {xmin, ymin, xmax, ymax}
*/
bool isIn( double *bbox );

/**
* \brief Is the labelposition intersect the bounding-box ?
*
*\param bbox the bounding-box double[4] = {xmin, ymin, xmax, ymax}
*/
bool isIntersect( double *bbox );

/**
* \brief Is the labelposition inside the bounding-box ?
*
*\param bbox the bounding-box double[4] = {xmin, ymin, xmax, ymax}
*/
bool isInside( double *bbox );

/**
* \brief Check whether or not this overlap with another labelPosition
*
Expand Down
14 changes: 13 additions & 1 deletion src/core/pal/pal.cpp
Expand Up @@ -106,7 +106,9 @@ namespace pal
point_p = 8;
line_p = 8;
poly_p = 8;


showPartial = true;

this->map_unit = pal::METER;

std::cout.precision( 12 );
Expand Down Expand Up @@ -899,6 +901,11 @@ namespace pal
if ( dpi > 0 )
this->dpi = dpi;
}

void Pal::setShowPartial(bool show)
{
this->showPartial = show;
}

int Pal::getPointP()
{
Expand Down Expand Up @@ -929,6 +936,11 @@ namespace pal
{
return dpi;
}

bool Pal::getShowPartial()
{
return showPartial;
}

SearchMethod Pal::getSearch()
{
Expand Down
21 changes: 19 additions & 2 deletions src/core/pal/pal.h
Expand Up @@ -166,6 +166,11 @@ namespace pal
int ejChainDeg;
int tenure;
double candListSize;

/**
* \brief show partial labels (cut-off by the map canvas) or not
*/
bool showPartial;

/**
* \brief Problem factory
Expand Down Expand Up @@ -352,8 +357,20 @@ namespace pal
* @return map resolution (dot per inch)
*/
int getDpi();



/**
*\brief Set flag show partial label
*
* @param show flag value
*/
void setShowPartial(bool show);

/**
* \brief Get flag show partial label
*
* @return value of flag
*/
bool getShowPartial();

/**
* \brief set # candidates to generate for points features
Expand Down

0 comments on commit 7bc72d4

Please sign in to comment.