libgd-gis 0.3.2 → 0.3.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gd/gis/layer_points.rb +27 -30
- data/lib/test.rb +1 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ae0d79550ce61b3bebaa90e48f7b57c5dd1f1fca8be67d857e41fd8fec69e75c
|
|
4
|
+
data.tar.gz: b37ff43e8f0a0dd9112ad256c46e3aa1154975ca737544eae761bec9d074ee32
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6272498890dd101132b00edcd65d63b023721afa2d18a77bb17919b53d6220927ff5d532803d1c24e726799ac3d7671b648d2979c38725880403d5cd5dc966be
|
|
7
|
+
data.tar.gz: 65464584707bb1c54bb8401c847a395ba646f94846d5897fe5e6b099c97d812616035d35770d3106860819ce0d318b8980b56c7e067ace39c683ed6a5fa18273
|
data/lib/gd/gis/layer_points.rb
CHANGED
|
@@ -50,7 +50,7 @@ module GD
|
|
|
50
50
|
if icon.is_a?(Array) || icon.nil?
|
|
51
51
|
fill, stroke = icon || [GD::GIS::ColorHelpers.random_rgb, GD::GIS::ColorHelpers.random_rgb]
|
|
52
52
|
@icon = build_default_marker(fill, stroke)
|
|
53
|
-
elsif
|
|
53
|
+
elsif %w[numeric alphabetic].include?(icon)
|
|
54
54
|
@icon = icon
|
|
55
55
|
@font_color = font_color
|
|
56
56
|
else
|
|
@@ -65,7 +65,6 @@ module GD
|
|
|
65
65
|
@r, @g, @b, @a = color
|
|
66
66
|
@a = 0 if @a.nil?
|
|
67
67
|
@count = count
|
|
68
|
-
|
|
69
68
|
end
|
|
70
69
|
|
|
71
70
|
# Builds a default circular marker icon.
|
|
@@ -100,18 +99,17 @@ module GD
|
|
|
100
99
|
#
|
|
101
100
|
# @return [void]
|
|
102
101
|
def render!(img, projector)
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
end
|
|
102
|
+
value = case @icon
|
|
103
|
+
when "numeric"
|
|
104
|
+
@count
|
|
105
|
+
when "alphabetic"
|
|
106
|
+
(@count + 96).chr
|
|
107
|
+
else
|
|
108
|
+
"*"
|
|
109
|
+
end
|
|
112
110
|
|
|
113
111
|
if @icon.is_a?(GD::Image)
|
|
114
|
-
w = @icon.width
|
|
112
|
+
w = @icon.width
|
|
115
113
|
h = @icon.height
|
|
116
114
|
else
|
|
117
115
|
w = radius_from_text(img, value, font: @font, size: @size) * 2
|
|
@@ -127,31 +125,31 @@ module GD
|
|
|
127
125
|
|
|
128
126
|
text = @label.call(row)
|
|
129
127
|
next if text.nil? || text.strip.empty?
|
|
128
|
+
|
|
130
129
|
font_h = @size * 1.1
|
|
131
130
|
|
|
132
131
|
if @icon == "numeric" || @icon == "alphabetic"
|
|
133
132
|
|
|
134
133
|
draw_symbol_circle!(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
)
|
|
134
|
+
img: img,
|
|
135
|
+
x: x,
|
|
136
|
+
y: y,
|
|
137
|
+
symbol: value,
|
|
138
|
+
bg_color: @color,
|
|
139
|
+
font_color: @font_color,
|
|
140
|
+
font: @font,
|
|
141
|
+
font_size: @size
|
|
142
|
+
)
|
|
145
143
|
else
|
|
146
144
|
img.copy(@icon, x - (w / 2), y - (h / 2), 0, 0, w, h)
|
|
147
145
|
end
|
|
148
146
|
|
|
149
147
|
img.text(text,
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
148
|
+
x: x + (w / 2) + 4,
|
|
149
|
+
y: y + (font_h / 2),
|
|
150
|
+
size: @size,
|
|
151
|
+
color: GD::Color.rgba(@r, @g, @b, @a),
|
|
152
|
+
font: @font)
|
|
155
153
|
end
|
|
156
154
|
end
|
|
157
155
|
|
|
@@ -159,7 +157,7 @@ module GD
|
|
|
159
157
|
#
|
|
160
158
|
# - x, y: circle center in pixels
|
|
161
159
|
# - y for text() is BASELINE (not top). We compute baseline to center the text.
|
|
162
|
-
def draw_symbol_circle!(img:, x:, y:, symbol:,
|
|
160
|
+
def draw_symbol_circle!(img:, x:, y:, symbol:, bg_color:, font_color:, font:, font_size:, angle: 0.0)
|
|
163
161
|
diameter = radius_from_text(img, symbol, font: font, size: font_size) * 2
|
|
164
162
|
|
|
165
163
|
# 1) Bullet background
|
|
@@ -203,9 +201,8 @@ module GD
|
|
|
203
201
|
)
|
|
204
202
|
|
|
205
203
|
# Use the larger dimension to ensure the text fits
|
|
206
|
-
(
|
|
204
|
+
([w, h].max / 2.0).ceil + padding
|
|
207
205
|
end
|
|
208
|
-
|
|
209
206
|
end
|
|
210
207
|
end
|
|
211
208
|
end
|
data/lib/test.rb
CHANGED