コード例 #1
0
    def create_feature_line_fill_symbol(i_symbol):
        """ This collects all properties of a line fill symbol and returns a dictionary of them

        :param i_symbol: the symbol to investigate
        :return: symbol_properties as dictionary
        """
        fill_dict = copy.deepcopy(SingleSymbol.propDict)
        symbol_properties = {
            'simpleSymbolClass': "LinePatternFill",
            'dict_symbols': fill_dict,
        }

        symbol_properties['dict_symbols']['angle'] = i_symbol.Angle
        layer_color = convert_int_to_rgb_string(i_symbol.LineSymbol.Color.RGB)
        symbol_properties['dict_symbols']['color'] = layer_color
        symbol_properties['dict_symbols']['offset'] = i_symbol.Offset
        symbol_properties['dict_symbols']['distance'] = str(i_symbol.Separation)

        symbol_properties['dict_symbols']['outline_color'] = convert_int_to_rgb_string(i_symbol.Outline.Color.RGB)
        symbol_properties['dict_symbols']['outline_width'] = i_symbol.Outline.Width

        SubSymbolProvider.create_sub_symbol(symbol_properties, 'line')

        from renderer.feature.symbols.symbolPropertiesProvider import SymbolPropertiesProvider
        SymbolPropertiesProvider.get_line_properties(
            symbol_properties['subSymbol'],
            i_symbol.LineSymbol
        )

        return symbol_properties
コード例 #2
0
    def get_text_style(formatted_symbol, label_dict):
        """
        This function defines the text-style in the label_dict
        :param formatted_symbol: the text-symbol
        :param label_dict: the label dictionary including all the label properties
        """
        label_dict['labelValues']['placement']['rotationAngle'] = str(
            formatted_symbol.Angle)
        label_dict['labelValues']['text-style']['fontLetterSpacing'] = str(
            formatted_symbol.CharacterSpacing)
        # label_dict['labelValues']['text-style']['fontWordSpacing'] = str(formattedSymbol.WordSpacing)
        label_dict['labelValues']['text-style'][
            'textColor'] = convert_int_to_rgb_string(
                formatted_symbol.Color.RGB)
        label_dict['labelValues']['text-style'][
            'fontFamily'] = formatted_symbol.Font.Name
        label_dict['labelValues']['text-style']['fontWeight'] = str(
            formatted_symbol.Font.Weight)
        label_dict['labelValues']['text-style']['fontSize'] = str(
            formatted_symbol.Size)
        label_dict['labelValues']['text-style']['fontItalic'] = str(
            int(formatted_symbol.Font.Italic))
        label_dict['labelValues']['text-style']['fontUnderline'] = str(
            int(formatted_symbol.Font.Underline))

        if formatted_symbol.Font.Bold:
            label_dict['labelValues']['text-style']['namedStyle'] = "Bold"
        else:
            label_dict['labelValues']['text-style']['namedStyle'] = "Standard"

        label_dict['labelValues']['shadow'][
            'shadowColor'] = convert_int_to_rgb_string(
                formatted_symbol.ShadowColor.RGB)
