Пример #1
0
    def read(self, stream: Stream, version):
        """
        Reads the decoration information
        """
        self.fixed_angle = not bool(stream.read_uchar())
        stream.log('detected {}'.format(
            'fixed angle' if self.fixed_angle else 'not fixed angle'))
        self.flip_first = bool(stream.read_uchar())
        stream.log('detected {}'.format(
            'flip first' if self.flip_first else 'no flip first'))
        self.flip_all = bool(stream.read_uchar())
        stream.log('detected {}'.format(
            'flip all' if self.flip_all else 'no flip all'))

        stream.read(2)  # unknown -- maybe includes position as ratio?

        self.marker = stream.read_object('marker')

        # next bit is the number of doubles coming next
        marker_number_positions = stream.read_uint('marker positions')

        # next bit is the positions themselves -- maybe we can infer this from the number of positions
        # alone. E.g. 2 positions = 0, 1. 3 positions = 0, 0.5, 1
        for _ in range(marker_number_positions):
            self.marker_positions.append(stream.read_double())
        stream.log('marker positions are {}'.format(self.marker_positions))
Пример #2
0
    def read(self, stream: Stream, version):
        stream.read_int('unknown')
        stream.read_int('unknown 2')

        self.file = stream.read_embedded_file('image')

        self.color_foreground = stream.read_object('color 1')
        self.color_background = stream.read_object('color 2')
        self.color_transparent = stream.read_object('color 3')

        self.angle = stream.read_double('angle')
        self.size = stream.read_double('size')
        self.x_offset = stream.read_double('x offset')
        self.y_offset = stream.read_double('y offset')

        stream.read_double('unknown')
        stream.read_double('unknown')

        stream.read_0d_terminator()
        self.swap_fb_gb = bool(stream.read_uchar('swap fgbg'))

        check = binascii.hexlify(stream.read(2))
        if check != b'ffff':
            raise UnreadableSymbolException(
                'Expected ffff at {}, got {}'.format(check,
                                                     hex(stream.tell() - 2)))

        # unknown
        stream.read(6)
Пример #3
0
    def read(self, stream: Stream, version):
        self.angle = stream.read_double('angle')
        self.cap = self.read_cap(stream)
        unknown = binascii.hexlify(stream.read(3))
        if unknown != b'000000':
            raise UnreadableSymbolException(
                'Differing unknown string {}'.format(unknown))
        self.join = self.read_join(stream)
        unknown = binascii.hexlify(stream.read(3))
        if unknown != b'000000':
            raise UnreadableSymbolException(
                'Differing unknown string {}'.format(unknown))
        self.width = stream.read_double('width')
        stream.read(1)
        self.offset = stream.read_double('offset')

        self.line = stream.read_object('line')

        self.color = stream.read_object('color')
        self.template = stream.read_object('template')

        self.decoration = stream.read_object('decoration')
        stream.read_0d_terminator()

        _ = stream.read_uchar('unknown char')
        _ = stream.read_double('unknown')
        _ = stream.read_double('unknown')
Пример #4
0
 def read_join(stream: Stream):
     """
     Reads a line join style from the stream
     """
     join_bin = stream.read_uchar()
     if join_bin == 0:
         return 'miter'
     elif join_bin == 1:
         return 'round'
     elif join_bin == 2:
         return 'bevel'
     else:
         raise UnreadableSymbolException('unknown join style {}'.format(join_bin))
Пример #5
0
 def read_cap(stream: Stream):
     """
     Reads a line cap style from the stream
     """
     cap_bin = stream.read_uchar()
     if cap_bin == 0:
         return 'butt'
     elif cap_bin == 1:
         return 'round'
     elif cap_bin == 2:
         return 'square'
     else:
         raise UnreadableSymbolException('unknown cap style {}'.format(cap_bin))
Пример #6
0
    def read(self, stream: Stream, version):
        version = binascii.hexlify(stream.read(1))
        if version != b'01':
            raise UnsupportedVersionException(
                'Unsupported Font version {}'.format(version))

        self.charset = stream.read_ushort('charset')

        # Not exposed in ArcMap front end:
        attributes = stream.read_uchar('attributes')
        self.italic = attributes & self.Italic
        self.underline = attributes & self.Underline
        self.strikethrough = attributes & self.Strikethrough

        self.weight = stream.read_ushort('weight')

        # From https://docs.microsoft.com/en-us/windows/desktop/api/olectl/ns-olectl-tagfontdesc
        # Use the int64 member of the CY structure and scale your font size (in points) by 10000.
        self.size = stream.read_int('font size') / 10000

        name_length = stream.read_uchar('font name size')
        self.font_name = stream.read(name_length).decode()
