libgd-gis 0.4.6 → 0.4.7
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 +11 -10
- 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: 845f824374bd07e832f915da01a2c4f0139ceab3836b121397d66f710c83a789
|
|
4
|
+
data.tar.gz: 8eeb1c1abc669c85333bc201875b8e07a5af34803dcae9753875ee12b288895b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1a7ee52afb255c6da0cee58bcd53f6639a6994cf68e6138c581dd1729d3e382197f5b1ad83916c100774ac6e721ad0f2f88e7c9c6e3419396cdaa7b7252fb8e1
|
|
7
|
+
data.tar.gz: f3bbff63007f3857f556908b553f5fa20a5c7a3da7934f478f1da0a7c967864dd82e597c3388a2ff78a0c2cd647c29d970689b60ebd130af275029431f23c52b
|
data/lib/gd/gis/layer_geojson.rb
CHANGED
|
@@ -26,18 +26,19 @@ module GD
|
|
|
26
26
|
# @raise [JSON::ParserError] if the file is invalid JSON
|
|
27
27
|
# @raise [Errno::ENOENT] if the file does not exist
|
|
28
28
|
def self.load(source)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
|
|
30
|
+
geojson = case source
|
|
31
|
+
when String
|
|
32
|
+
if source.strip.start_with?("{", "[")
|
|
33
|
+
JSON.parse(source)
|
|
34
|
+
else
|
|
35
|
+
JSON.parse(File.read(source))
|
|
36
|
+
end
|
|
37
|
+
when Hash
|
|
38
|
+
source
|
|
33
39
|
else
|
|
34
|
-
|
|
40
|
+
raise ArgumentError, "Unsupported GeoJSON source"
|
|
35
41
|
end
|
|
36
|
-
when Hash
|
|
37
|
-
source
|
|
38
|
-
else
|
|
39
|
-
raise ArgumentError, "Unsupported GeoJSON source"
|
|
40
|
-
end
|
|
41
42
|
|
|
42
43
|
# 1) Detect CRS
|
|
43
44
|
crs_name = data["crs"]&.dig("properties", "name")
|