Example #1
0
def main():
    options, flags = gcore.parser()
    if options['input']:
        map_name = gcore.find_file(name=options['input'], element='cell')['fullname']
        if not map_name:
            gcore.fatal(_("Raster map <{raster}> not found").format(raster=options['input']))

    # define display driver (avoid 'no graphics device selected' error at start up)
    driver = UserSettings.Get(group='display', key='driver', subkey='type')
    if driver == 'png':
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
    else:
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'

    # launch application
    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()

    # show main frame
    giface = StandaloneGrassInterface()
    frame = ExampleMapFrame(parent=None, giface=giface)
    if options['input']:
        giface.WriteLog(_("Loading raster map <{raster}>...").format(raster=map_name))
        frame.SetLayer(map_name)

    frame.Show()
    app.MainLoop()
Example #2
0
def main():
    group_name = subgroup_name = map_name = trainingmap_name = None

    if options['group']:
        if not options['subgroup']:
            grass.fatal(_("Name of subgroup required"))
        group_name = grass.find_file(name=options['group'],
                                     element='group')['name']
        if not group_name:
            grass.fatal(_("Group <%s> not found") % options['group'])
        if options['subgroup'] not in grass.read_command(
                'i.group', group=group_name, flags='sg').splitlines():
            grass.fatal(_("Subgroup <%s> not found") % options['subgroup'])
        subgroup_name = options['subgroup']

    if options['map']:
        map_name = grass.find_file(name=options['map'],
                                   element='cell')['fullname']
        if not map_name:
            grass.fatal(_("Raster map <%s> not found") % options['map'])

    if options['trainingmap']:
        trainingmap_name = grass.find_file(name=options['trainingmap'],
                                           element='vector')['fullname']
        if not trainingmap_name:
            grass.fatal(
                _("Vector map <%s> not found") % options['trainingmap'])

    # define display driver
    driver = UserSettings.Get(group='display', key='driver', subkey='type')
    if driver == 'png':
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
    else:
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'

    # launch application
    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()

    # show main frame
    giface = StandaloneGrassInterface()
    frame = IClassMapFrame(parent=None, giface=giface)
    if not flags['m']:
        frame.CenterOnScreen()
    if group_name:
        frame.SetGroup(group_name, subgroup_name)
    if map_name:
        giface.WriteLog(_("Loading raster map <%s>...") % map_name)
        frame.trainingMapManager.AddLayer(map_name)
    if trainingmap_name:
        giface.WriteLog(_("Loading training map <%s>...") % trainingmap_name)
        frame.ImportAreas(trainingmap_name)

    frame.Show()
    if flags['m']:
        frame.Maximize()

    app.MainLoop()
Example #3
0
def main():
    driver = UserSettings.Get(group='display', key='driver', subkey='type')
    if driver == 'png':
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
    else:
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'

    first = options['first']
    second = options['second']
    mode = options['mode']

    for mapName in [first, second]:
        if mapName:
            gfile = grass.find_file(name=mapName)
            if not gfile['name']:
                grass.fatal(_("Raster map <%s> not found") % mapName)

    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()

    frame = SwipeMapFrame(parent=None, giface=StandaloneGrassInterface())

    if first:
        frame.SetFirstRaster(first)
    if second:
        frame.SetSecondRaster(second)
    if first or second:
        frame.SetRasterNames()

    frame.SetViewMode(mode)
    frame.Show()

    app.MainLoop()
Example #4
0
def main():
    """Sets the GRASS display driver

    .. todo::
        use command line options as an alternative to wizard
    """
    options, flags = gscript.parser()

    import wx

    from grass.script.setup import set_gui_path

    set_gui_path()

    from core.settings import UserSettings
    from core.giface import StandaloneGrassInterface
    from gcp.manager import GCPWizard

    driver = UserSettings.Get(group="display", key="driver", subkey="type")
    if driver == "png":
        os.environ["GRASS_RENDER_IMMEDIATE"] = "png"
    else:
        os.environ["GRASS_RENDER_IMMEDIATE"] = "cairo"

    app = wx.App()

    wizard = GCPWizard(parent=None, giface=StandaloneGrassInterface())

    app.MainLoop()
Example #5
0
def main():
    """Sets the GRASS display driver

    .. todo::
        use command line options as an alternative to wizard
    """
    options, flags = gscript.parser()

    import wx

    from grass.script.setup import set_gui_path
    set_gui_path()

    from core.settings import UserSettings
    from core.globalvar import CheckWxVersion
    from core.giface import StandaloneGrassInterface
    from gcp.manager import GCPWizard

    driver = UserSettings.Get(group='display', key='driver', subkey='type')
    if driver == 'png':
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
    else:
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'

    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()

    wizard = GCPWizard(parent=None, giface=StandaloneGrassInterface())

    app.MainLoop()
Example #6
0
def main():
    """Test application (potentially useful as g.gui.pyedit)"""
    app = wx.App()
    giface = StandaloneGrassInterface()
    simple_editor = PyEditFrame(parent=None, giface=giface)
    simple_editor.SetSize((600, 800))
    simple_editor.Show()
    app.MainLoop()
Example #7
0
def main():
    options, flags = gscript.parser()

    import wx

    from grass.script.setup import set_gui_path
    set_gui_path()

    from core.utils import _
    from core.giface import StandaloneGrassInterface
    try:
        from tplot.frame import TplotFrame
    except ImportError as e:
        gscript.fatal(e.message)
    rasters = None
    if options['strds']:
        rasters = options['strds'].strip().split(',')
    coords = None
    if options['coordinates']:
        coords = options['coordinates'].strip().split(',')
    cats = None
    if options['cats']:
        cats = options['cats']
    output = options['output']
    vectors = None
    attr = None
    if options['stvds']:
        vectors = options['stvds'].strip().split(',')
        if not options['attr']:
            gscript.fatal(_("With stvds you have to set 'attr' option"))
        else:
            attr = options['attr']
        if coords and cats:
            gscript.fatal(
                _("With stvds it is not possible to use 'coordinates' "
                  "and 'cats' options together"))
        elif not coords and not cats:
            gscript.warning(
                _("With stvds you have to use 'coordinates' or "
                  "'cats' option"))
    app = wx.App()
    frame = TplotFrame(parent=None, giface=StandaloneGrassInterface())
    frame.SetDatasets(rasters, vectors, coords, cats, attr)
    if output:
        frame.OnRedraw()
        if options['size']:
            sizes = options['size'].strip().split(',')
            sizes = [int(s) for s in sizes]
            frame.canvas.SetSize(sizes)
        if output.split('.')[-1].lower() == 'png':
            frame.canvas.print_png(output)
        if output.split('.')[-1].lower() in ['jpg', 'jpeg']:
            frame.canvas.print_jpg(output)
        if output.split('.')[-1].lower() in ['tif', 'tiff']:
            frame.canvas.print_tif(output)
    else:
        frame.Show()
        app.MainLoop()
Example #8
0
def main():
    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()
    frame = RLiSetupFrame(parent=None, giface=StandaloneGrassInterface())
    frame.Show()
    frame.CenterOnScreen()

    app.MainLoop()
Example #9
0
def main():
    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()
    frame = ModelFrame(parent=None, giface=StandaloneGrassInterface())
    if options['file']:
        frame.LoadModelFile(options['file'])
    frame.Show()

    app.MainLoop()
Example #10
0
def main():
    options, flags = gscript.parser()

    import wx

    from grass.script.setup import set_gui_path

    set_gui_path()

    from core.settings import UserSettings
    from core.giface import StandaloneGrassInterface
    from core import globalvar
    from mapswipe.frame import SwipeMapDisplay

    driver = UserSettings.Get(group="display", key="driver", subkey="type")
    if driver == "png":
        os.environ["GRASS_RENDER_IMMEDIATE"] = "png"
    else:
        os.environ["GRASS_RENDER_IMMEDIATE"] = "cairo"

    first = options["first"]
    second = options["second"]
    mode = options["mode"]

    for mapName in [first, second]:
        if mapName:
            gfile = gscript.find_file(name=mapName)
            if not gfile["name"]:
                gscript.fatal(_("Raster map <%s> not found") % mapName)

    app = wx.App()

    # show main frame
    frame = wx.Frame(
        parent=None,
        size=globalvar.MAP_WINDOW_SIZE,
        title=_("Map Swipe Tool - GRASS GIS"),
    )
    frame = SwipeMapDisplay(
        parent=frame,
        giface=StandaloneGrassInterface(),
    )

    if first:
        frame.SetFirstRaster(first)
    if second:
        frame.SetSecondRaster(second)
    if first or second:
        frame.SetRasterNames()

    frame.SetViewMode(mode)
    frame.Show()

    app.MainLoop()