Пример #7
0
    def read(self, stream: Stream, version):
        self.color = stream.read_object('color')

        self.unicode = stream.read_int('unicode')
        self.angle = stream.read_double('angle')
        self.size = stream.read_double('size')
        self.x_offset = stream.read_double('x offset')
        self.y_offset = stream.read_double('y offset')

        stream.read_double('unknown 1')
        stream.read_double('unknown 2')

        if version == 2:
            self.std_font = stream.read_object('font')
            self.font = self.std_font.font_name

        stream.read_0d_terminator()
        if binascii.hexlify(stream.read(2)) != b'ffff':
            raise UnreadableSymbolException('Expected ffff')

        if version >= 3:
            self.font = stream.read_string('font name')

            # lot of unknown stuff
            stream.read_double('unknown 3')  # or object?
            stream.read_double('unknown 4')  # or object?

            stream.read_uchar('unknown')
            stream.read_uchar('unknown')

            stream.read(4)
            stream.read(6)

            if version >= 4:
                # std OLE font .. maybe contains useful stuff like bold/etc, but these aren't exposed in ArcGIS anyway..
                self.std_font = stream.read_object('font')
Пример #8
0
    def read(self, stream: Stream, version):
        if version == 4:
            self.picture = stream.read_object('picture')
        elif version == 7:
            _ = stream.read_ushort('pic version?')
            _ = stream.read_uint('picture type?')
            self.picture = stream.read_object('picture')
        elif version == 8:
            self.picture = stream.read_picture('picture')

        self.color_background = stream.read_object('color bg')
        self.color_foreground = stream.read_object('color fg')
        self.color_transparent = stream.read_object('color trans')

        # either an entire LineSymbol or just a LineSymbolLayer
        outline = stream.read_object('outline')
        if outline is not None:
            if issubclass(outline.__class__, SymbolLayer):
                self.outline_layer = outline
            else:
                self.outline_symbol = outline

        self.angle = stream.read_double('angle')
        self.scale_x = stream.read_double('scale_x')
        self.scale_y = stream.read_double('scale_y')

        self.offset_x = stream.read_double('offset x')
        self.offset_y = stream.read_double('offset y')
        self.separation_x = stream.read_double('separation x')
        self.separation_y = stream.read_double('separation y')

        stream.read(16)

        stream.read_0d_terminator()

        self.swap_fb_gb = bool(stream.read_uchar('swap fgbg'))

        if version <= 4:
            return

        stream.read(6)
        if version < 8:
            stream.read(4)
Пример #9
0
    def read(self, stream: Stream, version):
        self.color = stream.read_object('color')
        self.size = stream.read_double('size')

        type_code = stream.read_int()
        type_dict = {
            0: 'circle',
            1: 'square',
            2: 'cross',
            3: 'x',
            4: 'diamond'
        }

        if type_code not in type_dict:
            raise UnreadableSymbolException(
                'Unknown marker type at {}, got {}'.format(
                    hex(stream.tell() - 4), type_code))
        stream.log('found a {}'.format(type_dict[type_code]), 4)
        self.type = type_dict[type_code]

        # look for 0d terminator
        if not binascii.hexlify(stream.read(8)) == b'0d00000000000000':
            raise UnreadableSymbolException()

        stream.read_double('unknown')

        self.x_offset = stream.read_double('x offset')
        self.y_offset = stream.read_double('y offset')

        has_outline = stream.read_uchar()
        if has_outline == 1:
            self.outline_enabled = True
        self.outline_width = stream.read_double('outline width')
        self.outline_color = stream.read_object('outline color')

        check = binascii.hexlify(stream.read(2))
        if check != b'ffff':
            raise UnreadableSymbolException(
                'Expected ffff at {}, got {}'.format(check,
                                                     hex(stream.tell() - 2)))
Пример #10
0
    def read(self, stream: Stream, version):
        if version in (4, 5):
            self.picture = stream.read_object('picture')
        elif version == 8:
            _ = stream.read_ushort('pic version?')
            _ = stream.read_uint('picture type?')
            self.picture = stream.read_object('picture')
        elif version == 9:
            self.picture = stream.read_picture('picture')

        if version <= 8:
            _ = stream.read_object()

        self.color_foreground = stream.read_object('color 1')
        self.color_background = stream.read_object('color 2')

        if version >= 9:
            self.color_transparent = stream.read_object('color 3')

        self.angle = stream.read_double('angle')
        self.size = stream.read_double('size')
        self.x_offset = stream.read_double('x offset')
        self.y_offset = stream.read_double('y offset')

        stream.read_double('unknown')
        stream.read_double('unknown')

        stream.read_0d_terminator()
        self.swap_fb_gb = bool(stream.read_uchar('swap fgbg'))

        check = binascii.hexlify(stream.read(2))
        if check != b'ffff':
            raise UnreadableSymbolException('Expected ffff at {}, got {}'.format(check, hex(stream.tell() - 2)))

        if version < 6:
            return

        stream.read(6)
        if version <= 8:
            stream.read(4)
Пример #11
0
    def read(self, stream: Stream, version):
        self.cap = self.read_cap(stream)
        stream.log('read cap of {}'.format(self.cap), 1)

        self.offset = stream.read_double('offset')
        self.pattern_marker = stream.read_object('pattern marker')
        self.template = stream.read_object('template')
        self.decoration = stream.read_object('decoration')

        stream.read_0d_terminator()

        _ = stream.read_double('unknown double')
        _ = stream.read_int('unknown int')
        _ = stream.read_uchar('unknown char')

        self.join = self.read_join(stream)
        unknown = binascii.hexlify(stream.read(3))
        if unknown != b'000000':
            raise UnreadableSymbolException(
                'Differing unknown string {}'.format(unknown))

        _ = stream.read_double('unknown double')