Skip to content

Commit e51d77b

Browse files
committed
wip
1 parent 80bbc47 commit e51d77b

3 files changed

Lines changed: 76 additions & 1 deletion

File tree

cadastral.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,26 @@ def draw_north_arrow(self):
191191
height = (self._frame_coords[3] - self._frame_coords[1]) * 0.07
192192
self._drawer.draw_north_arrow(coord.easting, self._frame_coords[3] - height, height)
193193

194+
# for easting label
195+
width = (self._frame_coords[2] - self._frame_coords[0]) * 0.1
196+
197+
self._drawer.add_north_arrow_label((self._frame_coords[0], coord.northing),
198+
(self._frame_coords[0] + width, coord.northing), f"{coord.easting}mE",
199+
self.label_size)
200+
self._drawer.add_north_arrow_label((self._frame_coords[2], coord.northing),
201+
(self._frame_coords[2] - width, coord.northing), "",
202+
self.label_size)
203+
204+
# for northing label
205+
northing_label_y = self._frame_coords[1]
206+
if len(self.footers) > 0:
207+
northing_label_y = northing_label_y + ((self._frame_coords[3] - self._frame_coords[1]) * 0.25)
208+
209+
self._drawer.add_north_arrow_label((coord.easting, northing_label_y),
210+
(coord.easting, northing_label_y + height), f"{coord.northing}mN",
211+
self.label_size)
212+
self._drawer.draw_north_arrow_cross(coord.easting, coord.northing, self.beacon_size * 3)
213+
194214
def draw(self):
195215
# Draw elements
196216
self.draw_beacons()

dxf.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,44 @@ def draw_north_arrow(self, x: float, y: float, height: float = 100.0):
228228
(x, y),
229229
)
230230

231+
def add_north_arrow_label(self, start: Tuple[float, float], stop: Tuple[float, float], label: str = "", height: float = 100.0):
232+
height = height * self.scale
233+
x = start[0] * self.scale
234+
y = start[1] * self.scale
235+
stop_x = stop[0] * self.scale
236+
stop_y = stop[1] * self.scale
237+
238+
# add line
239+
self.msp.add_line((x, y), (stop_x, stop_y), dxfattribs={'color': 5})
240+
241+
if label:
242+
angle = math.degrees(math.atan2(stop_y - y, stop_x - x))
243+
244+
# add text at midpoint
245+
self.msp.add_text(
246+
label,
247+
dxfattribs={
248+
'height': height,
249+
'color': 5,
250+
'style': 'SURVEY_TEXT',
251+
'rotation': angle
252+
}
253+
).set_placement(
254+
(x, y),
255+
align=TextEntityAlignment.TOP_LEFT,
256+
)
257+
258+
def draw_north_arrow_cross(self, x: float, y: float, length: float = 100.0):
259+
x = x * self.scale
260+
y = y * self.scale
261+
length = length * self.scale
262+
263+
half = length / 2
264+
265+
# add cross lines
266+
self.msp.add_line((x - half, y), (x + half, y), dxfattribs={'color': 5})
267+
self.msp.add_line((x, y - half), (x, y + half), dxfattribs={'color': 5})
268+
231269
def draw_graphical_scale(self, x: float, y: float, length: float = 1000.0):
232270
X = x * self.scale
233271
Y = y * self.scale
@@ -614,7 +652,7 @@ def save(self, paper_size: str = "A4", orientation: str = "portrait"):
614652
url = upload_file(zip_path, folder="survey_plans", file_name=filename)
615653
if url is None:
616654
raise Exception("Upload failed")
617-
return url
655+
return "url"
618656

619657

620658

topographic.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,23 @@ def draw_north_arrow(self):
520520
height = (self._frame_coords[3] - self._frame_coords[1]) * 0.07
521521
self._drawer.draw_north_arrow(coord.easting, self._frame_coords[3] - height, height)
522522

523+
# for easting label
524+
width = (self._frame_coords[2] - self._frame_coords[0]) * 0.1
525+
526+
self._drawer.add_north_arrow_label((self._frame_coords[0], coord.northing), (self._frame_coords[0] + width, coord.northing), f"{coord.easting}mE", self.label_size)
527+
self._drawer.add_north_arrow_label((self._frame_coords[2], coord.northing),
528+
(self._frame_coords[2] - width, coord.northing), "",
529+
self.label_size)
530+
531+
# for northing label
532+
northing_label_y = self._frame_coords[1]
533+
if len(self.footers) > 0:
534+
northing_label_y = northing_label_y + ((self._frame_coords[3] - self._frame_coords[1]) * 0.25)
535+
536+
537+
self._drawer.add_north_arrow_label((coord.easting, northing_label_y), (coord.easting, northing_label_y + height), f"{coord.northing}mN", self.label_size)
538+
self._drawer.draw_north_arrow_cross(coord.easting, coord.northing, self.beacon_size * 3)
539+
523540
def draw(self):
524541
# Draw elements
525542
self.draw_beacons()

0 commit comments

Comments
 (0)