Skip to content

Commit e638bf6

Browse files
committed
poly rendering: GRP 1.6 support
When coordpoly is set (aka TopSky mode), do things like we used to, otherwise only specify COLOR once, then separate polygons with COORDTYPE:OTHER:REGION
1 parent d73e329 commit e638bf6

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

mapbuilder/handlers/jinja.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def to_text_buffer(geometry, label: str, color: str, adapt_to_length=True):
103103
distance += 0.00001 * len(labeltext)
104104
buffer = shapely.buffer(point, distance).envelope.boundary
105105

106-
_render_polygon(lines, [buffer], color)
106+
_render_polygon(lines, [buffer], color, False)
107107

108108
return "\n".join(lines)
109109

@@ -181,21 +181,28 @@ def envelope(geometries):
181181
def to_poly(geometries, designator: str, color: str | None = None, coordpoly=False):
182182
lines = [f"// {designator}"] if designator else []
183183

184-
_render_polygon(lines, _get_geoms(geometries), color)
184+
_render_polygon(lines, _get_geoms(geometries), color, coordpoly)
185185

186186
if coordpoly:
187187
lines.extend((f"COORDPOLY:{coordpoly}", ""))
188188

189189
return "\n".join(lines)
190190

191191

192-
def _render_polygon(lines, polygons, color=None):
192+
def _render_polygon(lines, polygons, color=None, coordpoly=False):
193+
if not coordpoly and color is not None:
194+
lines.append(f"COLOR:{color}")
195+
else:
196+
lines.append("")
197+
193198
for polygon in polygons:
194-
if color is not None:
195-
lines.append(f"COLOR:{color}")
199+
if coordpoly:
200+
if color is not None:
201+
lines.append(f"COLOR:{color}")
202+
else:
203+
lines.append("")
196204
else:
197-
lines.append("")
198-
205+
lines.append("COORDTYPE:OTHER:REGION")
199206
for point in polygon.coords:
200207
lines.append(f"COORD:{coord2es((point[0], point[1]))}")
201208

0 commit comments

Comments
 (0)