Sha256: 6388e9d7b1885482d3105ff0c9047e27b2a4fb1f2f28538c12ed2ffb821d2eb3

Contents?: true

Size: 1.71 KB

Versions: 2

Compression:

Stored size: 1.71 KB

Contents

# sbJson 1.0 writer spatial

# History:
#  Stan Smith 2017-06-01 original script

module ADIWG
   module Mdtranslator
      module Writers
         module SbJson

            module Spatial

               def self.build(aExtents)

                  spatial = {}
                  aBoxObjects = []

                  aExtents.each do |hExtent|
                     hExtent[:geographicExtents].each do |hGeoExtent|
                        hBbox = hGeoExtent[:computedBbox]
                        sw = [ hBbox[:westLongitude], hBbox[:southLatitude] ]
                        nw = [ hBbox[:westLongitude], hBbox[:northLatitude] ]
                        ne = [ hBbox[:eastLongitude], hBbox[:northLatitude] ]
                        se = [ hBbox[:eastLongitude], hBbox[:southLatitude] ]
                        aPoly = [ sw, nw, ne, se ]
                        geoJson = {
                           type: 'Polygon',
                           coordinates: [
                              aPoly
                           ]
                        }
                        aBoxObjects << geoJson
                     end
                  end

                  unless aBoxObjects.empty?
                     hBox = AdiwgCoordinates.computeBbox(aBoxObjects)
                     sbBox = {}
                     sbBox[:maxY] = hBox[:northLatitude]
                     sbBox[:minY] = hBox[:southLatitude]
                     sbBox[:maxX] = hBox[:eastLongitude]
                     sbBox[:minX] = hBox[:westLongitude]
                     spatial[:boundingBox] = sbBox
                  end

                  # representational point is not computed

                  spatial

               end

            end

         end
      end
   end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
adiwg-mdtranslator-2.0.0rc10 lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb
adiwg-mdtranslator-2.0.0rc9 lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb