app/models/map.rb
#takes in the clipping mask file, transforms it to geo and converts to geojson, returning the geojson
takes in the clipping mask file, transforms it to geo and converts to geojson, returning the geojson
takes in the clipping mask file transforms it to geo and converts to geojson returning the geojson
def convert_mask_to_geojson
    if self.gcps.hard.size < 3
      return nil;
    else
      gcp_array = self.gcps.hard
      gdal_gcp_array = []
      gcp_array.each do |gcp|
        gdal_gcp_array << gcp.gdal_array
      end
      gdal_gcp_array.flatten!
      mask = self.masking.original
      command = ["ogr2ogr", "-f", "geojson", "-s_srs", "epsg:4326", "-t_srs", "epsg:3857", gdal_gcp_array, "/dev/stdout",  "/vsistdin/" ].flatten
      logger.info command
      o_out, o_err = Open3.capture3( *command, :stdin_data => mask  )
      if !o_err.blank? 
        logger.error "Error ogr2ogr script" + o_err
        logger.error "output = "+o_out
        return nil;
      end
      return o_out
    end
  end
def convert_mask_to_geojson if self . gcps . hard . size < 3 return nil ; else gcp_array = self . gcps . hard gdal_gcp_array = [ ] gcp_array . each do | gcp | gdal_gcp_array << gcp . gdal_array end gdal_gcp_array . flatten! mask = self . masking . original command = [ "ogr2ogr" , "-f" , "geojson" , "-s_srs" , "epsg:4326" , "-t_srs" , "epsg:3857" , gdal_gcp_array , "/dev/stdout" , "/vsistdin/" ] . flatten logger . info command o_out , o_err = Open3 . capture3 ( * command , :stdin_data => mask ) if ! o_err . blank? logger . error "Error ogr2ogr script" + o_err logger . error "output = " + o_out return nil ; end return o_out end end
takes in the clipping mask file, transforms it to geo and converts to geojson, returning the geojson
takes in the clipping mask file transforms it to geo and converts to geojson returning the geojson