Example #11
0
def main():
    """Sets the GRASS display driver
    """
    options, flags = gscript.parser()

    import wx
    from grass.script.setup import set_gui_path
    set_gui_path()

    from core.settings import UserSettings
    from core.globalvar import CheckWxVersion
    from core.giface import StandaloneGrassInterface
    from photo2image.ip2i_manager import GCPWizard

    driver = UserSettings.Get(group='display', key='driver', subkey='type')
    if driver == 'png':
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
    else:
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'

    if options['group']:
        group = options['group']
    else:
        gscript.fatal(_("Please provide a group name to process"))
    
    if options['raster']:
        raster = options['raster']
    else:
        gscript.fatal(_("Please provide a raster map name to process"))

    if options['camera']:
        camera = options['camera']
    else:
        gscript.fatal(_("Please provide a camera name (generated by i.ortho.camera)"))

    if options['order']:
        order = options['order']
    else:
        gscript.fatal(_("Please provive an order value (1 if 4 Fiducials, 2 if 8 Fiducials)"))

    if options['extension']:
        extension = options['extension']
    else:
        gscript.fatal(_("Please provive an output files extension (used by i.rectify)"))

    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()

    wizard = GCPWizard(parent=None, giface=StandaloneGrassInterface(), group=group, 
            raster=raster, raster1=raster, camera=camera, order=order, extension=extension)
    app.MainLoop()
Example #12
0
def main():
    options, flags = gcore.parser()

    import wx

    from grass.script.setup import set_gui_path

    set_gui_path()

    from core.globalvar import CheckWxVersion, MAP_WINDOW_SIZE
    from core.giface import StandaloneGrassInterface
    from core.settings import UserSettings
    from example.frame import ExampleMapDisplay

    if options["input"]:
        map_name = gcore.find_file(name=options["input"],
                                   element="cell")["fullname"]
        if not map_name:
            gcore.fatal(
                _("Raster map <{raster}> not found").format(
                    raster=options["input"]))

    # define display driver (avoid 'no graphics device selected' error at start up)
    driver = UserSettings.Get(group="display", key="driver", subkey="type")
    if driver == "png":
        os.environ["GRASS_RENDER_IMMEDIATE"] = "png"
    else:
        os.environ["GRASS_RENDER_IMMEDIATE"] = "cairo"

    # launch application
    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()

    # show main frame
    frame = wx.Frame(parent=None,
                     size=MAP_WINDOW_SIZE,
                     title=_("Example Tool - GRASSGIS"))
    frame = ExampleMapDisplay(
        parent=frame,
        giface=StandaloneGrassInterface(),
    )
    if options["input"]:
        frame.giface.WriteLog(
            _("Loading raster map <{raster}>...").format(raster=map_name))
        frame.SetLayer(map_name)

    frame.Show()
    app.MainLoop()
Example #13
0
def main():
    options, flags = gscript.parser()

    import wx

    from grass.script.setup import set_gui_path
    set_gui_path()

    from core.settings import UserSettings
    from core.globalvar import CheckWxVersion
    from core.giface import StandaloneGrassInterface
    from core.utils import _
    from mapswipe.frame import SwipeMapFrame

    driver = UserSettings.Get(group='display', key='driver', subkey='type')
    if driver == 'png':
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
    else:
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'

    first = options['first']
    second = options['second']
    mode = options['mode']

    for mapName in [first, second]:
        if mapName:
            gfile = gscript.find_file(name=mapName)
            if not gfile['name']:
                gscript.fatal(_("Raster map <%s> not found") % mapName)

    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()

    frame = SwipeMapFrame(parent=None, giface=StandaloneGrassInterface())

    if first:
        frame.SetFirstRaster(first)
    if second:
        frame.SetSecondRaster(second)
    if first or second:
        frame.SetRasterNames()

    frame.SetViewMode(mode)
    frame.Show()

    app.MainLoop()
Example #14
0
def main():
    gscript.parser()

    import wx

    from grass.script.setup import set_gui_path
    set_gui_path()

    from core.giface import StandaloneGrassInterface
    from rlisetup.frame import RLiSetupFrame

    app = wx.App()
    frame = RLiSetupFrame(parent=None, giface=StandaloneGrassInterface())
    frame.Show()
    frame.CenterOnScreen()

    app.MainLoop()
