Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resync symbol classes with licensed version #116

Merged
merged 2 commits into from
Nov 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions slyr_community/parser/objects/fill_symbol_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,15 +368,19 @@ def read(self, stream: Stream, version):
self.separation_x = stream.read_double('separation x')
self.separation_y = stream.read_double('separation y')

stream.read(16)
stream.read_double('dpi?') # , expected=(0, 9.014173228346458, 96))
stream.read_double('dpi?') # , expected=(0, 9.014173228346458, 96))

self.symbol_level = SymbolLayer.read_symbol_level(stream)

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

if version < 4:
return
if version >= 4:
stream.read_int('unknown', expected=0)
stream.read_ushort('unknown', expected=0)

stream.read(6)
if 4 < version < 8:
stream.read(4)
size = stream.read_int('picture size')
if size:
self.picture = Picture()
self.picture.content = stream.read(size)
10 changes: 9 additions & 1 deletion slyr_community/parser/objects/font.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ class Font(Object):
254: 'utf-8', # see https://tedwvc.wordpress.com/2019/09/09/new-utf-8-features-in-windows-10-1903/
# MAC_CHARSET? (77?)
# OEM_CHARSET (255)
# Guessed values
100: 'utf-8',
108: 'utf-8',
116: 'utf-8',
148: 'utf-8',
232: 'utf-8',
236: 'utf-8',
244: 'utf-8'
}

@staticmethod
Expand Down Expand Up @@ -92,4 +100,4 @@ def read(self, stream: Stream, version):
self.size = stream.read_int('font size') / 10000

name_length = stream.read_uchar('font name size')
self.font_name = stream.read(name_length).decode(Font.CHARSET_MAP[self.charset])
self.font_name = stream.read(name_length).decode(Font.CHARSET_MAP[self.charset]).strip()
13 changes: 7 additions & 6 deletions slyr_community/parser/objects/marker_symbol_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,20 @@ def read(self, stream: Stream, version):
self.rotate_with_transform = stream.read_ushort('rotate with transform') != 0

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

# lot of unknown stuff
stream.read_double('unknown 3', expected=0) # or object?
stream.read_double('unknown 4', expected=0) # or object?
stream.read_int('unknown 3a', expected=(0, 1))
stream.read_int('unknown 3b', expected=(0, 1))
stream.read_double('unknown 4', expected=0)

stream.read_int('font weight')
stream.read_int('unknown', expected=0)
stream.read_int('font size * 10000')

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')
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')


class ArrowMarkerSymbol(MarkerSymbolLayer):
Expand Down
2 changes: 1 addition & 1 deletion slyr_community/parser/objects/symbol_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ def read_symbol_level(stream: Stream):
Reads the symbol level from the stream
"""
# actually raster op
assert stream.read_int('terminator') == 13
stream.read_int('raster op', expected=13)
# symbol level of 0xffffffff = merge and join
return stream.read_int('symbol level')
40 changes: 24 additions & 16 deletions slyr_community/parser/objects/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,35 @@ class Units:
TIME_UNITS_DECADES = 9
TIME_UNITS_CENTURIES = 10

UNIT_TO_STRING_MAP = {
DISTANCE_UNKNOWN: 'unknown',
DISTANCE_INCHES: 'inches',
DISTANCE_POINTS: 'points',
DISTANCE_FEET: 'feet',
DISTANCE_YARDS: 'yards',
DISTANCE_MILES: 'miles',
DISTANCE_NAUTICAL_MILES: 'nautical_miles',
DISTANCE_MILLIMETERS: 'millimeters',
DISTANCE_CENTIMETERS: 'centimeters',
DISTANCE_METERS: 'meters',
DISTANCE_KILOMETERS: 'kilometers',
DISTANCE_DECIMAL_DEGREES: 'decimal_degrees',
DISTANCE_DECIMETERS: 'decimeters',
}

@staticmethod
def distance_unit_to_string(unit) -> Optional[str]:
"""
Converts a distance unit to a string representation
"""
unit_map = {
Units.DISTANCE_UNKNOWN: 'unknown',
Units.DISTANCE_INCHES: 'inches',
Units.DISTANCE_POINTS: 'points',
Units.DISTANCE_FEET: 'feet',
Units.DISTANCE_YARDS: 'yards',
Units.DISTANCE_MILES: 'miles',
Units.DISTANCE_NAUTICAL_MILES: 'nautical_miles',
Units.DISTANCE_MILLIMETERS: 'millimeters',
Units.DISTANCE_CENTIMETERS: 'centimeters',
Units.DISTANCE_METERS: 'meters',
Units.DISTANCE_KILOMETERS: 'kilometers',
Units.DISTANCE_DECIMAL_DEGREES: 'decimal_degrees',
Units.DISTANCE_DECIMETERS: 'decimeters',
}
return unit_map.get(unit, None)
return Units.UNIT_TO_STRING_MAP.get(unit, None)

@staticmethod
def string_to_distance_unit(unit: str):
"""
Converts a string to a distance unit
"""
return [k for k, v in Units.UNIT_TO_STRING_MAP.items() if v == unit][0]

@staticmethod
def time_unit_to_string(unit) -> Optional[str]:
Expand Down