Sha256: 4621304ead56f4d89ad123c9720eb49b991867565322353a3d268e691555e7f6

Contents?: true

Size: 1.43 KB

Versions: 22

Compression:

Stored size: 1.43 KB

Contents

require 'jbuilder'
require 'rgeo'

module ADIWG
  module Mdtranslator
    module Writers
      module SbJson
        module Spatial
          def self.build(intObj)
            geo = []
            intObj.each do |ext|
              ext[:extGeoElements].each do |ge|
                case ge[:elementType]
                when 'GeometryCollection'
                  ge[:elementGeometry][:geometry].each do |geom|
                    geo << AdiwgGeoFormat.internal_to_wkt(geom[:elementGeometry])
                  end

                when 'FeatureCollection'
                  ge[:elementGeometry][:geometry].each do |fea|
                    geo << AdiwgGeoFormat.internal_to_wkt(fea[:elementGeometry])
                  end
                else
                  geo << AdiwgGeoFormat.internal_to_wkt(ge[:elementGeometry])
                end
              end
            end
            # puts geo
            # calculate the bounds
            reader = RGeo::WKRep::WKTParser.new(nil, support_wkt12: true)
            fact = RGeo::Geographic.spherical_factory
            bbox = RGeo::Cartesian::BoundingBox.new(fact, ignore_z: true)
            geo.each { |geom| bbox.add(reader.parse(geom)) }

            {
              boundingBox: {
                minX: bbox.min_x,
                maxX: bbox.max_x,
                minY: bbox.min_y,
                maxY: bbox.max_y
              }
            }

          end
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
adiwg-mdtranslator-2.0.0rc8 lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb
adiwg-mdtranslator-2.0.0rc7 lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb
adiwg-mdtranslator-2.0.0rc6 lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb
adiwg-mdtranslator-2.0.0rc5 lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb
adiwg-mdtranslator-2.0.0rc4 lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb
adiwg-mdtranslator-2.0.0rc3 lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb
adiwg-mdtranslator-2.0.0rc2 lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb
adiwg-mdtranslator-1.4.0 lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb
adiwg-mdtranslator-1.4.0.beta14 lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb
adiwg-mdtranslator-1.4.0.beta13 lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb
adiwg-mdtranslator-1.4.0.beta12 lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb
adiwg-mdtranslator-1.4.0.beta11 lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb
adiwg-mdtranslator-1.4.0.beta10 lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb
adiwg-mdtranslator-1.4.0.beta9 lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb
adiwg-mdtranslator-1.4.0.beta8 lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb
adiwg-mdtranslator-1.4.0.beta7 lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb
adiwg-mdtranslator-1.4.0.beta6 lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb
adiwg-mdtranslator-1.4.0.beta5 lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb
adiwg-mdtranslator-1.4.0.beta4 lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb
adiwg-mdtranslator-1.4.0.beta3 lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb