Skip to content
Permalink
Browse files

Merge branch 'master' of github.com:qgis/QGIS

  • Loading branch information
pcav committed Oct 1, 2013
2 parents dd914b8 + 96bd7e7 commit 7bc72d4f6dc494cbd7bbe31dd9ed23f07d3f6fe2
Showing with 1,389 additions and 1,139 deletions.
  1. +1,095 −1,109 i18n/qgis_lt.ts
  2. +3 −0 python/core/qgspallabeling.sip
  3. +1 −0 python/plugins/processing/admintools/ImportIntoPostGIS.py
  4. +2 −1 python/plugins/processing/gdal/GdalOgrAlgorithmProvider.py
  5. +72 −0 python/plugins/processing/gdal/gdal2xyz.py
  6. +1 −1 python/plugins/processing/grass/GrassAlgorithm.py
  7. +8 −4 python/plugins/processing/saga/ext/supervisedclassification.py
  8. +1 −1 python/plugins/processing/tools/dataobjects.py
  9. +2 −0 src/app/composer/qgscompositionwidget.cpp
  10. +6 −3 src/app/qgsidentifyresultsdialog.cpp
  11. +4 −0 src/app/qgslabelengineconfigdialog.cpp
  12. +6 −1 src/core/pal/feature.cpp
  13. +33 −0 src/core/pal/labelposition.cpp
  14. +15 −1 src/core/pal/labelposition.h
  15. +13 −1 src/core/pal/pal.cpp
  16. +19 −2 src/core/pal/pal.h
  17. +8 −0 src/core/qgspallabeling.cpp
  18. +4 −0 src/core/qgspallabeling.h
  19. +2 −0 src/gui/attributetable/qgsattributetablemodel.cpp
  20. +17 −3 src/gui/qgshighlight.cpp
  21. +4 −1 src/gui/qgshighlight.h
  22. +7 −0 src/mapserver/qgsprojectparser.cpp
  23. +3 −0 src/providers/spatialite/qgsspatialitefeatureiterator.cpp
  24. +15 −8 src/ui/qgsengineconfigdialog.ui
  25. +26 −3 tests/src/python/test_qgspallabeling_base.py
  26. +1 −0 tests/src/python/test_qgspallabeling_canvas.py
  27. +1 −0 tests/src/python/test_qgspallabeling_server.py
  28. +20 −0 tests/src/python/test_qgspallabeling_tests.py
  29. BIN ...ta/control_images/expected_pal_canvas/sp_partials_labels_disabled/sp_partials_labels_disabled.png
  30. BIN ...data/control_images/expected_pal_canvas/sp_partials_labels_enabled/sp_partials_labels_enabled.png

Large diffs are not rendered by default.

@@ -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

@@ -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))
@@ -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
@@ -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
@@ -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)
@@ -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]
@@ -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
@@ -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:
@@ -369,6 +369,7 @@ void QgsCompositionWidget::displayCompositionWidthHeight()
setSize( mPaperHeightDoubleSpinBox, paperHeight );

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

//set paper name
bool found = false;
@@ -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 )
@@ -43,6 +43,8 @@ QgsLabelEngineConfigDialog::QgsLabelEngineConfigDialog( QgsPalLabeling* lbl, QWi
mShadowDebugRectChkBox->setChecked( mLBL->isShowingShadowRectangles() );

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

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


@@ -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() )
{
@@ -80,4 +83,5 @@ void QgsLabelEngineConfigDialog::setDefaults()
chkShowCandidates->setChecked( false );
chkShowAllLabels->setChecked( false );
mShadowDebugRectChkBox->setChecked( false );
chkShowPartialsLabels->setChecked( p.getShowPartial() );
}
@@ -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
@@ -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()
{
@@ -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
*
@@ -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 );
@@ -899,6 +901,11 @@ namespace pal
if ( dpi > 0 )
this->dpi = dpi;
}

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

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

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

SearchMethod Pal::getSearch()
{
@@ -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
@@ -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

0 comments on commit 7bc72d4

Please sign in to comment.
You can’t perform that action at this time.