コード例 #3
0
    def write_multi_gradient_colors_in_dict(multi_gradient_fill, ramp_number,
                                            color_range, radial_fill,
                                            symbol_properties):
        """ This returns the the color-range of the used color-ramp (and adds it to the existing range)
            of a multi_gradient_fill_symbol

        :param multi_gradient_fill: Is the multi_gradient_fill symbol
        :param ramp_number: the index number of the color-ramp
        :param color_range: the existing color_range
        :param radial_fill: This declares if the gradient has a radial fill
        :param symbol_properties: symbol_properties as dictionary
        :return: the actual color_range of a ramp
        """
        colors = FeatureGradientFillSymbol.get_colors_from_ramp(
            multi_gradient_fill.Ramp[ramp_number - 1])
        color_range_for_ramp = 1.0 / multi_gradient_fill.NumberOfRamps

        if len(colors) == 2:
            step_size = color_range_for_ramp
        else:
            step_size = color_range_for_ramp / len(colors)

        if radial_fill:
            colors.reverse()

        for color in colors:
            if radial_fill:
                if color == colors[
                        0] and ramp_number == multi_gradient_fill.NumberOfRamps:
                    symbol_properties['dict_symbols'][
                        'color1'] = convert_int_to_rgb_string(color.RGB)
                if color == colors[-1] and ramp_number == 1:
                    symbol_properties['dict_symbols'][
                        'color2'] = convert_int_to_rgb_string(color.RGB)
            else:
                if color == colors[0] and ramp_number == 1:
                    symbol_properties['dict_symbols'][
                        'color1'] = convert_int_to_rgb_string(color.RGB)
                if color == colors[
                        -1] and ramp_number == multi_gradient_fill.NumberOfRamps:
                    symbol_properties['dict_symbols'][
                        'color2'] = convert_int_to_rgb_string(color.RGB)

            symbol_properties['dict_symbols']['stops'] += "{};{}:".format(
                color_range, convert_int_to_rgb_string(color.RGB))

            if color in colors[:-1]:
                color_range += step_size
            else:
                # This is hacky stuff to support hard borders between multiple ColorRamps O_o
                # If element is last element of a colorRamp make short step after it to have a hard border to the next.
                # No Step after last element of last colorRamp as well
                if ramp_number != multi_gradient_fill.NumberOfRamps or radial_fill and ramp_number != 1:
                    color_range += 0.01

        return color_range
コード例 #4
0
    def get_background(formatted_symbol, label_dict):
        """
        This function writes the background specifications in the label_dict if background exists
        :param formatted_symbol: the text-symbol
        :param label_dict: the label dictionary including all the label properties
        """

        # implement when possible in qgis
        # balloon_callout_background = change_interface(
        #     formatted_symbol.Background,
        #     ArcGisModules.module_display.IBalloonCallout
        # )

        line_callout_background = change_interface(
            formatted_symbol.Background,
            ArcGisModules.module_display.ILineCallout)

        marker_text_background = change_interface(
            formatted_symbol.Background,
            ArcGisModules.module_display.IMarkerTextBackground)

        if marker_text_background:
            label_dict['labelValues']['background']['subsymbol'] = {}
            SymbolPropertiesProvider.get_point_properties(
                label_dict['labelValues']['background']['subsymbol'],
                marker_text_background.Symbol)
            label_dict['labelValues']['background']['shapeType'] = "5"
            label_dict['labelValues']['background']['shapeDraw'] = "1"
        elif line_callout_background:
            try:
                formatted_symbol_callout_margin = change_interface(
                    formatted_symbol.Background,
                    ArcGisModules.module_display.ITextMargins)
                label_dict['labelValues']['background'][
                    'shapeFillColor'] = convert_int_to_rgb_string(
                        line_callout_background.Border.Color.RGB)
                label_dict['labelValues']['background'][
                    'shapeBorderColor'] = convert_int_to_rgb_string(
                        line_callout_background.Border.Outline.Color.RGB)
                label_dict['labelValues']['background'][
                    'shapeBorderWidth'] = str(
                        line_callout_background.Border.Outline.Width)
                label_dict['labelValues']['background']['shapeSizeX'] = str(
                    int(formatted_symbol_callout_margin.LeftMargin) * 2)
                label_dict['labelValues']['background']['shapeSizeY'] = str(
                    int(formatted_symbol_callout_margin.TopMargin) * 2)
                label_dict['labelValues']['background']['shapeDraw'] = "1"
            except ValueError:
                label_dict['labelValues']['background']['shapeDraw'] = "0"

        else:
            pass
