libgd-gis 0.4.9 → 0.5.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/lib/gd/gis/layer_geojson.rb +5 -9
- data/lib/gd/gis/map.rb +8 -0
- data/lib/gd/gis/ontology.rb +24 -3
- 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: 9d3a1a097a70594f97c1bc94eaf18e02c1494b530b430c137051eb1bc9d3c293
|
|
4
|
+
data.tar.gz: 1c3d4d8b4c9476dd06eab30fa0708063a9f6605dda34a2d23690460d98713edb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '069642af657e39514e8b16f2076e25abb097f8174abd5612c2427c0a8e64041ac0d82dd5769a4712a946bde371db8b697c65043b290a889b7840f3580f885b65'
|
|
7
|
+
data.tar.gz: d20ceb5e7e8c129100f6e536a633d9ea2cb9f423852878a829563c0132d01014ce9221637cfdd1f8ed3ff32c50c95c734022eacb175b502e7683b81505cef0fa
|
data/lib/gd/gis/layer_geojson.rb
CHANGED
|
@@ -77,17 +77,13 @@ module GD
|
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
def self.validate_geojson!(data)
|
|
80
|
-
unless data.is_a?(Hash)
|
|
81
|
-
raise ArgumentError, "GeoJSON must be an object"
|
|
82
|
-
end
|
|
80
|
+
raise ArgumentError, "GeoJSON must be an object" unless data.is_a?(Hash)
|
|
83
81
|
|
|
84
|
-
unless data["type"] == "FeatureCollection"
|
|
85
|
-
raise ArgumentError, "Only FeatureCollection is supported"
|
|
86
|
-
end
|
|
82
|
+
raise ArgumentError, "Only FeatureCollection is supported" unless data["type"] == "FeatureCollection"
|
|
87
83
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
84
|
+
return if data["features"].is_a?(Array)
|
|
85
|
+
|
|
86
|
+
raise ArgumentError, "GeoJSON must contain features array"
|
|
91
87
|
end
|
|
92
88
|
|
|
93
89
|
# Normalizes a GeoJSON geometry in-place.
|
data/lib/gd/gis/map.rb
CHANGED
|
@@ -404,6 +404,10 @@ module GD
|
|
|
404
404
|
@layers[:minor] << feature
|
|
405
405
|
end
|
|
406
406
|
end
|
|
407
|
+
puts "\n=== ONTOLOGY DEBUG ==="
|
|
408
|
+
puts "Properties: #{feature.properties}"
|
|
409
|
+
puts "Geometry: #{feature.geometry['type']}"
|
|
410
|
+
puts "→ Classified as: #{feature.layer.inspect}"
|
|
407
411
|
end
|
|
408
412
|
end
|
|
409
413
|
|
|
@@ -674,6 +678,10 @@ module GD
|
|
|
674
678
|
items = @layers[kind]
|
|
675
679
|
return if items.nil? || items.empty?
|
|
676
680
|
|
|
681
|
+
puts ">>>>>>debug<<<<<<"
|
|
682
|
+
puts kind
|
|
683
|
+
|
|
684
|
+
|
|
677
685
|
style =
|
|
678
686
|
case kind
|
|
679
687
|
when :street, :primary, :motorway, :secondary, :minor
|
data/lib/gd/gis/ontology.rb
CHANGED
|
@@ -31,6 +31,20 @@ module GD
|
|
|
31
31
|
@rules = YAML.load_file(path)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
def print_rules
|
|
35
|
+
@rules.each do |layer, sources|
|
|
36
|
+
puts "\n=== #{layer.to_s.upcase} ==="
|
|
37
|
+
|
|
38
|
+
sources.each do |source, rules|
|
|
39
|
+
puts " [#{source}]"
|
|
40
|
+
|
|
41
|
+
rules.each do |key, values|
|
|
42
|
+
puts " #{key} → #{values.join(', ')}"
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
34
48
|
# Classifies a feature into a semantic layer.
|
|
35
49
|
#
|
|
36
50
|
# Properties are matched against ontology rules using
|
|
@@ -64,9 +78,16 @@ module GD
|
|
|
64
78
|
end
|
|
65
79
|
|
|
66
80
|
# Fallback classification
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
81
|
+
case geometry_type
|
|
82
|
+
when "Point"
|
|
83
|
+
:points
|
|
84
|
+
when "LineString", "MultiLineString"
|
|
85
|
+
:minor
|
|
86
|
+
when "Polygon", "MultiPolygon"
|
|
87
|
+
:area
|
|
88
|
+
else
|
|
89
|
+
nil
|
|
90
|
+
end
|
|
70
91
|
end
|
|
71
92
|
end
|
|
72
93
|
end
|