예제 #1
0
    def setUpClass(cls):

        from grass.pygrass import utils
        utils.create_test_vector_map(cls.tmpname)

        cls.vect = None
        cls.vect = VectorTopo(cls.tmpname)
        cls.vect.open('r')
        cls.vect.close()
예제 #2
0
 def setUpClass(cls):
     
     from grass.pygrass import utils
     utils.create_test_vector_map(cls.tmpname)
     
     cls.vect = None
     cls.vect = VectorTopo(cls.tmpname)
     cls.vect.open('r')
     cls.vect.close()
예제 #3
0
    def setUpClass(cls):

        # Tests are based on a stream network
        from grass.pygrass import utils
        utils.create_test_vector_map(cls.tmpname)

        cls.vect = None
        cls.vect = VectorTopo(cls.tmpname)
        cls.vect.open('r')
        cls.c_mapinfo = cls.vect.c_mapinfo
예제 #4
0
    def setUpClass(cls):

        # Tests are based on a stream network
        from grass.pygrass import utils
        utils.create_test_vector_map(cls.tmpname)

        cls.vect = None
        cls.vect = VectorTopo(cls.tmpname)
        cls.vect.open('r')
        cls.c_mapinfo = cls.vect.c_mapinfo
    def setUpClass(cls):

        from grass.pygrass import utils
        utils.create_test_vector_map(cls.tmpname)

        cls.vect = None
        cls.vect = VectorTopo(cls.tmpname)
        cls.vect.open('r')
        cls.c_mapinfo = cls.vect.c_mapinfo

        cls.attrs = cls.vect[1].attrs
예제 #6
0
def load_tests(loader, tests, ignore):
    # TODO: this must be somewhere when doctest is called, not here
    # TODO: ultimate solution is not to use _ as a buildin in lib/python
    from grass.script.core import run_command

    gutils.create_test_vector_map(gutils.test_vector_name)

    run_command("g.region", n=50, s=0, e=60, w=0, res=1)
    run_command("r.mapcalc", expression="%s = 1"%(gutils.test_raster_name),
                             overwrite=True)

    # for now it is the only place where it works
    grass.gunittest.utils.do_doctest_gettext_workaround()
    # this should be called at some top level
    tests.addTests(doctest.DocTestSuite(gutils))
    return tests
예제 #7
0
def load_tests(loader, tests, ignore):
    # TODO: this must be somewhere when doctest is called, not here
    # TODO: ultimate solution is not to use _ as a buildin in lib/python
    from grass.script.core import run_command

    gutils.create_test_vector_map(gutils.test_vector_name)

    run_command("g.region", n=50, s=0, e=60, w=0, res=1)
    run_command("r.mapcalc",
                expression="%s = 1" % (gutils.test_raster_name),
                overwrite=True)

    # for now it is the only place where it works
    grass.gunittest.utils.do_doctest_gettext_workaround()
    # this should be called at some top level
    tests.addTests(doctest.DocTestSuite(gutils))
    return tests
예제 #8
0
            RPCDefs.GET_VECTOR_FEATURES_AS_WKB,
            name,
            mapset,
            extent,
            feature_type,
            field,
        ])
        return self.safe_receive("get_vector_features_as_wkb_list")


if __name__ == "__main__":
    import doctest
    from grass.pygrass.modules import Module

    Module("g.region", n=40, s=0, e=40, w=0, res=10)
    Module(
        "r.mapcalc",
        expression="%s = row() + (10 * col())" % (test_raster_name),
        overwrite=True,
    )
    utils.create_test_vector_map(test_vector_name)

    doctest.testmod()
    """Remove the generated maps, if exist"""
    mset = utils.get_mapset_raster(test_raster_name, mapset="")
    if mset:
        Module("g.remove", flags="f", type="raster", name=test_raster_name)
    mset = utils.get_mapset_vector(test_vector_name, mapset="")
    if mset:
        Module("g.remove", flags="f", type="vector", name=test_vector_name)
예제 #9
0
                    raise GrassError(_("Unable to read area with id %i"%(a_id)))

                pcat = None
                c_ok = libvect.Vect_get_area_cats(self.c_mapinfo, a_id,
                                                  ctypes.byref(line_c))
                if c_ok == 0: # Centroid found

                    ok = libvect.Vect_cat_get(ctypes.byref(line_c), field,
                                              ctypes.byref(cat))
                    if ok > 0:
                        pcat = cat.value

                l.append((a_id, pcat, ctypes.string_at(barray, size.value)))
                libgis.G_free(barray)

            return l
        return None

if __name__ == "__main__":
    import doctest
    from grass.pygrass import utils
    utils.create_test_vector_map(test_vector_name)
    doctest.testmod()

    """Remove the generated vector map, if exist"""
    from grass.pygrass.utils import get_mapset_vector
    from grass.script.core import run_command
    mset = get_mapset_vector(test_vector_name, mapset='')
    if mset:
        run_command("g.remove", flags='f', type='vector', name=test_vector_name)