Skip to content

Commit 0dbf2e2

Browse files
committed
main
1 parent b8ee501 commit 0dbf2e2

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

cadastral.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,16 @@ def add_leg_labels(self, leg, orientation: str):
9696

9797
# Offset text above/below the line
9898
normals = line_normals((leg.from_.easting, leg.from_.northing), (leg.to.easting, leg.to.northing), orientation)
99-
offset_distance = self._get_drawing_extent() * 0.02
99+
offset_distance = self._get_drawing_extent() * 0.04
100100
offset_inside_x = (normals[0][0] / math.hypot(*normals[0])) * offset_distance
101101
offset_inside_y = (normals[0][1] / math.hypot(*normals[0])) * offset_distance
102102
offset_outside_x = (normals[1][0] / math.hypot(*normals[1])) * offset_distance
103103
offset_outside_y = (normals[1][1] / math.hypot(*normals[1])) * offset_distance
104104

105105
first_x += offset_outside_x; first_y += offset_outside_y
106106
last_x += offset_outside_x; last_y += offset_outside_y
107-
mid_x += offset_inside_x; mid_y += offset_inside_y
107+
mid_x += offset_inside_x; mid_y += offset_inside_y
108+
108109

109110
# Text angle adjustment
110111
text_angle = angle_deg
@@ -116,7 +117,7 @@ def add_leg_labels(self, leg, orientation: str):
116117
angle=text_angle, height=self.label_size)
117118
ld = line_direction(angle_deg)
118119
if ld == "left → right":
119-
# self._drawer.add_label_mtext(f"{format_number(leg.bearing.degrees, "hundredth")}° {format_number(leg.bearing.minutes, "tenth")}'", mid_x, mid_y,
120+
# self._drawer.add_label_mtext(f"{format_number(leg.bearing.degrees, "hundredth")}° {format_number(leg.bearing.minutes, "tenth")}'", mid_x + offset_outside_x, mid_y + offset_outside_y,
120121
# angle=text_angle, height=self.label_size)
121122
self._drawer.add_label(f"{format_number(leg.bearing.degrees, "hundredth")}°", first_x, first_y,
122123
angle=text_angle, height=self.label_size)
@@ -212,7 +213,8 @@ def draw_north_arrow(self):
212213

213214
self._drawer.add_north_arrow_label((coord.easting, northing_label_y),
214215
(coord.easting, northing_label_y + height), f"{coord.northing}mN",
215-
self.label_size)
216+
self.label_size, "vertical")
217+
216218
self._drawer.draw_north_arrow_cross(coord.easting, coord.northing, self.beacon_size * 3)
217219

218220
def draw(self):

dxf.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def draw_north_arrow(self, x: float, y: float, height: float = 100.0):
323323
(x, y),
324324
)
325325

326-
def add_north_arrow_label(self, start: Tuple[float, float], stop: Tuple[float, float], label: str = "", height: float = 100.0):
326+
def add_north_arrow_label(self, start: Tuple[float, float], stop: Tuple[float, float], label: str = "", height: float = 100.0, orientation: str = "horizontal"):
327327
height = height * self.scale
328328
x = start[0] * self.scale
329329
y = start[1] * self.scale
@@ -333,6 +333,12 @@ def add_north_arrow_label(self, start: Tuple[float, float], stop: Tuple[float, f
333333
# add line
334334
self.msp.add_line((x, y), (stop_x, stop_y), dxfattribs={'color': 5})
335335

336+
placement_x = x + 1
337+
placement_y = y + 1
338+
339+
if orientation == "vertical":
340+
placement_x = x - 1
341+
336342
if label:
337343
angle = math.degrees(math.atan2(stop_y - y, stop_x - x))
338344

@@ -346,7 +352,7 @@ def add_north_arrow_label(self, start: Tuple[float, float], stop: Tuple[float, f
346352
'rotation': angle
347353
}
348354
).set_placement(
349-
(x + 1, y + 1),
355+
(placement_x, placement_y),
350356
align=TextEntityAlignment.TOP_LEFT,
351357
)
352358

layout.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ def _add_leg_labels(self, leg, orientation: str):
664664

665665
# Offset text above/below the line
666666
normals = line_normals((leg.from_.easting, leg.from_.northing), (leg.to.easting, leg.to.northing), orientation)
667-
offset_distance = self._get_drawing_extent() * 0.02
667+
offset_distance = self._get_drawing_extent() * 0.04
668668
offset_inside_x = (normals[0][0] / math.hypot(*normals[0])) * offset_distance
669669
offset_inside_y = (normals[0][1] / math.hypot(*normals[0])) * offset_distance
670670
offset_outside_x = (normals[1][0] / math.hypot(*normals[1])) * offset_distance
@@ -973,7 +973,7 @@ def draw_north_arrow(self):
973973

974974
self._drawer.add_north_arrow_label((coord.easting, northing_label_y),
975975
(coord.easting, northing_label_y + height), f"{coord.northing}mN",
976-
self.label_size)
976+
self.label_size, "vertical")
977977
self._drawer.draw_north_arrow_cross(coord.easting, coord.northing, self.beacon_size * 3)
978978

979979
def draw_beacons(self):

topographic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def add_leg_labels(self, leg, orientation: str):
137137

138138
# Offset text above/below the line
139139
normals = line_normals((leg.from_.easting, leg.from_.northing), (leg.to.easting, leg.to.northing), orientation)
140-
offset_distance = self._get_drawing_extent() * 0.02
140+
offset_distance = self._get_drawing_extent() * 0.04
141141
offset_inside_x = (normals[0][0] / math.hypot(*normals[0])) * offset_distance
142142
offset_inside_y = (normals[0][1] / math.hypot(*normals[0])) * offset_distance
143143
offset_outside_x = (normals[1][0] / math.hypot(*normals[1])) * offset_distance
@@ -537,7 +537,7 @@ def draw_north_arrow(self):
537537
northing_label_y = northing_label_y + ((self._frame_coords[3] - self._frame_coords[1]) * 0.2)
538538

539539

540-
self._drawer.add_north_arrow_label((coord.easting, northing_label_y), (coord.easting, northing_label_y + height), f"{coord.northing}mN", self.label_size)
540+
self._drawer.add_north_arrow_label((coord.easting, northing_label_y), (coord.easting, northing_label_y + height), f"{coord.northing}mN", self.label_size, "vertical")
541541
self._drawer.draw_north_arrow_cross(coord.easting, coord.northing, self.beacon_size * 3)
542542

543543
def draw(self):

0 commit comments

Comments
 (0)