コード例 #5
0
    def create_feature_gradient_fill_symbol(i_symbol):
        """ This collects all properties of a gradient fill symbol and returns a dictionary of them

        :param i_symbol: the symbol to investigate
        :return: symbol_properties as dictionary
        """
        fill_dict = copy.deepcopy(SingleSymbol.propDict)
        symbol_properties = {
            'simpleSymbolClass': "GradientFill",
            'dict_symbols': fill_dict,
        }

        layer_color = convert_int_to_rgb_string(i_symbol.Color.RGB)
        symbol_properties['dict_symbols']['color'] = layer_color

        angle = i_symbol.GradientAngle + 270.0
        if angle >= 360:
            symbol_properties['dict_symbols']['angle'] = str(angle - 360)
        else:
            symbol_properties['dict_symbols']['angle'] = str(angle)

        symbol_properties['dict_symbols'][
            'type'] = SingleSymbol.gradient_style[i_symbol.Style]
        if i_symbol.Style == 1 | i_symbol.Style == 3:
            arcpy.AddWarning(
                "Rectangular and buffered gradient is not supported by QGIS")

        radial_fill = False

        if symbol_properties['dict_symbols']['type'] == "1":
            symbol_properties['dict_symbols'][
                "reference_point1_iscentroid"] = "1"
            symbol_properties['dict_symbols']["reference_point2"] = "1,1"
            radial_fill = True  # QGIS radial_fill works in the other direction of the ColorRamp

        symbol_properties['dict_symbols']['rampType'] = "gradient"
        symbol_properties['dict_symbols']['discrete'] = "0"
        symbol_properties['dict_symbols']['spread'] = "0"

        symbol_properties['dict_symbols']['outline_color'] = str(
            convert_int_to_rgb_string(i_symbol.Outline.Color.RGB))
        symbol_properties['dict_symbols']['outline_width'] = str(
            i_symbol.Outline.Width)

        FeatureGradientFillSymbol.create_color_ramp_properties(
            i_symbol.ColorRamp, radial_fill, symbol_properties)

        return symbol_properties
コード例 #6
0
ファイル: lineSymbol.py プロジェクト: WhereGroup/mapqonverter
    def create_feature_line_symbol(i_symbol):
        """ This collects all properties of a line symbol and returns a dictionary of them

        :param i_symbol: the symbol to investigate
        :return: the symbol_properties as dictionary
        """
        line_dict = copy.deepcopy(SingleSymbol.propDict)
        symbol_properties = {
            'simpleSymbolClass': "SimpleLine",
            'dict_symbols': line_dict,
        }

        line_symbol_types = LineSymbol.get_line_symbol_types(i_symbol)

        for line_type, line_symbol in line_symbol_types.items():
            LineSymbol.dict_line_creation[line_type](line_symbol, symbol_properties)

        LineSymbol.create_line_properties(i_symbol, symbol_properties)

        basic_line_symbol = change_interface(i_symbol, ArcGisModules.module_display.ILineSymbol)
        if basic_line_symbol.Color.NullColor:
            symbol_properties['dict_symbols']['line_style'] = 'no'
        try:
            layer_color = convert_int_to_rgb_string(basic_line_symbol.Color.RGB)
        except ValueError:
            layer_color = '0,0,0,255'
            arcpy.AddWarning(
                "\t\tError occured while rendering color. Default color is none."
            )
        symbol_properties['dict_symbols']['line_color'] = layer_color
        symbol_properties['dict_symbols']['line_width'] = basic_line_symbol.Width

        return symbol_properties
コード例 #7
0
    def create_feature_marker_fill_symbol(i_symbol):
        """ This collects all properties of a marker fill symbol and returns a dictionary of them

        :param i_symbol: the symbol to investigate
        :return: symbol_properties as dictionary
        """
        fill_dict = copy.deepcopy(SingleSymbol.propDict)
        symbol_properties = {
            'simpleSymbolClass': "RandomMarkerFill",
            'dict_symbols': fill_dict,
        }
        layer_color = convert_int_to_rgb_string(
            i_symbol.MarkerSymbol.Color.RGB)
        symbol_properties['dict_symbols']['color'] = layer_color
        symbol_properties['dict_symbols']['clip_points'] = '1'
        symbol_properties['dict_symbols']['count_method'] = '1'
        symbol_properties['dict_symbols']['density_area'] = '250'
        symbol_properties['dict_symbols']['density_area_unit'] = 'MM'
        symbol_properties['dict_symbols'][
            'density_area_scale'] = '3x:0,0,0,0,0,0'
        symbol_properties['dict_symbols']['point_count'] = '10'
        symbol_properties['dict_symbols']['seed'] = '48648189'

        SubSymbolProvider.create_sub_symbol(symbol_properties, 'marker')

        from renderer.feature.symbols.symbolPropertiesProvider import SymbolPropertiesProvider
        SymbolPropertiesProvider.get_point_properties(
            symbol_properties['subSymbol'], i_symbol.MarkerSymbol)

        return symbol_properties
