lib/adiwg/mdtranslator/readers/mdJson/modules/module_geometryFeature.rb in adiwg-mdtranslator-2.13.0 vs lib/adiwg/mdtranslator/readers/mdJson/modules/module_geometryFeature.rb in adiwg-mdtranslator-2.13.1

- old
+ new

@@ -1,30 +1,32 @@ # unpack geometry feature # Reader - ADIwg JSON to internal data structure # History: -# Stan Smith 2018-02-18 refactored error and warning messaging +# Stan Smith 2018-06-20 refactored error and warning messaging # Stan Smith 2016-11-10 added computedBbox computation # Stan Smith 2016-10-25 original script +require 'adiwg/mdtranslator/internal/module_coordinates' require_relative 'module_geometryObject' require_relative 'module_geometryProperties' require_relative 'module_geometryCollection' -require 'adiwg/mdtranslator/internal/module_coordinates' module ADIWG module Mdtranslator module Readers module MdJson module GeometryFeature def self.unpack(hFeature, responseObj) + @MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson + # return nil object if input is empty if hFeature.empty? - responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: GeoJSON geometry feature object is empty' + @MessagePath.issueWarning(370, responseObj) return nil end # instance classes needed in script intMetadataClass = InternalMetadata.new @@ -34,20 +36,16 @@ if hFeature.has_key?('type') unless hFeature['type'] == '' if hFeature['type'] == 'Feature' intFeature[:type] = hFeature['type'] else - responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: GeoJSON geometry feature type must be Feature' - responseObj[:readerExecutionPass] = false - return nil + @MessagePath.issueError(371, responseObj) end end end if intFeature[:type].nil? || intFeature[:type] == '' - responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: GeoJSON geometry feature type is missing' - responseObj[:readerExecutionPass] = false - return nil + @MessagePath.issueError(372, responseObj) end # geometry feature - id if hFeature.has_key?('id') unless hFeature['id'] == '' @@ -74,12 +72,10 @@ unless hReturn.nil? intFeature[:geometryObject] = hReturn end end else - responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: GeoJSON geometry feature geometry is missing' - responseObj[:readerExecutionPass] = false - return nil + @MessagePath.issueError(373, responseObj) end # geometry feature - properties if hFeature.has_key?('properties') hObject = hFeature['properties']