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