コード例 #8
0
    def create_feature_simple_fill_symbol(i_symbol):
        """ This collects all properties of a simple fill symbol and returns a dictionary of them

        :param i_symbol: the symbol to investigate
        :return: the symbol_properties as dictionary
        """
        fill_dict = copy.deepcopy(SingleSymbol.propDict)
        symbol_properties = {
            'simpleSymbolClass': "SimpleFill",
            'dict_symbols': fill_dict
        }

        fill_symbol = change_interface(
            i_symbol, ArcGisModules.module_display.IFillSymbol)

        try:
            layer_color = convert_int_to_rgb_string(fill_symbol.Color.RGB)
            if fill_symbol.Color.NullColor:
                symbol_properties['dict_symbols']['style'] = "no"
            else:
                symbol_properties['dict_symbols']['style'] = "solid"
        except ValueError:
            layer_color = '0,0,0,255'
            symbol_properties['dict_symbols']['style'] = "solid"
            arcpy.AddWarning(
                "\t\tError occured while render color. Default Color is black. Default style is solid."
            )

        symbol_properties['dict_symbols']['color'] = layer_color

        if fill_symbol.Outline:
            simple_outline = change_interface(
                fill_symbol.Outline,
                ArcGisModules.module_display.ISimpleLineSymbol)
            if simple_outline:
                if fill_symbol.Outline.Color.NullColor:
                    symbol_properties['dict_symbols']['outline_style'] = "no"
                else:
                    symbol_properties['dict_symbols']['outline_style'] = \
                        SingleSymbol.simple_line_style_dict[simple_outline.Style]
            symbol_properties['dict_symbols'][
                'outline_color'] = convert_int_to_rgb_string(
                    fill_symbol.Outline.Color.RGB)
            symbol_properties['dict_symbols'][
                'outline_width'] = fill_symbol.Outline.Width

        return symbol_properties
コード例 #9
0
    def create_feature_marker_fill_symbol(i_symbol):
        """ This collects all properties of a marker fill symbol and returns a dictionary of them

        :param i_symbol: the symbol to investigate
        :return: symbol_properties as dictionary
        """
        fill_dict = copy.deepcopy(SingleSymbol.propDict)
        symbol_properties = {
            'simpleSymbolClass': "PointPatternFill",
            'dict_symbols': fill_dict,
        }
        layer_color = convert_int_to_rgb_string(
            i_symbol.MarkerSymbol.Color.RGB)
        symbol_properties['dict_symbols']['color'] = layer_color

        fill_properties = change_interface(
            i_symbol, ArcGisModules.module_display.IFillProperties)

        symbol_properties['dict_symbols']['offset_x'] = str(
            fill_properties.XOffset)
        symbol_properties['dict_symbols']['offset_y'] = str(
            fill_properties.YOffset)
        symbol_properties['dict_symbols']['offset_x_unit'] = "Pixel"
        symbol_properties['dict_symbols']['offset_y_unit'] = "Pixel"

        symbol_properties['dict_symbols']['distance_x'] = str(
            fill_properties.XSeparation)
        symbol_properties['dict_symbols']['distance_y'] = str(
            fill_properties.YSeparation)
        symbol_properties['dict_symbols']['distance_x_unit'] = "Pixel"
        symbol_properties['dict_symbols']['distance_y_unit'] = "Pixel"

        symbol_properties['dict_symbols']['outline_color'] = str(
            convert_int_to_rgb_string(i_symbol.Outline.Color.RGB))
        symbol_properties['dict_symbols']['outline_width'] = str(
            i_symbol.Outline.Width)

        SubSymbolProvider.create_sub_symbol(symbol_properties, 'marker')

        from renderer.feature.symbols.symbolPropertiesProvider import SymbolPropertiesProvider
        SymbolPropertiesProvider.get_point_properties(
            symbol_properties['subSymbol'], i_symbol.MarkerSymbol)

        return symbol_properties
コード例 #10
0
    def write_solo_gradient_colors_in_dict(color_ramp, radial_fill,
                                           symbol_properties):
        """This writes the the color-range of the used color-ramp of a multi_gradient_fill_symbol

        :param color_ramp: The Color Ramp Symbol
        :param radial_fill: This declares if the gradient has a radial fill - boolean
        :param symbol_properties: symbol_properties as dictionary
        """
        colors = FeatureGradientFillSymbol.get_colors_from_ramp(color_ramp)
        first_color = convert_int_to_rgb_string(colors[0].RGB)
        second_color = convert_int_to_rgb_string(colors[1].RGB)

        color1 = first_color
        color2 = second_color
        if radial_fill:
            color1 = second_color
            color2 = first_color

        symbol_properties['dict_symbols']['color'] = color1
        symbol_properties['dict_symbols']['color1'] = color1
        symbol_properties['dict_symbols']['color2'] = color2
        symbol_properties['dict_symbols']['gradient_color2'] = color2

        random_color_ramp = change_interface(
            color_ramp, ArcGisModules.module_display.IRandomColorRamp)
        if random_color_ramp:
            symbol_properties['dict_symbols']['discrete'] = "1"
        else:
            symbol_properties['dict_symbols']['color_type'] = "0"
        color_range = 0.0
        if color_ramp.Size == 0 and not random_color_ramp:
            step_size = 0.5
        else:
            step_size = 1.0 / len(colors)
        if radial_fill:
            colors.reverse()
        for colorNumber, color in enumerate(colors):
            symbol_properties['dict_symbols']['stops'] += "{};{}".format(
                color_range, convert_int_to_rgb_string(color.RGB))
            if colorNumber != len(colors):
                symbol_properties['dict_symbols']['stops'] += ":"
            color_range += step_size
コード例 #11
0
ファイル: layoutItem.py プロジェクト: WhereGroup/mapqonverter
 def create_frame_element(self, layout_item_element, frame_color=0):
     """
     This function creates the frame for a layout-item
     :param layout_item_element: the layout-item as a dom object
     :param frame_color: the color of the frame, default is black
     :return:
     """
     frame_colors = convert_int_to_rgb_string(frame_color).split(",")
     frame_color_element = self.dom.createElement("FrameColor")
     frame_color_element.setAttribute('red', frame_colors[0])
     frame_color_element.setAttribute('green', frame_colors[1])
     frame_color_element.setAttribute('blue', frame_colors[2])
     frame_color_element.setAttribute('alpha', frame_colors[3])
     layout_item_element.appendChild(frame_color_element)
コード例 #12
0
ファイル: layoutItem.py プロジェクト: WhereGroup/mapqonverter
 def create_background_element(self,
                               layout_item_element,
                               background_color=16777215):
     """
     This function creates the background for a layout-item
     :param layout_item_element: the layout-item as a dom object
     :param background_color: the color of the background, default is white
     :return:
     """
     background_colors = convert_int_to_rgb_string(background_color).split(
         ",")
     background_color_element = self.dom.createElement("BackgroundColor")
     background_color_element.setAttribute('red', background_colors[0])
     background_color_element.setAttribute('green', background_colors[1])
     background_color_element.setAttribute('blue', background_colors[2])
     background_color_element.setAttribute('alpha', background_colors[3])
     layout_item_element.appendChild(background_color_element)
