Sha256: e492e3e1ed75d5a6aded0592cf9eab14ff5108fa94be3d2da850e70fe02cf5c7

Contents?: true

Size: 1.67 KB

Versions: 10

Compression:

Stored size: 1.67 KB

Contents

module SpatialExtensions
  private

  def abstract_refresh_geometry_action(model, cache_classes)
    queue = "#{model.class}/#{model.id}/update_features"

    # Destroy old failed jobs
    Delayed::Job.where(:queue => queue).where.not(:failed_at => nil).destroy_all

    Delayed::Job.enqueue(
      ArcGISUpdateFeaturesJob.new(
        :spatial_model_type => model.class,
        :spatial_model_id => model.id,
        :cache_classes => cache_classes
      ),
      :queue => queue
    )

    redirect_to :back
  end

  def abstract_proximity_action(scope, target, distance, &block)
    @nearby_records = scope_for_search(scope).within_buffer(target, distance, :distance => true, :intersection_area => true).order('distance_in_meters ASC, intersection_area_in_square_meters DESC, id ASC')
    @target = target

    yield if block_given?

    respond_to do |format|
      format.html { render :template => 'shared/spatial/feature_proximity', :layout => false }
      format.kml { render :template => 'shared/spatial/feature_proximity' }
    end
  end

  def abstract_venn_polygons_action(scope, target, &block)
    @venn_polygons = SpatialFeatures.venn_polygons(scope_for_search(scope).intersecting(target), target.class.where(:id => target), :target => target)
    @klass = klass_for_search(scope)
    @target = target

    yield if block_given?

    respond_to do |format|
      format.kml { render :template => 'shared/spatial/feature_venn_polygons' }
    end
  end

  def klass_for_search(scope_or_class)
    scope_or_class.is_a?(ActiveRecord::Relation) ? scope_or_class.klass : scope_or_class
  end

  def scope_for_search(scope)
    params.key?(:ids) ? scope.where(:id => params[:ids]) : scope
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
spatial_features-1.2.7 lib/spatial_features/controller_helpers/spatial_extensions.rb
spatial_features-1.2.6 lib/spatial_features/controller_helpers/spatial_extensions.rb
spatial_features-1.2.5 lib/spatial_features/controller_helpers/spatial_extensions.rb
spatial_features-1.2.4 lib/spatial_features/controller_helpers/spatial_extensions.rb
spatial_features-1.2.3 lib/spatial_features/controller_helpers/spatial_extensions.rb
spatial_features-1.2.2 lib/spatial_features/controller_helpers/spatial_extensions.rb
spatial_features-1.2.1 lib/spatial_features/controller_helpers/spatial_extensions.rb
spatial_features-1.2.0 lib/spatial_features/controller_helpers/spatial_extensions.rb
spatial_features-1.1.1 lib/spatial_features/controller_helpers/spatial_extensions.rb
spatial_features-1.1.0 lib/spatial_features/controller_helpers/spatial_extensions.rb