Skip to content

Commit

Permalink
Fix oversized point markers
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 9, 2024
1 parent 7115ebb commit 3a9e6db
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 27 deletions.
13 changes: 7 additions & 6 deletions felt/core/fsl_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,8 @@ def marker_line_to_fsl(
interval_pixels = FslConverter.convert_to_pixels(
layer.interval(), layer.intervalUnit(), context)
try:
marker_size = float(converted_layer['size'])
# FSL size is radius, not diameter
marker_size = float(converted_layer['size']) * 2
except TypeError:
continue

Expand Down Expand Up @@ -748,7 +749,7 @@ def simple_marker_to_fsl(

res = {
'color': color_str,
'size': size,
'size': size / 2, # FSL size is radius, not diameter
'strokeColor': FslConverter.color_to_fsl(layer.strokeColor(),
context) if has_stroke
else FslConverter.NULL_COLOR,
Expand Down Expand Up @@ -797,7 +798,7 @@ def ellipse_marker_to_fsl(

res = {
'color': color_str,
'size': size,
'size': size / 2, # FSL size is radius, not diameter
'strokeColor': FslConverter.color_to_fsl(layer.strokeColor(),
context)
if has_stroke else FslConverter.NULL_COLOR,
Expand Down Expand Up @@ -846,7 +847,7 @@ def svg_marker_to_fsl(

res = {
'color': color_str,
'size': size,
'size': size / 2, # FSL size is radius, not diameter
'strokeColor': FslConverter.color_to_fsl(layer.strokeColor(),
context)
if has_stroke else FslConverter.NULL_COLOR,
Expand Down Expand Up @@ -894,7 +895,7 @@ def font_marker_to_fsl(

res = {
'color': color_str,
'size': size,
'size': size / 2, # FSL size is radius, not diameter
'strokeColor': FslConverter.color_to_fsl(layer.strokeColor(),
context)
if has_stroke else FslConverter.NULL_COLOR,
Expand Down Expand Up @@ -937,7 +938,7 @@ def filled_marker_to_fsl(
layer.sizeUnit(), context)

res = {
'size': size,
'size': size / 2, # FSL size is radius, not diameter
'color': color_str or FslConverter.NULL_COLOR,
'strokeColor': stroke_color_str or FslConverter.NULL_COLOR,
}
Expand Down
42 changes: 21 additions & 21 deletions felt/test/test_fsl_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ def test_simple_marker_to_fsl(self):
self.assertEqual(
FslConverter.simple_marker_to_fsl(marker, conversion_context),
[{'color': 'rgb(120, 130, 140)',
'size': 19,
'size': 9.5,
'strokeColor': 'rgba(0, 0, 0, 0)',
'strokeWidth': 1}]
)
Expand All @@ -603,7 +603,7 @@ def test_simple_marker_to_fsl(self):
FslConverter.simple_marker_to_fsl(marker, conversion_context,
symbol_opacity=0.5),
[{'color': 'rgb(120, 130, 140)',
'size': 19,
'size': 9.5,
'opacity': 0.5,
'strokeColor': 'rgba(0, 0, 0, 0)',
'strokeWidth': 1}]
Expand All @@ -617,7 +617,7 @@ def test_simple_marker_to_fsl(self):
self.assertEqual(
FslConverter.simple_marker_to_fsl(marker, conversion_context),
[{'color': 'rgb(120, 130, 140)',
'size': 19,
'size': 9.5,
'strokeColor': 'rgb(255, 100, 0)',
'strokeWidth': 3}]
)
Expand All @@ -628,7 +628,7 @@ def test_simple_marker_to_fsl(self):
self.assertEqual(
FslConverter.simple_marker_to_fsl(marker, conversion_context),
[{'color': 'rgb(120, 130, 140)',
'size': 48,
'size': 24,
'strokeColor': 'rgb(255, 100, 0)',
'strokeWidth': 3}]
)
Expand Down Expand Up @@ -660,7 +660,7 @@ def test_ellipse_marker_to_fsl(self):
self.assertEqual(
FslConverter.ellipse_marker_to_fsl(marker, conversion_context),
[{'color': 'rgb(120, 130, 140)',
'size': 19,
'size': 9.5,
'strokeColor': 'rgba(0, 0, 0, 0)',
'strokeWidth': 1}]
)
Expand All @@ -669,7 +669,7 @@ def test_ellipse_marker_to_fsl(self):
FslConverter.ellipse_marker_to_fsl(marker, conversion_context,
symbol_opacity=0.5),
[{'color': 'rgb(120, 130, 140)',
'size': 19,
'size': 9.5,
'opacity': 0.5,
'strokeColor': 'rgba(0, 0, 0, 0)',
'strokeWidth': 1}]
Expand All @@ -683,7 +683,7 @@ def test_ellipse_marker_to_fsl(self):
self.assertEqual(
FslConverter.ellipse_marker_to_fsl(marker, conversion_context),
[{'color': 'rgb(120, 130, 140)',
'size': 19,
'size': 9.5,
'strokeColor': 'rgb(255, 100, 0)',
'strokeWidth': 3}]
)
Expand All @@ -696,7 +696,7 @@ def test_ellipse_marker_to_fsl(self):
self.assertEqual(
FslConverter.ellipse_marker_to_fsl(marker, conversion_context),
[{'color': 'rgb(120, 130, 140)',
'size': 48,
'size': 24,
'strokeColor': 'rgb(255, 100, 0)',
'strokeWidth': 3}]
)
Expand All @@ -705,7 +705,7 @@ def test_ellipse_marker_to_fsl(self):
self.assertEqual(
FslConverter.ellipse_marker_to_fsl(marker, conversion_context),
[{'color': 'rgb(120, 130, 140)',
'size': 69,
'size': 34.5,
'strokeColor': 'rgb(255, 100, 0)',
'strokeWidth': 3}]
)
Expand All @@ -731,7 +731,7 @@ def test_svg_marker_to_fsl(self):
self.assertEqual(
FslConverter.svg_marker_to_fsl(marker, conversion_context),
[{'color': 'rgb(120, 130, 140)',
'size': 19,
'size': 9.5,
'strokeColor': 'rgba(0, 0, 0, 0)',
'strokeWidth': 1.0}]
)
Expand All @@ -740,7 +740,7 @@ def test_svg_marker_to_fsl(self):
FslConverter.svg_marker_to_fsl(marker, conversion_context,
symbol_opacity=0.5),
[{'color': 'rgb(120, 130, 140)',
'size': 19,
'size': 9.5,
'opacity': 0.5,
'strokeColor': 'rgba(0, 0, 0, 0)',
'strokeWidth': 1.0}]
Expand All @@ -753,7 +753,7 @@ def test_svg_marker_to_fsl(self):
self.assertEqual(
FslConverter.svg_marker_to_fsl(marker, conversion_context),
[{'color': 'rgb(120, 130, 140)',
'size': 19,
'size': 9.5,
'strokeColor': 'rgb(255, 100, 0)',
'strokeWidth': 3}]
)
Expand All @@ -764,7 +764,7 @@ def test_svg_marker_to_fsl(self):
self.assertEqual(
FslConverter.svg_marker_to_fsl(marker, conversion_context),
[{'color': 'rgb(120, 130, 140)',
'size': 48,
'size': 24,
'strokeColor': 'rgb(255, 100, 0)',
'strokeWidth': 3}]
)
Expand All @@ -790,7 +790,7 @@ def test_font_marker_to_fsl(self):
self.assertEqual(
FslConverter.font_marker_to_fsl(marker, conversion_context),
[{'color': 'rgb(120, 130, 140)',
'size': 19,
'size': 9.5,
'strokeColor': 'rgba(0, 0, 0, 0)',
'strokeWidth': 1}]
)
Expand All @@ -799,7 +799,7 @@ def test_font_marker_to_fsl(self):
FslConverter.font_marker_to_fsl(marker, conversion_context,
symbol_opacity=0.5),
[{'color': 'rgb(120, 130, 140)',
'size': 19,
'size': 9.5,
'opacity': 0.5,
'strokeColor': 'rgba(0, 0, 0, 0)',
'strokeWidth': 1}]
Expand All @@ -812,7 +812,7 @@ def test_font_marker_to_fsl(self):
self.assertEqual(
FslConverter.font_marker_to_fsl(marker, conversion_context),
[{'color': 'rgb(120, 130, 140)',
'size': 19,
'size': 9.5,
'strokeColor': 'rgb(255, 100, 0)',
'strokeWidth': 3}]
)
Expand All @@ -823,7 +823,7 @@ def test_font_marker_to_fsl(self):
self.assertEqual(
FslConverter.font_marker_to_fsl(marker, conversion_context),
[{'color': 'rgb(120, 130, 140)',
'size': 48,
'size': 24,
'strokeColor': 'rgb(255, 100, 0)',
'strokeWidth': 3}]
)
Expand Down Expand Up @@ -862,7 +862,7 @@ def test_filled_marker(self):
self.assertEqual(
FslConverter.filled_marker_to_fsl(marker, conversion_context),
[{'color': 'rgb(0, 255, 0)',
'size': 8,
'size': 4,
'strokeColor': 'rgb(35, 35, 35)',
'strokeWidth': 11}]
)
Expand All @@ -873,7 +873,7 @@ def test_filled_marker(self):
self.assertEqual(
FslConverter.filled_marker_to_fsl(marker, conversion_context),
[{'color': 'rgb(0, 255, 0)',
'size': 8,
'size': 4,
'strokeColor': 'rgb(35, 35, 35)',
'strokeWidth': 3.0}]
)
Expand All @@ -882,7 +882,7 @@ def test_filled_marker(self):
FslConverter.filled_marker_to_fsl(marker, conversion_context,
symbol_opacity=0.5),
[{'color': 'rgb(0, 255, 0)',
'size': 8,
'size': 4,
'strokeColor': 'rgb(35, 35, 35)',
'opacity': 0.5,
'strokeWidth': 3.0}]
Expand All @@ -893,7 +893,7 @@ def test_filled_marker(self):
self.assertEqual(
FslConverter.filled_marker_to_fsl(marker, conversion_context),
[{'color': 'rgb(0, 255, 0)',
'size': 4,
'size': 2,
'strokeColor': 'rgb(35, 35, 35)',
'strokeWidth': 3.0}]
)
Expand Down

0 comments on commit 3a9e6db

Please sign in to comment.