コード例 #13
0
    def create_text_content(self, layout_item_base_element):
        """
        This function creats the Text-item specific content
        :param layout_item_base_element: the layout element in the DOM
        """
        arcpy_item = LayoutItem.get_arcpy_layout_element(
            self, self.layout_item_object)
        LayoutItemText.set_size_and_position(self, layout_item_base_element,
                                             arcpy_item)

        font_symbol = self.text_object.Symbol

        layout_item_base_element.setAttribute("frame", "false")
        layout_item_base_element.setAttribute("background", "false")
        layout_item_base_element.setAttribute("type", "65641")
        layout_item_base_element.setAttribute("labelText", font_symbol.Text)
        layout_item_base_element.setAttribute("marginX", "0")
        layout_item_base_element.setAttribute("marginY", "0")
        layout_item_base_element.setAttribute(
            "halign", TextSymbol.textSymbolHorizontalAlign[
                font_symbol.HorizontalAlignment])
        layout_item_base_element.setAttribute(
            "valign",
            TextSymbol.textSymbolVerticalAlign[font_symbol.VerticalAlignment])

        LayoutItemText.set_uuid_attributes(arcpy_item.text[:5],
                                           layout_item_base_element)
        label_font_description = LayoutItemText.get_label_font_description(
            font_symbol)

        label_font_element = self.dom.createElement("LabelFont")
        label_font_element.setAttribute("description", label_font_description)
        layout_item_base_element.appendChild(label_font_element)

        font_color = convert_int_to_rgb_string(
            font_symbol.Color.RGB).split(",")
        font_color_element = self.dom.createElement("FontColor")
        font_color_element.setAttribute('red', font_color[0])
        font_color_element.setAttribute('green', font_color[1])
        font_color_element.setAttribute('blue', font_color[2])
        font_color_element.setAttribute('alpha', font_color[3])
        layout_item_base_element.appendChild(font_color_element)
コード例 #14
0
    def create_north_arrow_content(self, layout_item_base_element):
        """
        This function creats the northArrow-item specific content
        :param layout_item_base_element: the layout element in the DOM
        """
        border = self.north_arrow_object.Border
        background = self.north_arrow_object.Background

        NorthArrowElement.create_background_and_frame(self, border, background, layout_item_base_element)

        arcpy_item = LayoutItem.get_arcpy_layout_element(self, self.layout_item_object)
        NorthArrowElement.set_size_and_position(self, layout_item_base_element, arcpy_item)

        NorthArrowElement.set_uuid_attributes(self.layout_item_object.MapSurround.Name, layout_item_base_element)

        layout_item_base_element.setAttribute('file', ":/images/north_arrows/layout_default_north_arrow.svg")
        layout_item_base_element.setAttribute('type', "65640")
        north_arrow = change_interface(self.north_arrow_object.MapSurround, ArcGisModules.module_carto.INorthArrow)
        layout_item_base_element.setAttribute('northOffset', unicode(north_arrow.CalibrationAngle))
        layout_item_base_element.setAttribute('svgBorderColor', convert_int_to_rgb_string(north_arrow.Color.RGB))
        layout_item_base_element.setAttribute('svgFillColor', "255,255,255,255")
コード例 #15
0
    def create_character_marker_symbol(character_symbol):
        marker_dict = copy.deepcopy(SingleSymbol.propDict)
        symbol_properties = {
            'simpleSymbolClass': "FontMarker",
            'dict_symbols': marker_dict
        }

        font = character_symbol.Font.Name
        character = unichr(character_symbol.CharacterIndex)

        symbol_properties['dict_symbols']['font'] = font
        symbol_properties['dict_symbols']['chr'] = character
        symbol_properties['dict_symbols'][
            'angle'] = character_symbol.Angle * -1
        symbol_properties['dict_symbols']['size'] = character_symbol.Size
        symbol_properties['dict_symbols']['offset'] = '{},{}'.format(
            character_symbol.XOffset, character_symbol.YOffset)

        symbol_properties['dict_symbols']['color'] = convert_int_to_rgb_string(
            character_symbol.Color.RGB)

        return symbol_properties
