libgd-gis 0.4.5 → 0.4.6
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_geojson.rb +13 -2
- data/lib/gd/gis/map.rb +2 -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: f3554f0a9c975f7b1b08d83ed233235e5fd6c1819c8a53bad5ee8f9ad2c47171
|
|
4
|
+
data.tar.gz: 6135f85c489fe8e5019d0812bb2c7d4125c850e386d2b422ff55ce6ef70ccc51
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 32e87dda7bde5daa819cb12b1712b3a438d7996558b1781631a2bcfa6e8a15e2d92e45a4ff72f2e7c66ce4da30737f827fc648da3fb35c6ab84d0718022ec58c
|
|
7
|
+
data.tar.gz: 9cd4fe592fa790a046efa016603b458abb5092f80f52ed2896a9e8d0c69160f3ec44f6a8ecdb42fed7d1d56219bf0cca78ed57ae90b9ff5152abdb456cd807a6
|
data/lib/gd/gis/layer_geojson.rb
CHANGED
|
@@ -25,8 +25,19 @@ module GD
|
|
|
25
25
|
# @return [Array<GD::GIS::Feature>]
|
|
26
26
|
# @raise [JSON::ParserError] if the file is invalid JSON
|
|
27
27
|
# @raise [Errno::ENOENT] if the file does not exist
|
|
28
|
-
def self.load(
|
|
29
|
-
|
|
28
|
+
def self.load(source)
|
|
29
|
+
geojson = case source
|
|
30
|
+
when String
|
|
31
|
+
if source.strip.start_with?("{", "[")
|
|
32
|
+
JSON.parse(source)
|
|
33
|
+
else
|
|
34
|
+
JSON.parse(File.read(source))
|
|
35
|
+
end
|
|
36
|
+
when Hash
|
|
37
|
+
source
|
|
38
|
+
else
|
|
39
|
+
raise ArgumentError, "Unsupported GeoJSON source"
|
|
40
|
+
end
|
|
30
41
|
|
|
31
42
|
# 1) Detect CRS
|
|
32
43
|
crs_name = data["crs"]&.dig("properties", "name")
|
data/lib/gd/gis/map.rb
CHANGED
|
@@ -334,9 +334,9 @@ module GD
|
|
|
334
334
|
#
|
|
335
335
|
# @param path [String] path to GeoJSON file
|
|
336
336
|
# @return [void]
|
|
337
|
-
def add_geojson(
|
|
337
|
+
def add_geojson(source)
|
|
338
338
|
@style ||= GD::GIS::Style.default
|
|
339
|
-
features = LayerGeoJSON.load(
|
|
339
|
+
features = LayerGeoJSON.load(source)
|
|
340
340
|
|
|
341
341
|
features.each do |feature|
|
|
342
342
|
maybe_create_line_label(feature)
|