Sha256: 495d3045a2afcd209cdfc9aa7fed07f48c94d9c980238db04156412a1445a29d

Contents?: true

Size: 1.9 KB

Versions: 8

Compression:

Stored size: 1.9 KB

Contents

# frozen_string_literal: true

# -----------------------------------------------------------------------------
#
# Proj4 projection
#
# -----------------------------------------------------------------------------

module RGeo
  module Geographic
    class Proj4Projector # :nodoc:
      def initialize(geography_factory, projection_factory)
        @geography_factory = geography_factory
        @projection_factory = projection_factory
      end

      def set_factories(geography_factory, projection_factory)
        @geography_factory = geography_factory
        @projection_factory = projection_factory
      end

      def project(geometry)
        Feature.cast(geometry, @projection_factory, :project)
      end

      def unproject(geometry)
        Feature.cast(geometry, @geography_factory, :project)
      end

      attr_reader :projection_factory

      def wraps?
        false
      end

      def limits_window
        nil
      end

      class << self
        def create_from_existing_factory(geography_factory, projection_factory)
          new(geography_factory, projection_factory)
        end

        def create_from_proj4(geography_factory, proj4, opts = {})
          projection_factory =
            Cartesian.preferred_factory(
              proj4: proj4,
              coord_sys: opts[:coord_sys], srid: opts[:srid],
              buffer_resolution: opts[:buffer_resolution],
              lenient_multi_polygon_assertions: opts[:lenient_multi_polygon_assertions],
              uses_lenient_assertions: opts[:uses_lenient_assertions],
              has_z_coordinate: opts[:has_z_coordinate],
              has_m_coordinate: opts[:has_m_coordinate],
              wkt_parser: opts[:wkt_parser], wkt_generator: opts[:wkt_generator],
              wkb_parser: opts[:wkb_parser], wkb_generator: opts[:wkb_generator]
            )
          new(geography_factory, projection_factory)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rgeo-2.4.0 lib/rgeo/geographic/proj4_projector.rb
rgeo-2.3.1 lib/rgeo/geographic/proj4_projector.rb
rgeo-2.3.0 lib/rgeo/geographic/proj4_projector.rb
rgeo-2.2.0 lib/rgeo/geographic/proj4_projector.rb
rgeo-2.1.1 lib/rgeo/geographic/proj4_projector.rb
rgeo-2.1.0 lib/rgeo/geographic/proj4_projector.rb
rgeo-2.0.1 lib/rgeo/geographic/proj4_projector.rb
rgeo-2.0.0 lib/rgeo/geographic/proj4_projector.rb