Skip to content
Permalink
Browse files

[sextante]changed 'create grid' algorithm to allow non integer values

  • Loading branch information
volaya committed Apr 12, 2013
1 parent 448d860 commit 61b3e4c414df69567a08d53834615d82fa5c522d
@@ -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))
@@ -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']

0 comments on commit 61b3e4c

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