Example #15
0
def main():
    options, flags = gscript.parser()

    # import wx only after running parser
    # to avoid issues when only interface is needed
    import wx

    from grass.script.setup import set_gui_path
    set_gui_path()

    from core.giface import StandaloneGrassInterface
    from datacatalog.frame import DataCatalogFrame

    app = wx.App()

    frame = DataCatalogFrame(parent=None, giface=StandaloneGrassInterface())
    frame.CentreOnScreen()
    frame.Show()
    app.MainLoop()
Example #16
0
def main():
    gscript.parser()

    import wx

    from grass.script.setup import set_gui_path
    set_gui_path()

    from core.giface import StandaloneGrassInterface
    from core.globalvar import CheckWxVersion
    from rlisetup.frame import RLiSetupFrame

    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()
    frame = RLiSetupFrame(parent=None, giface=StandaloneGrassInterface())
    frame.Show()
    frame.CenterOnScreen()

    app.MainLoop()
Example #17
0
def main():
    options, flags = gscript.parser()

    import wx

    from grass.script.setup import set_gui_path
    set_gui_path()

    from core.giface import StandaloneGrassInterface
    from core.globalvar import CheckWxVersion
    from gmodeler.frame import ModelFrame

    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()
    frame = ModelFrame(parent=None, giface=StandaloneGrassInterface())
    if options['file']:
        frame.LoadModelFile(options['file'])
    frame.Show()

    app.MainLoop()
Example #18
0
def main():
    options, flags = gscript.parser()

    import wx

    from grass.script.setup import set_gui_path
    set_gui_path()

    from core.giface import StandaloneGrassInterface
    from gmodeler.frame import ModelFrame

    app = wx.App()
    frame = ModelFrame(
        parent=None,
        giface=StandaloneGrassInterface(),
        title=_("Graphical Modeler - GRASS GIS"),
    )
    if options['file']:
        frame.LoadModelFile(options['file'])
    frame.Show()

    app.MainLoop()
Example #19
0
    def __init__(self, vectorMap):
        MapFrame.__init__(self,
                          parent=None,
                          giface=StandaloneGrassInterface(),
                          title=_("GRASS GIS Vector Digitizer"),
                          size=(850, 600))

        # load vector map
        mapLayer = self.GetMap().AddLayer(
            ltype='vector',
            command=['d.vect', 'map=%s' % vectorMap],
            active=True,
            name=vectorMap,
            hidden=False,
            opacity=1.0,
            render=True)

        # switch toolbar
        self.AddToolbar('vdigit', fixed=True)

        # start editing
        self.toolbars['vdigit'].StartEditing(mapLayer)
Example #20
0
def main():
    options, flags = gscript.parser()

    import wx

    from grass.script.setup import set_gui_path
    set_gui_path()

    from core.giface import StandaloneGrassInterface
    try:
        from tplot.frame import TplotFrame
    except ImportError as e:
        gscript.fatal(e.message)
    rasters = None
    if options['strds']:
        rasters = options['strds'].strip().split(',')
    coords = None
    if options['coordinates']:
        coords = options['coordinates'].strip().split(',')
    cats = None
    if options['cats']:
        cats = options['cats']
    output = options['output']
    vectors = None
    attr = None
    if options['stvds']:
        vectors = options['stvds'].strip().split(',')
        if not options['attr']:
            gscript.fatal(_("With stvds you have to set 'attr' option"))
        else:
            attr = options['attr']
        if coords and cats:
            gscript.fatal(_("With stvds it is not possible to use 'coordinates' "
                            "and 'cats' options together"))
        elif not coords and not cats:
            gscript.warning(_("With stvds you have to use 'coordinates' or "
                              "'cats' option"))
    title = None
    if options['title']:
        title = options['title']
    xlabel = None
    if options['xlabel']:
        xlabel = options['xlabel']
    ylabel = None
    if options['ylabel']:
        ylabel = options['ylabel']
    csvfile = None
    if options['csv']:
        csvfile = options['csv']
    app = wx.App()
    frame = TplotFrame(
        parent=None,
        giface=StandaloneGrassInterface(),
        title=_("Temporal Plot Tool - GRASS GIS"),
    )
    if flags['l']:
        frame.linRegRaster.SetValue(state=True)
        frame.linRegVector.SetValue(state=True)
    frame.SetDatasets(rasters, vectors, coords, cats, attr, title, xlabel,
                      ylabel, csvfile, flags['h'], gscript .overwrite)
    if output:
        frame.OnRedraw()
        if options['size']:
            sizes = options['size'].strip().split(',')
            sizes = [int(s) for s in sizes]
            frame.canvas.SetSize(sizes)
        frame.canvas.figure.savefig(output)
    else:
        frame.Show()
        app.MainLoop()
