forked from jan/fatamorgana
Compare commits
No commits in common. "master" and "release" have entirely different histories.
2 changed files with 5 additions and 18 deletions
|
|
@ -1302,38 +1302,25 @@ def read_point_list(stream: io.BufferedIOBase) -> List[List[int]]:
|
||||||
"""
|
"""
|
||||||
list_type = read_uint(stream)
|
list_type = read_uint(stream)
|
||||||
list_len = read_uint(stream)
|
list_len = read_uint(stream)
|
||||||
|
#TODO: Implicit close point for 1del
|
||||||
if list_type == 0:
|
if list_type == 0:
|
||||||
points = []
|
points = []
|
||||||
dx, dy = 0, 0
|
|
||||||
for i in range(list_len):
|
for i in range(list_len):
|
||||||
point = [0, 0]
|
point = [0, 0]
|
||||||
n = read_sint(stream)
|
n = read_uint(stream)
|
||||||
if n == 0:
|
if n == 0:
|
||||||
raise InvalidDataError('Zero-sized 1-delta')
|
raise InvalidDataError('Zero-sized 1-delta')
|
||||||
point[i % 2] = n
|
point[i % 2] = n
|
||||||
points.append(point)
|
points.append(point)
|
||||||
if i % 2:
|
|
||||||
dy += n
|
|
||||||
else:
|
|
||||||
dx += n
|
|
||||||
points.append([-dx, 0])
|
|
||||||
points.append([0, -dy])
|
|
||||||
elif list_type == 1:
|
elif list_type == 1:
|
||||||
points = []
|
points = []
|
||||||
dx, dy = 0, 0
|
|
||||||
for i in range(list_len):
|
for i in range(list_len):
|
||||||
point = [0, 0]
|
point = [0, 0]
|
||||||
n = read_sint(stream)
|
n = read_uint(stream)
|
||||||
if n == 0:
|
if n == 0:
|
||||||
raise Exception('Zero-sized 1-delta')
|
raise Exception('Zero-sized 1-delta')
|
||||||
point[(i + 1) % 2] = n
|
point[(i + 1) % 2] = n
|
||||||
points.append(point)
|
points.append(point)
|
||||||
if i % 2:
|
|
||||||
dx += n
|
|
||||||
else:
|
|
||||||
dy += n
|
|
||||||
points.append([0, -dy])
|
|
||||||
points.append([-dx, 0])
|
|
||||||
elif list_type == 2:
|
elif list_type == 2:
|
||||||
points = [ManhattanDelta.read(stream).as_list() for _ in range(list_len)]
|
points = [ManhattanDelta.read(stream).as_list() for _ in range(list_len)]
|
||||||
elif list_type == 3:
|
elif list_type == 3:
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import zlib
|
||||||
import io
|
import io
|
||||||
import logging
|
import logging
|
||||||
import pprint
|
import pprint
|
||||||
from warnings import warn
|
|
||||||
from .basic import AString, NString, repetition_t, property_value_t, real_t, \
|
from .basic import AString, NString, repetition_t, property_value_t, real_t, \
|
||||||
ReuseRepetition, OffsetTable, Validation, read_point_list, read_property_value, \
|
ReuseRepetition, OffsetTable, Validation, read_point_list, read_property_value, \
|
||||||
read_bstring, read_uint, read_sint, read_real, read_repetition, read_interval, \
|
read_bstring, read_uint, read_sint, read_real, read_repetition, read_interval, \
|
||||||
|
|
@ -1630,7 +1630,7 @@ class Polygon(Record):
|
||||||
|
|
||||||
if point_list is not None:
|
if point_list is not None:
|
||||||
if len(point_list) < 3:
|
if len(point_list) < 3:
|
||||||
warn('Polygon with < 3 points')
|
raise InvalidDataError('Polygon with < 3 points')
|
||||||
|
|
||||||
def merge_with_modals(self, modals: Modals):
|
def merge_with_modals(self, modals: Modals):
|
||||||
adjust_coordinates(self, modals, 'geometry_x', 'geometry_y')
|
adjust_coordinates(self, modals, 'geometry_x', 'geometry_y')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue