TclCommandGeoUnion.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. from tclCommands.TclCommand import *
  2. class TclCommandGeoUnion(TclCommand):
  3. """
  4. Tcl shell command to run a union (addition) operation on the
  5. components of a geometry object.
  6. example:
  7. """
  8. # List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
  9. aliases = ['geo_union']
  10. # Dictionary of types from Tcl command, needs to be ordered
  11. arg_names = collections.OrderedDict([
  12. ('name', str),
  13. ])
  14. # Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value
  15. option_types = collections.OrderedDict([
  16. ])
  17. # array of mandatory options for current Tcl command: required = {'name','outname'}
  18. required = ['name']
  19. # structured help for current command, args needs to be ordered
  20. help = {
  21. 'main': ('Runs a union operation (addition) on the components '
  22. 'of the geometry object. For example, if it contains '
  23. '2 intersecting polygons, this opperation adds them into'
  24. 'a single larger polygon.'),
  25. 'args': collections.OrderedDict([
  26. ('name', 'Name of the Geometry Object.'),
  27. ]),
  28. 'examples': []
  29. }
  30. def execute(self, args, unnamed_args):
  31. """
  32. :param args:
  33. :param unnamed_args:
  34. :return:
  35. """
  36. obj_name = args['name']
  37. try:
  38. obj = self.collection.get_by_name(str(obj_name))
  39. except:
  40. return "Could not retrieve object: %s" % obj_name
  41. if obj is None:
  42. return "Object not found: %s" % obj_name
  43. obj.union()