Example #21
0
    def __init__(self, parent, samplingType, icon=None, map_=None):
        wx.Panel.__init__(self, parent=parent)

        self.mapWindowProperties = MapWindowProperties()
        self.mapWindowProperties.setValuesFromUserSettings()
        giface = StandaloneGrassInterface()
        self.samplingtype = samplingType
        self.parent = parent

        if map_:
            self.map_ = map_
        else:
            self.map_ = Map()
        self.map_.region = self.map_.GetRegion()

        self._mgr = wx.aui.AuiManager(self)
        self.mapWindow = BufferedMapWindow(parent=self, giface=giface,
                                           Map=self.map_,
                                           properties=self.mapWindowProperties)
        self._mgr.AddPane(self.mapWindow, wx.aui.AuiPaneInfo().CentrePane().
                          Dockable(True).BestSize((-1, -1)).Name('mapwindow').
                          CloseButton(False).DestroyOnClose(True).
                          Layer(0))
        self._toolSwitcher = ToolSwitcher()
        self._toolSwitcher.toggleToolChanged.connect(self._onToolChanged)
        self.toolbar = RLiSetupToolbar(self, self._toolSwitcher)

        self.catId = 1

        self._mgr.AddPane(self.toolbar,
                          wx.aui.AuiPaneInfo().
                          Name("maptoolbar").Caption(_("Map Toolbar")).
                          ToolbarPane().Left().Name('mapToolbar').
                          CloseButton(False).Layer(1).Gripper(False).
                          BestSize((self.toolbar.GetBestSize())))
        self._mgr.Update()

        if self.samplingtype == SamplingType.REGIONS:
            self.afterRegionDrawn = Signal('RLiSetupMapPanel.afterRegionDrawn')
            self._registeredGraphics = self.mapWindow.RegisterGraphicsToDraw(
                graphicsType='line')
        elif self.samplingtype in [SamplingType.MUNITSR, SamplingType.MMVWINR]:
            self.sampleFrameChanged = Signal(
                'RLiSetupMapPanel.sampleFrameChanged')
            self._registeredGraphics = self.mapWindow.RegisterGraphicsToDraw(
                graphicsType='rectangle')
        elif self.samplingtype in [SamplingType.MUNITSC, SamplingType.MMVWINC]:
            self.afterCircleDrawn = Signal('RLiSetupMapPanel.afterCircleDrawn')
            self._registeredGraphics = self.mapWindow.RegisterGraphicsToDraw(
                graphicsType='line')
        else:
            self.sampleFrameChanged = Signal(
                'RLiSetupMapPanel.sampleFrameChanged')
            self._registeredGraphics = self.mapWindow.RegisterGraphicsToDraw(
                graphicsType='rectangle')

        self._registeredGraphics.AddPen('rlisetup', wx.Pen(wx.GREEN, width=2,
                                                           style=wx.SOLID))
        self._registeredGraphics.AddItem(coords=[[0, 0], [0, 0]],
                                         penName='rlisetup', hide=True)

        if self.samplingtype != SamplingType.VECT:
            self.toolbar.SelectDefault()
Example #22
0
def main():
    rast = options['rast']
    vect = options['vect']
    strds = options['strds']
    stvds = options['stvds']

    numInputs = 0

    if rast:
        numInputs += 1
    if vect:
        numInputs += 1
    if strds:
        numInputs += 1
    if stvds:
        numInputs += 1

    if numInputs > 1:
        grass.fatal(
            _("%s=, %s=, %s= and %s= are mutually exclusive.") %
            ("rast", "vect", "strds", "stvds"))

    if numInputs > 0:
        # We need to initialize the temporal framework in case
        # a space time dataset was set on the command line so that
        # the AnimLayer() class works correctly
        tgis.init()

    layerList = LayerList()
    if rast:
        layer = AnimLayer()
        layer.mapType = 'rast'
        layer.name = rast
        layer.cmd = ['d.rast', 'map={name}'.format(name=rast.split(',')[0])]
        layerList.AddLayer(layer)
    if vect:
        layer = AnimLayer()
        layer.mapType = 'vect'
        layer.name = vect
        layer.cmd = ['d.vect', 'map={name=}'.format(name=vect.split(',')[0])]
        layerList.AddLayer(layer)
    if strds:
        layer = AnimLayer()
        layer.mapType = 'strds'
        layer.name = strds
        layer.cmd = ['d.rast', 'map=']
        layerList.AddLayer(layer)
    if stvds:
        layer = AnimLayer()
        layer.mapType = 'stvds'
        layer.name = stvds
        layer.cmd = ['d.vect', 'map=']
        layerList.AddLayer(layer)

    app = wx.App()
    if not CheckWxVersion([2, 9]):
        wx.InitAllImageHandlers()

    frame = AnimationFrame(parent=None, giface=StandaloneGrassInterface())
    frame.CentreOnScreen()
    frame.Show()
    if len(layerList) >= 1:
        frame.SetAnimations([layerList] + [None] * (MAX_COUNT - 1))
    app.MainLoop()
