Skip to content

Commit

Permalink
[sextante]changed 'create grid' algorithm to allow non integer values
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed Apr 12, 2013
1 parent 448d860 commit 61b3e4c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
12 changes: 6 additions & 6 deletions python/plugins/sextante/algs/mmqgisx/MMQGISXAlgorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,12 @@ def defineCharacteristics(self):
self.name = "Create grid"
self.group = "Vector creation tools"

self.addParameter(ParameterNumber(self.HSPACING, "Horizontal spacing", default = 10))
self.addParameter(ParameterNumber(self.VSPACING, "Vertical spacing", default = 10))
self.addParameter(ParameterNumber(self.WIDTH, "Width", default = 360))
self.addParameter(ParameterNumber(self.HEIGHT, "Height", default = 180))
self.addParameter(ParameterNumber(self.CENTERX, "Center X", default = 0))
self.addParameter(ParameterNumber(self.CENTERY, "Center Y", default = 0))
self.addParameter(ParameterNumber(self.HSPACING, "Horizontal spacing", default = 10.0))
self.addParameter(ParameterNumber(self.VSPACING, "Vertical spacing", default = 10.0))
self.addParameter(ParameterNumber(self.WIDTH, "Width", default = 360.0))
self.addParameter(ParameterNumber(self.HEIGHT, "Height", default = 180.0))
self.addParameter(ParameterNumber(self.CENTERX, "Center X", default = 0.0))
self.addParameter(ParameterNumber(self.CENTERY, "Center Y", default = 0.0))
self.gridtype_options = ["Rectangle (line)","Rectangle (polygon)","Diamond (polygon)","Hexagon (polygon)"]
self.addParameter(ParameterSelection(self.GRIDTYPE, "Grid type",
self.gridtype_options, default = 0))
Expand Down
21 changes: 21 additions & 0 deletions python/plugins/sextante/tests/QgisAlgsTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,27 @@ def test_qgiscreategrid(self):
wkt='LINESTRING(-180.0 -90.0, -180.0 -80.0, -180.0 -70.0, -180.0 -60.0, -180.0 -50.0, -180.0 -40.0, -180.0 -30.0, -180.0 -20.0, -180.0 -10.0, -180.0 0.0, -180.0 10.0, -180.0 20.0, -180.0 30.0, -180.0 40.0, -180.0 50.0, -180.0 60.0, -180.0 70.0, -180.0 80.0, -180.0 90.0)'
self.assertEqual(wkt, str(feature.geometry().exportToWkt()))

def test_qgiscreategridnointeger(self):
outputs=sextante.runalg("qgis:creategrid",0.1,0.1,1,1,0,0,None)
output=outputs['SAVENAME']
layer=QGisLayers.getObjectFromUri(output, True)
fields=layer.pendingFields()
expectednames=['longitude','latitude']
expectedtypes=['Real','Real']
names=[str(f.name()) for f in fields]
types=[str(f.typeName()) for f in fields]
self.assertEqual(expectednames, names)
self.assertEqual(expectedtypes, types)
features=sextante.getfeatures(layer)
self.assertEqual(22, len(features))
feature=features.next()
attrs=feature.attributes()
expectedvalues=["-0.5","0"]
values=[str(attr.toString()) for attr in attrs]
self.assertEqual(expectedvalues, values)
wkt='LINESTRING(-0.5 -0.5, -0.5 -0.4, -0.5 -0.3, -0.5 -0.2, -0.5 -0.1, -0.5 -0.0, -0.5 0.1, -0.5 0.2, -0.5 0.3, -0.5 0.4, -0.5 0.5)'
self.assertEqual(wkt, str(feature.geometry().exportToWkt()))

def test_qgiscreategridhex(self):
outputs=sextante.runalg("qgis:creategrid",10,10,360,180,0,0,3,None)
output=outputs['SAVENAME']
Expand Down

0 comments on commit 61b3e4c

Please sign in to comment.