libgd-gis 0.3.3 → 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 +11 -14
- data/lib/gd/gis/map.rb +1 -91
- data/lib/gd/gis/style.rb +0 -5
- data/lib/test.rb +3 -0
- metadata +3 -2
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
|
@@ -40,19 +40,19 @@ module GD
|
|
|
40
40
|
size: 12,
|
|
41
41
|
color: [0, 0, 0],
|
|
42
42
|
font_color: nil,
|
|
43
|
-
|
|
43
|
+
count: 0
|
|
44
44
|
)
|
|
45
45
|
@data = data
|
|
46
46
|
@lon = lon
|
|
47
47
|
@lat = lat
|
|
48
48
|
@color = color
|
|
49
|
-
@font_color = font_color
|
|
50
49
|
|
|
51
50
|
if icon.is_a?(Array) || icon.nil?
|
|
52
51
|
fill, stroke = icon || [GD::GIS::ColorHelpers.random_rgb, GD::GIS::ColorHelpers.random_rgb]
|
|
53
52
|
@icon = build_default_marker(fill, stroke)
|
|
54
|
-
elsif %w[numeric alphabetic
|
|
53
|
+
elsif %w[numeric alphabetic].include?(icon)
|
|
55
54
|
@icon = icon
|
|
55
|
+
@font_color = font_color
|
|
56
56
|
else
|
|
57
57
|
@icon = GD::Image.open(icon)
|
|
58
58
|
@icon.alpha_blending = true
|
|
@@ -62,11 +62,9 @@ module GD
|
|
|
62
62
|
@label = label
|
|
63
63
|
@font = font
|
|
64
64
|
@size = size
|
|
65
|
-
|
|
66
65
|
@r, @g, @b, @a = color
|
|
67
66
|
@a = 0 if @a.nil?
|
|
68
|
-
|
|
69
|
-
@symbol = symbol
|
|
67
|
+
@count = count
|
|
70
68
|
end
|
|
71
69
|
|
|
72
70
|
# Builds a default circular marker icon.
|
|
@@ -103,13 +101,11 @@ module GD
|
|
|
103
101
|
def render!(img, projector)
|
|
104
102
|
value = case @icon
|
|
105
103
|
when "numeric"
|
|
106
|
-
@
|
|
104
|
+
@count
|
|
107
105
|
when "alphabetic"
|
|
108
|
-
(@
|
|
109
|
-
when "symbol"
|
|
110
|
-
@symbol
|
|
106
|
+
(@count + 96).chr
|
|
111
107
|
else
|
|
112
|
-
|
|
108
|
+
"*"
|
|
113
109
|
end
|
|
114
110
|
|
|
115
111
|
if @icon.is_a?(GD::Image)
|
|
@@ -132,7 +128,8 @@ module GD
|
|
|
132
128
|
|
|
133
129
|
font_h = @size * 1.1
|
|
134
130
|
|
|
135
|
-
if @icon == "numeric" || @icon == "alphabetic"
|
|
131
|
+
if @icon == "numeric" || @icon == "alphabetic"
|
|
132
|
+
|
|
136
133
|
draw_symbol_circle!(
|
|
137
134
|
img: img,
|
|
138
135
|
x: x,
|
|
@@ -151,7 +148,7 @@ module GD
|
|
|
151
148
|
x: x + (w / 2) + 4,
|
|
152
149
|
y: y + (font_h / 2),
|
|
153
150
|
size: @size,
|
|
154
|
-
color: @
|
|
151
|
+
color: GD::Color.rgba(@r, @g, @b, @a),
|
|
155
152
|
font: @font)
|
|
156
153
|
end
|
|
157
154
|
end
|
|
@@ -176,7 +173,7 @@ module GD
|
|
|
176
173
|
# baseline = top_y + h = y + h/2
|
|
177
174
|
text_x = (x - (w / 2.0)).round
|
|
178
175
|
text_y = (y + (h / 2.0)).round
|
|
179
|
-
|
|
176
|
+
|
|
180
177
|
# 4) Draw number
|
|
181
178
|
img.text(
|
|
182
179
|
text,
|
data/lib/gd/gis/map.rb
CHANGED
|
@@ -288,7 +288,7 @@ module GD
|
|
|
288
288
|
size: size,
|
|
289
289
|
color: color,
|
|
290
290
|
font_color: font_color,
|
|
291
|
-
|
|
291
|
+
count: @count
|
|
292
292
|
)
|
|
293
293
|
@count += 1
|
|
294
294
|
elsif LINE_GEOMS.include?(geom_type)
|
|
@@ -298,96 +298,6 @@ module GD
|
|
|
298
298
|
end
|
|
299
299
|
end
|
|
300
300
|
|
|
301
|
-
# Adds a single point (marker) to the map.
|
|
302
|
-
#
|
|
303
|
-
# This is a convenience helper for the most common use case: rendering
|
|
304
|
-
# one point with an optional label and icon, without having to build
|
|
305
|
-
# a full collection or manually configure a PointsLayer.
|
|
306
|
-
#
|
|
307
|
-
# Internally, this method wraps the given coordinates into a one-element
|
|
308
|
-
# data collection and delegates rendering to {GD::GIS::PointsLayer},
|
|
309
|
-
# preserving the same rendering behavior and options.
|
|
310
|
-
#
|
|
311
|
-
# This method is intended for annotations, markers, alerts, cities,
|
|
312
|
-
# or any scenario where only one point needs to be rendered.
|
|
313
|
-
#
|
|
314
|
-
# @param lon [Numeric]
|
|
315
|
-
# Longitude of the point.
|
|
316
|
-
# @param lat [Numeric]
|
|
317
|
-
# Latitude of the point.
|
|
318
|
-
# @param label [String, nil]
|
|
319
|
-
# Optional text label rendered next to the point.
|
|
320
|
-
# @param icon [String, Array<GD::Color>, nil]
|
|
321
|
-
# Marker representation. Can be:
|
|
322
|
-
# - a path to an image file
|
|
323
|
-
# - :numeric or :alphabetic symbol styles
|
|
324
|
-
# - an array of [fill, stroke] colors
|
|
325
|
-
# - nil to generate a default marker
|
|
326
|
-
# @param font [String, nil]
|
|
327
|
-
# Font path used to render the label or symbol.
|
|
328
|
-
# @param size [Integer]
|
|
329
|
-
# Font size in pixels (default: 12).
|
|
330
|
-
# @param color [Array<Integer>]
|
|
331
|
-
# Label or symbol background color as an RGB(A) array.
|
|
332
|
-
# @param font_color [GD::Color, nil]
|
|
333
|
-
# Text color for numeric or alphabetic symbols.
|
|
334
|
-
#
|
|
335
|
-
# @return [void]
|
|
336
|
-
#
|
|
337
|
-
# @example Render a simple point
|
|
338
|
-
# map.add_point(
|
|
339
|
-
# lon: -58.3816,
|
|
340
|
-
# lat: -34.6037
|
|
341
|
-
# )
|
|
342
|
-
#
|
|
343
|
-
# @example Point with label
|
|
344
|
-
# map.add_point(
|
|
345
|
-
# lon: -58.3816,
|
|
346
|
-
# lat: -34.6037,
|
|
347
|
-
# label: "Buenos Aires"
|
|
348
|
-
# )
|
|
349
|
-
#
|
|
350
|
-
# @example Point with numeric marker
|
|
351
|
-
# map.add_point(
|
|
352
|
-
# lon: -58.3816,
|
|
353
|
-
# lat: -34.6037,
|
|
354
|
-
# icon: "numeric",
|
|
355
|
-
# label: "1",
|
|
356
|
-
# font: "/usr/share/fonts/DejaVuSans.ttf"
|
|
357
|
-
# )
|
|
358
|
-
#
|
|
359
|
-
|
|
360
|
-
def add_point(
|
|
361
|
-
lon:,
|
|
362
|
-
lat:,
|
|
363
|
-
label: nil,
|
|
364
|
-
icon: nil,
|
|
365
|
-
font: nil,
|
|
366
|
-
size: nil,
|
|
367
|
-
color: nil,
|
|
368
|
-
font_color: nil,
|
|
369
|
-
symbol: nil
|
|
370
|
-
)
|
|
371
|
-
row = {
|
|
372
|
-
lon: lon,
|
|
373
|
-
lat: lat,
|
|
374
|
-
label: label
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
@points_layers << GD::GIS::PointsLayer.new(
|
|
378
|
-
[row],
|
|
379
|
-
lon: -> r { r[:lon] },
|
|
380
|
-
lat: -> r { r[:lat] },
|
|
381
|
-
icon: icon || @style.point[:icon],
|
|
382
|
-
label: label ? -> r { r[:label] } : nil,
|
|
383
|
-
font: font || @style.point[:font],
|
|
384
|
-
size: size || @style.point[:size],
|
|
385
|
-
color: color || @style.point[:color],
|
|
386
|
-
font_color: font_color || @style.point[:font_color],
|
|
387
|
-
symbol: symbol
|
|
388
|
-
)
|
|
389
|
-
end
|
|
390
|
-
|
|
391
301
|
# Adds a generic points overlay layer.
|
|
392
302
|
#
|
|
393
303
|
# @param data [Enumerable]
|
data/lib/gd/gis/style.rb
CHANGED
|
@@ -17,9 +17,6 @@ module GD
|
|
|
17
17
|
# @return [Hash] global styling rules
|
|
18
18
|
attr_reader :global
|
|
19
19
|
|
|
20
|
-
# @return [Hash] point styling rules
|
|
21
|
-
attr_reader :point
|
|
22
|
-
|
|
23
20
|
# @return [Hash] road styling rules
|
|
24
21
|
attr_reader :roads
|
|
25
22
|
|
|
@@ -48,7 +45,6 @@ module GD
|
|
|
48
45
|
# :global, :roads, :rails, :water, :parks, :points, :order, :track
|
|
49
46
|
def initialize(definition)
|
|
50
47
|
@global = definition[:global] || {}
|
|
51
|
-
@point = definition[:point] || {}
|
|
52
48
|
@roads = definition[:roads] || {}
|
|
53
49
|
@rails = definition[:rails] || {}
|
|
54
50
|
@water = definition[:water] || {}
|
|
@@ -83,7 +79,6 @@ module GD
|
|
|
83
79
|
|
|
84
80
|
new(
|
|
85
81
|
global: data[:global],
|
|
86
|
-
point: data[:point],
|
|
87
82
|
roads: data[:roads],
|
|
88
83
|
rails: data[:rail] || data[:rails],
|
|
89
84
|
track: data[:track],
|
data/lib/test.rb
ADDED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: libgd-gis
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.21
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Germán Alberto Giménez Silva
|
|
@@ -57,6 +57,7 @@ files:
|
|
|
57
57
|
- lib/gd/gis/projection.rb
|
|
58
58
|
- lib/gd/gis/style.rb
|
|
59
59
|
- lib/libgd_gis.rb
|
|
60
|
+
- lib/test.rb
|
|
60
61
|
homepage: https://github.com/ggerman/libgd-gis
|
|
61
62
|
licenses:
|
|
62
63
|
- MIT
|
|
@@ -76,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
76
77
|
- !ruby/object:Gem::Version
|
|
77
78
|
version: '0'
|
|
78
79
|
requirements: []
|
|
79
|
-
rubygems_version: 4.0.
|
|
80
|
+
rubygems_version: 4.0.4
|
|
80
81
|
specification_version: 4
|
|
81
82
|
summary: Geospatial raster rendering for Ruby using libgd
|
|
82
83
|
test_files: []
|