コード例 #16
0
    def create_scale_bar_content(self, layout_item_base_element):
        """
        This function creats the ScaleBar-item specific content
        :param layout_item_base_element: the layout element in the DOM
        """

        border = self.scale_bar_object.Border
        background = self.scale_bar_object.Background

        ScaleBarElement.create_background_and_frame(self, border, background,
                                                    layout_item_base_element)

        arcpy_item = LayoutItem.get_arcpy_layout_element(
            self, self.layout_item_object)
        ScaleBarElement.set_size_and_position(self, layout_item_base_element,
                                              arcpy_item)

        scale_bar = change_interface(self.scale_bar_object.MapSurround,
                                     ArcGisModules.module_carto.IScaleBar)
        scale_marks = change_interface(self.scale_bar_object.MapSurround,
                                       ArcGisModules.module_carto.IScaleMarks)

        layout_item_base_element.setAttribute('unitType',
                                              dict_units[scale_bar.Units])
        layout_item_base_element.setAttribute('unitLabel', scale_bar.UnitLabel)

        ScaleBarElement.set_uuid_attributes(
            self.layout_item_object.MapSurround.Name, layout_item_base_element)

        try:
            layout_item_base_element.setAttribute(
                'mapUuid',
                unicode(LayoutUuidProvider.uuid_dict[
                    self.layout_item_object.MapSurround.Map.Name]))
        except KeyError:
            LayoutUuidProvider.create_uuid(
                self.layout_item_object.MapSurround.Map.Name)
            layout_item_base_element.setAttribute(
                'mapUuid',
                unicode(LayoutUuidProvider.uuid_dict[
                    self.layout_item_object.MapSurround.Map.Name]))

        layout_item_base_element.setAttribute('type', "65646")
        layout_item_base_element.setAttribute(
            'numSegments',
            unicode(scale_bar.Divisions - scale_bar.DivisionsBeforeZero))
        if scale_bar.DivisionsBeforeZero > 0:
            layout_item_base_element.setAttribute(
                'numSegmentsLeft', unicode(scale_bar.Subdivisions))
        else:
            layout_item_base_element.setAttribute('numSegmentsLeft', '0')
        layout_item_base_element.setAttribute('numUnitsPerSegment',
                                              unicode(scale_bar.Division))
        layout_item_base_element.setAttribute(
            'labelVerticalPlacement',
            dict_vertical_position[scale_bar.LabelPosition])
        layout_item_base_element.setAttribute('labelBarSpace',
                                              unicode(scale_bar.LabelGap))
        if str(scale_bar.Name).startswith('Double'):
            layout_item_base_element.setAttribute('style', "Double Box")
        else:
            layout_item_base_element.setAttribute('style', "Single Box")

        scale_line = change_interface(scale_bar,
                                      ArcGisModules.module_carto.IScaleLine)
        if scale_line:
            num_segments = unicode(
                (scale_bar.Divisions - scale_bar.DivisionsBeforeZero) *
                scale_bar.Subdivisions
            ) if scale_bar.Subdivisions > 0 else unicode(
                scale_bar.Divisions - scale_bar.DivisionsBeforeZero)
            layout_item_base_element.setAttribute('numSegments', num_segments)
            num_units_per_segment = unicode(scale_bar.Division / scale_bar.Subdivisions) \
                if not scale_bar.Subdivisions == 0 else unicode(scale_bar.Division)
            layout_item_base_element.setAttribute(
                'numUnitsPerSegment', unicode(num_units_per_segment))
            layout_item_base_element.setAttribute(
                'style', dict_line_style[scale_marks.MarkPosition])

        double_fill_scale_bar = change_interface(
            scale_bar, ArcGisModules.module_carto.IDoubleFillScaleBar)

        if double_fill_scale_bar:
            fill_color_1 = convert_int_to_rgb_string(
                double_fill_scale_bar.FillSymbol1.Color.RGB).split(",")
            fill_color_2 = convert_int_to_rgb_string(
                double_fill_scale_bar.FillSymbol2.Color.RGB).split(",")
            if double_fill_scale_bar.FillSymbol1.Color.NullColor and double_fill_scale_bar.FillSymbol2.Color.NullColor:
                layout_item_base_element.setAttribute('style', 'hollow')

            symbol_properties_1 = {}
            fill_symbol_1_element = self.dom.createElement('fillSymbol1')
            SymbolPropertiesProvider.get_polygon_properties(
                symbol_properties_1, double_fill_scale_bar.FillSymbol1)
            SimpleSymbol.create_simple_symbol(self.dom, fill_symbol_1_element,
                                              symbol_properties_1, '', '1')
            layout_item_base_element.appendChild(fill_symbol_1_element)

            symbol_properties_2 = {}
            fill_symbol_2_element = self.dom.createElement('fillSymbol2')
            SymbolPropertiesProvider.get_polygon_properties(
                symbol_properties_2, double_fill_scale_bar.FillSymbol2)
            SimpleSymbol.create_simple_symbol(self.dom, fill_symbol_2_element,
                                              symbol_properties_2, '', '1')
            layout_item_base_element.appendChild(fill_symbol_2_element)
        else:
            fill_color_1 = convert_int_to_rgb_string(
                scale_bar.BarColor.RGB).split(',')
            fill_color_2 = "255,255,255,255"

        fill_color_1_element = self.dom.createElement('fillColor')
        fill_color_1_element.setAttribute('red', fill_color_1[0])
        fill_color_1_element.setAttribute('green', fill_color_1[1])
        fill_color_1_element.setAttribute('blue', fill_color_1[2])
        fill_color_1_element.setAttribute('alpha', fill_color_1[3])
        layout_item_base_element.appendChild(fill_color_1_element)

        fill_color_2_element = self.dom.createElement('fillColor2')
        fill_color_2_element.setAttribute('red', fill_color_2[0])
        fill_color_2_element.setAttribute('green', fill_color_2[1])
        fill_color_2_element.setAttribute('blue', fill_color_2[2])
        fill_color_2_element.setAttribute('alpha', fill_color_2[3])
        layout_item_base_element.appendChild(fill_color_2_element)