Example #23
0
 def __init__(self, mapframe):
     StandaloneGrassInterface.__init__(self)
     self._mapframe = mapframe
Example #24
0
def main():
    options, flags = gscript.parser()

    # import wx only after running parser
    # to avoid issues when only interface is needed
    import grass.temporal as tgis
    import wx

    from grass.script.setup import set_gui_path
    set_gui_path()

    from core.giface import StandaloneGrassInterface
    from core.layerlist import LayerList
    from animation.frame import AnimationFrame, MAX_COUNT
    from animation.data import AnimLayer

    rast = options['raster']
    vect = options['vector']
    strds = options['strds']
    stvds = options['stvds']

    numInputs = 0

    if rast:
        numInputs += 1
    if vect:
        numInputs += 1
    if strds:
        numInputs += 1
    if stvds:
        numInputs += 1

    if numInputs > 1:
        gscript.fatal(_("%s=, %s=, %s= and %s= are mutually exclusive.") %
                       ("raster", "vector", "strds", "stvds"))

    if numInputs > 0:
        # We need to initialize the temporal framework in case
        # a space time dataset was set on the command line so that
        # the AnimLayer() class works correctly
        try:
            tgis.init()
        except FatalError as e:
            print(e)

    layerList = LayerList()
    if rast:
        layer = AnimLayer()
        layer.mapType = 'raster'
        layer.name = rast
        layer.cmd = ['d.rast', 'map={name}'.format(name=rast.split(',')[0])]
        layerList.AddLayer(layer)
    if vect:
        layer = AnimLayer()
        layer.mapType = 'vector'
        layer.name = vect
        layer.cmd = ['d.vect', 'map={name}'.format(name=vect.split(',')[0])]
        layerList.AddLayer(layer)
    if strds:
        layer = AnimLayer()
        layer.mapType = 'strds'
        layer.name = strds
        layer.cmd = ['d.rast', 'map=']
        layerList.AddLayer(layer)
    if stvds:
        layer = AnimLayer()
        layer.mapType = 'stvds'
        layer.name = stvds
        layer.cmd = ['d.vect', 'map=']
        layerList.AddLayer(layer)

    app = wx.App()

    frame = AnimationFrame(parent=None, giface=StandaloneGrassInterface())
    frame.CentreOnScreen()
    frame.Show()
    if len(layerList) >= 1:
        # CallAfter added since it was crashing with wxPython 3 gtk
        wx.CallAfter(frame.SetAnimations,
                     [layerList] + [None] * (MAX_COUNT - 1))
    app.MainLoop()
Example #25
0
 def __init__(self, mapframe):
     StandaloneGrassInterface.__init__(self)
     self._mapframe = mapframe
