charta 0.3.1 → 0.4.0
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/charta.gemspec +1 -0
- data/lib/charta/bounding_box.rb +1 -1
- data/lib/charta/factory/simple_feature_factory.rb +1 -1
- data/lib/charta/geometry.rb +29 -8
- data/lib/charta/version.rb +1 -1
- metadata +21 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96bee13636a087302272ef4bc271ca0200e46aece932f932a2c9ff6b989254a8
|
4
|
+
data.tar.gz: 4d139f4c3d628b178862b6879edc2ba92e11f82e96f43d748def1ac063c89562
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04b4a7e56bc7a412114f4f2713725d1304bc4c859911a2079a847b88511d80c5f20057df7a19f79c6b022b107ff9b1328b064084f0ebdf1e5335622afbff7f27
|
7
|
+
data.tar.gz: 3f8cec56a64a686abcfd14264df20b593c396fb0296b779b48c2697a630ad9bed6d16de61a86c12995fec6f74e5a1cf4ac1f65655e244a840393ea5448fd00ed
|
data/charta.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency 'rgeo', '~> 2.0'
|
22
22
|
spec.add_dependency 'rgeo-geojson', '~> 2.0'
|
23
23
|
spec.add_dependency 'rgeo-proj4', '~> 2.0'
|
24
|
+
spec.add_dependency 'victor', '~> 0.3.3'
|
24
25
|
spec.add_dependency 'zeitwerk', '~> 2.4.0'
|
25
26
|
|
26
27
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
data/lib/charta/bounding_box.rb
CHANGED
@@ -30,7 +30,7 @@ module Charta
|
|
30
30
|
if coordinates.is_a?(Charta::Geometry)
|
31
31
|
coordinates
|
32
32
|
elsif coordinates.is_a?(RGeo::Feature::Instance)
|
33
|
-
|
33
|
+
Geometry.feature(coordinates)
|
34
34
|
elsif coordinates.to_s =~ /\A[[:space:]]*\z/
|
35
35
|
empty_feature(srs)
|
36
36
|
else
|
data/lib/charta/geometry.rb
CHANGED
@@ -2,6 +2,7 @@ require 'json'
|
|
2
2
|
require 'rgeo/geo_json'
|
3
3
|
require 'rgeo/svg' # integrated lib for now
|
4
4
|
require 'active_support/core_ext/module/delegation'
|
5
|
+
require 'victor' # for SVG
|
5
6
|
|
6
7
|
module Charta
|
7
8
|
# Represents a Geometry with SRID
|
@@ -63,16 +64,36 @@ module Charta
|
|
63
64
|
|
64
65
|
alias to_ewkb to_binary
|
65
66
|
|
66
|
-
#
|
67
|
+
# Generate SVG from geometry
|
68
|
+
# @param [Hash] options , the options for SVG object.
|
69
|
+
# @option options [Hash] :mode could be :stroke or :fill
|
70
|
+
# @option options [Hash] :color could be "orange", "red", "blue" or HTML color "#14TF15"
|
71
|
+
# @option options [Hash] :fill_opacity could be '0' to '100'
|
72
|
+
# @option options [Hash] :stroke_linecap could be 'round', 'square', 'butt'
|
73
|
+
# @option options [Hash] :stroke_linejoin default 'round'
|
74
|
+
# @option options [Hash] :stroke_width default '5%'
|
75
|
+
# @note more informations on https://developer.mozilla.org/fr/docs/Web/SVG/Tutorial/Fills_and_Strokes
|
76
|
+
# @return [String] the SVG image
|
67
77
|
def to_svg(options = {})
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
78
|
+
# set default options if not present
|
79
|
+
options[:mode] ||= :stroke
|
80
|
+
options[:color] ||= 'black'
|
81
|
+
options[:fill_opacity] ||= '100' # 0 to 100
|
82
|
+
options[:stroke_linecap] ||= 'butt' # round, square, butt
|
83
|
+
options[:stroke_linejoin] ||= 'round' #
|
84
|
+
options[:stroke_width] ||= '5%'
|
85
|
+
|
86
|
+
svg = Victor::SVG.new template: :html
|
87
|
+
svg.setup width: 180, height: 180, viewBox: bounding_box.svg_view_box.join(' ')
|
88
|
+
# return a stroke SVG with options
|
89
|
+
if options[:mode] == :stroke
|
90
|
+
svg.path d: to_svg_path, fill: 'none', stroke: options[:color], stroke_linecap: options[:stroke_linecap],
|
91
|
+
stroke_linejoin: options[:stroke_linejoin], stroke_width: options[:stroke_width]
|
92
|
+
# return a fill SVG with options
|
93
|
+
elsif options[:mode] == :fill
|
94
|
+
svg.path d: to_svg_path, fill: options[:color], fill_opacity: options[:fill_opacity]
|
73
95
|
end
|
74
|
-
svg
|
75
|
-
svg
|
96
|
+
svg.render
|
76
97
|
end
|
77
98
|
|
78
99
|
# Return the geometry as Scalar Vector Graphics (SVG) path data.
|
data/lib/charta/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: charta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ekylibre developers
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '2.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: victor
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.3.3
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.3.3
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: zeitwerk
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,7 +178,7 @@ dependencies:
|
|
164
178
|
- - '='
|
165
179
|
- !ruby/object:Gem::Version
|
166
180
|
version: 1.3.1
|
167
|
-
description:
|
181
|
+
description:
|
168
182
|
email:
|
169
183
|
- dev@ekylibre.com
|
170
184
|
executables: []
|
@@ -206,7 +220,7 @@ homepage: https://gitlab.com/ekylibre
|
|
206
220
|
licenses:
|
207
221
|
- AGPL-3.0-only
|
208
222
|
metadata: {}
|
209
|
-
post_install_message:
|
223
|
+
post_install_message:
|
210
224
|
rdoc_options: []
|
211
225
|
require_paths:
|
212
226
|
- lib
|
@@ -221,8 +235,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
235
|
- !ruby/object:Gem::Version
|
222
236
|
version: '0'
|
223
237
|
requirements: []
|
224
|
-
rubygems_version: 3.
|
225
|
-
signing_key:
|
238
|
+
rubygems_version: 3.2.26
|
239
|
+
signing_key:
|
226
240
|
specification_version: 4
|
227
241
|
summary: Simple tool over geos and co
|
228
242
|
test_files: []
|