@@ -53,49 +53,48 @@ def method_missing(name, *args, &blk)
53
53
end
54
54
55
55
##
56
- # Returns the id of the feature.
56
+ # Returns the id of the feature.
57
57
58
58
def id
59
59
return @feature_json [ :properties ] [ :id ]
60
60
end
61
61
62
62
##
63
- # Returns the name of the feature.
63
+ # Returns the name of the feature.
64
64
65
65
def name
66
66
return @feature_json [ :properties ] [ :name ]
67
67
end
68
68
69
69
##
70
- # Raises an error if the +feature_type+ is not specified the the Feature's class.
70
+ # Raises an error if the +feature_type+ is not specified the the Feature's class.
71
71
72
72
def feature_type
73
73
raise 'feature_type not implemented for Feature, override in your class'
74
74
end
75
-
75
+
76
76
##
77
- # Raises an error if the +schema_file+ is not specified the the Feature's class.
78
-
77
+ # Raises an error if the +schema_file+ is not specified the the Feature's class.
78
+
79
79
def schema_file
80
80
raise 'schema_file not implemented for Feature, override in your class'
81
81
end
82
-
83
82
84
83
def schema
85
84
if @@feature_schema [ feature_type ] . nil?
86
85
@@schema_file_lock . synchronize do
87
86
File . open ( schema_file , 'r' ) do |file |
88
87
@@feature_schema [ feature_type ] = JSON . parse ( file . read , symbolize_names : true )
89
-
90
- #Allows additional properties.
88
+
89
+ # Allows additional properties.
91
90
@@feature_schema [ feature_type ] [ :additionalProperties ] = true
92
91
end
93
92
end
94
93
end
95
94
96
95
return @@feature_schema [ feature_type ]
97
96
end
98
-
97
+
99
98
##
100
99
# Returns coordinate with the minimum longitute and latitude within a given +building_json+ .
101
100
def get_min_lon_lat
@@ -119,7 +118,7 @@ def get_min_lon_lat
119
118
# [Parameters]
120
119
# +json+
121
120
#
122
- # For example:
121
+ # For example:
123
122
#
124
123
# polygon = {
125
124
# 'geometry': {
@@ -167,7 +166,7 @@ def create_origin_lat_lon(runner)
167
166
168
167
private
169
168
170
- ##
169
+ ##
171
170
# Used to validate the feature by checking +feature_id+ , +geometry+, +properties+
172
171
# and +geometry_type+ .
173
172
@@ -186,7 +185,7 @@ def validate_feat(feature) #:doc:
186
185
raise ( "No properties found in '#{ feature } '" )
187
186
return false
188
187
end
189
-
188
+
190
189
errors = JSON ::Validator . fully_validate ( schema , feature [ :properties ] )
191
190
if !errors . empty?
192
191
raise ( "Invalid properties for '#{ feature } '\n #{ errors . join ( '\n ' ) } " )
@@ -204,4 +203,4 @@ def validate_feat(feature) #:doc:
204
203
end
205
204
end
206
205
end
207
- end
206
+ end
0 commit comments