Example #26
0
def main():
    gscript.set_raise_on_error(False)
    options, flags = gscript.parser()

    import wx

    from grass.script.setup import set_gui_path
    set_gui_path()

    from core.settings import UserSettings
    from core.giface import StandaloneGrassInterface
    from iclass.frame import IClassMapFrame

    group_name = subgroup_name = map_name = trainingmap_name = None

    if options['group']:
        if not options['subgroup']:
            gscript.fatal(_("Name of subgroup required"))
        group_name = gscript.find_file(name=options['group'],
                                       element='group')['name']
        if not group_name:
            gscript.fatal(_("Group <%s> not found") % options['group'])
        subgroups = gscript.read_command('i.group',
                                         group=group_name,
                                         flags='sg').splitlines()
        if options['subgroup'] not in subgroups:
            gscript.fatal(_("Subgroup <%s> not found") % options['subgroup'])
        subgroup_name = options['subgroup']

    if options['map']:
        map_name = gscript.find_file(name=options['map'],
                                     element='cell')['fullname']
        if not map_name:
            gscript.fatal(_("Raster map <%s> not found") % options['map'])

    if options['trainingmap']:
        trainingmap_name = gscript.find_file(name=options['trainingmap'],
                                             element='vector')['fullname']
        if not trainingmap_name:
            gscript.fatal(
                _("Vector map <%s> not found") % options['trainingmap'])

    # define display driver
    driver = UserSettings.Get(group='display', key='driver', subkey='type')
    if driver == 'png':
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
    else:
        os.environ['GRASS_RENDER_IMMEDIATE'] = 'cairo'

    # launch application
    app = wx.App()

    # show main frame
    giface = StandaloneGrassInterface()
    frame = IClassMapFrame(parent=None, giface=giface)
    if not flags['m']:
        frame.CenterOnScreen()
    if group_name:
        frame.SetGroup(group_name, subgroup_name)
    if map_name:
        giface.WriteLog(_("Loading raster map <%s>...") % map_name)
        frame.trainingMapManager.AddLayer(map_name)
    if trainingmap_name:
        giface.WriteLog(_("Loading training map <%s>...") % trainingmap_name)
        frame.ImportAreas(trainingmap_name)

    frame.Show()
    if flags['m']:
        frame.Maximize()
    app.MainLoop()
Example #27
0
def main():
    gscript.set_raise_on_error(False)
    options, flags = gscript.parser()

    import wx

    from grass.script.setup import set_gui_path

    set_gui_path()

    from core.settings import UserSettings
    from core.giface import StandaloneGrassInterface
    from iclass.frame import IClassMapFrame

    group_name = subgroup_name = map_name = trainingmap_name = None

    if options["group"]:
        if not options["subgroup"]:
            gscript.fatal(_("Name of subgroup required"))
        group_name = gscript.find_file(name=options["group"],
                                       element="group")["name"]
        if not group_name:
            gscript.fatal(_("Group <%s> not found") % options["group"])
        subgroups = gscript.read_command("i.group",
                                         group=group_name,
                                         flags="sg").splitlines()
        if options["subgroup"] not in subgroups:
            gscript.fatal(_("Subgroup <%s> not found") % options["subgroup"])
        subgroup_name = options["subgroup"]

    if options["map"]:
        map_name = gscript.find_file(name=options["map"],
                                     element="cell")["fullname"]
        if not map_name:
            gscript.fatal(_("Raster map <%s> not found") % options["map"])

    if options["trainingmap"]:
        trainingmap_name = gscript.find_file(name=options["trainingmap"],
                                             element="vector")["fullname"]
        if not trainingmap_name:
            gscript.fatal(
                _("Vector map <%s> not found") % options["trainingmap"])

    # define display driver
    driver = UserSettings.Get(group="display", key="driver", subkey="type")
    if driver == "png":
        os.environ["GRASS_RENDER_IMMEDIATE"] = "png"
    else:
        os.environ["GRASS_RENDER_IMMEDIATE"] = "cairo"

    # launch application
    app = wx.App()

    # show main frame
    giface = StandaloneGrassInterface()
    frame = IClassMapFrame(
        parent=None,
        giface=giface,
        title=_("Supervised Classification Tool - GRASS GIS"),
    )
    if not flags["m"]:
        frame.CenterOnScreen()
    if group_name:
        frame.SetGroup(group_name, subgroup_name)
    if map_name:
        giface.WriteLog(_("Loading raster map <%s>...") % map_name)
        frame.trainingMapManager.AddLayer(map_name)
    if trainingmap_name:
        giface.WriteLog(_("Loading training map <%s>...") % trainingmap_name)
        frame.ImportAreas(trainingmap_name)

    frame.Show()
    if flags["m"]:
        frame.Maximize()
    app.MainLoop()