コード例 #17
0
    def create_simple_marker_symbol(i_symbol):
        """ This collects all properties of a simple marker symbol and returns a dictionary of them

        :param i_symbol: the symbol to investigate
        :return: symbol_properties as dictionary
        """
        marker_dict = copy.deepcopy(SingleSymbol.propDict)
        symbol_properties = {
            'simpleSymbolClass': "SimpleMarker",
            'dict_symbols': marker_dict
        }

        symbol_marker = change_interface(
            i_symbol, ArcGisModules.module_display.IMarkerSymbol)

        try:
            multilayer_symbol = change_interface(
                i_symbol,
                ArcGisModules.module_display.IMultiLayerMarkerSymbol).Layer[0]
            symbol_simple_marker = change_interface(
                multilayer_symbol,
                ArcGisModules.module_display.ISimpleMarkerSymbol)
        except AttributeError:
            symbol_simple_marker = change_interface(
                i_symbol, ArcGisModules.module_display.ISimpleMarkerSymbol)

        if symbol_simple_marker:
            symbol_properties['dict_symbols'][
                'style'] = symbol_simple_marker.Style
            symbol_properties['dict_symbols'][
                'name'] = SingleSymbol.simple_marker_style_dict[
                    symbol_simple_marker.Style]
            if symbol_simple_marker.Outline:
                symbol_properties['dict_symbols']['outline_style'] = "solid"
                symbol_properties['dict_symbols'][
                    'outline_color'] = convert_int_to_rgb_string(
                        symbol_simple_marker.OutlineColor.RGB)
                symbol_properties['dict_symbols'][
                    'outline_width'] = symbol_simple_marker.OutlineSize
            else:
                symbol_properties['dict_symbols']['outline_style'] = "no"
            symbol_properties['dict_symbols']['offset'] = str(
                symbol_simple_marker.XOffset) + "," + str(
                    symbol_simple_marker.YOffset)

        try:
            symbol_properties['dict_symbols']['angle'] = symbol_marker.Angle
            symbol_properties['dict_symbols']['size'] = symbol_marker.Size
        except AttributeError:
            symbol_properties['dict_symbols']['angle'] = "0"
            symbol_properties['dict_symbols']['size'] = "1"

        try:
            layer_color = convert_int_to_rgb_string(symbol_marker.Color.RGB)
            if symbol_marker.Color.NullColor:
                symbol_properties['dict_symbols']['style'] = "no"
        except (ValueError, AttributeError):
            layer_color = '0,0,0,255'
            arcpy.AddWarning(
                "\t\tThere was an Error coloring the Layer. Default Color is black."
            )

        symbol_properties['dict_symbols']['color'] = layer_color

        return symbol_properties