Example #28
0
def main():
    """
    Sets the GRASS display driver
    """
    options, flags = gscript.parser()

    import wx

    from grass.script.setup import set_gui_path

    set_gui_path()

    from core.settings import UserSettings
    from core.giface import StandaloneGrassInterface
    from image2target.ii2t_manager import GCPWizard

    driver = UserSettings.Get(group="display", key="driver", subkey="type")
    if driver == "png":
        os.environ["GRASS_RENDER_IMMEDIATE"] = "png"
    else:
        os.environ["GRASS_RENDER_IMMEDIATE"] = "cairo"

    #    if options['source_location']:
    #        src_loc = options['source_location']
    #    else:
    #        gscript.fatal(_("No georeferenced source location provided"))

    #    if options['source_mapset']:
    #        src_mpt = options['source_mapset']
    #    else:
    #        gscript.fatal(_("No georeferenced source mapset provided"))

    #    if options['source_group']:
    #        src_grp = options['source_group']
    #    else:
    #        gscript.fatal(_("Please provide a source group name to process"))

    #    if options['source_image']:
    #        src_ras = options['source_image']
    #    else:
    #        gscript.fatal(_("Please provide a source image map name to process"))

    #    if options['target_image']:
    #        tgt_ras = options['target_image']
    #    else:
    #        gscript.fatal(_("No georeferenced target map provided"))

    #    if options['camera']:
    #        camera = options['camera']
    #    else:
    #        gscript.fatal(_("Please provide a camera name (generated by i.ortho.camera)"))

    #    if options['order']:
    #        order = options['order']
    #    else:
    #        gscript.fatal(_("Please provive an order value"))

    #    if options['extension']:
    #        extension = options['extension']
    #    else:
    #        gscript.fatal(_("Please provide an output file extension"))

    app = wx.App()

    #    wizard = GCPWizard(parent=None, giface=StandaloneGrassInterface(),
    #            srcloc=src_loc,srcmpt=src_mpt,srcgrp=src_grp,srcras=src_ras,
    #            tgtras=tgt_ras,camera=camera, order=order, extension=extension)

    wizard = GCPWizard(parent=None, giface=StandaloneGrassInterface())
    app.MainLoop()
Example #29
0
 def __init__(self, map_):
     StandaloneGrassInterface.__init__(self)
     self._map = map_
     self.mapWindow = None
Example #30
0
 def __init__(self, map_):
     StandaloneGrassInterface.__init__(self)
     self._map = map_
     self.mapWindow = None
Example #31
0
        cmddata.SetText(command)
        if wx.TheClipboard.Open():
            wx.TheClipboard.SetData(cmddata)
            wx.TheClipboard.Close()
            self.SetStatusText(
                _("'{cmd}' copied to clipboard").format(cmd=command))

    def OnClear(self, event):
        """Clears text area
        """
        self.text_mcalc.SetValue('')

    def OnHelp(self, event):
        """Launches r.mapcalc help
        """
        RunCommand('g.manual', parent=self, entry=self.cmd)

    def OnClose(self, event):
        """Close window"""
        self.Destroy()


if __name__ == "__main__":

    app = wx.App(0)
    frame = MapCalcFrame(parent=None,
                         cmd='r.mapcalc',
                         giface=StandaloneGrassInterface())
    frame.Show()
    app.MainLoop()
Example #32
0
def main():
    """Sets the GRASS display driver"""
    options, flags = gscript.parser()

    import wx
    from grass.script.setup import set_gui_path

    set_gui_path()

    from core.settings import UserSettings
    from core.giface import StandaloneGrassInterface
    from photo2image.ip2i_manager import GCPWizard

    driver = UserSettings.Get(group="display", key="driver", subkey="type")
    if driver == "png":
        os.environ["GRASS_RENDER_IMMEDIATE"] = "png"
    else:
        os.environ["GRASS_RENDER_IMMEDIATE"] = "cairo"

    if options["group"]:
        group = options["group"]
    else:
        gscript.fatal(_("Please provide a group name to process"))

    if options["raster"]:
        raster = options["raster"]
    else:
        gscript.fatal(_("Please provide a raster map name to process"))

    if options["camera"]:
        camera = options["camera"]
    else:
        gscript.fatal(
            _("Please provide a camera name (generated by i.ortho.camera)"))

    if options["order"]:
        order = options["order"]
    else:
        gscript.fatal(
            _("Please provive an order value (1 if 4 Fiducials, 2 if 8 Fiducials)"
              ))

    if options["extension"]:
        extension = options["extension"]
    else:
        gscript.fatal(
            _("Please provive an output files extension (used by i.rectify)"))

    app = wx.App()

    wizard = GCPWizard(
        parent=None,
        giface=StandaloneGrassInterface(),
        group=group,
        raster=raster,
        raster1=raster,
        camera=camera,
        order=order,
        extension=extension,
    )
    app.MainLoop()