Class: Proj::OperationFactoryContext

Inherits:
Object
  • Object
show all
Defined in:
lib/proj/operation_factory_context.rb

Overview

A context for building coordinate operations between two CRS.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, authority: nil) ⇒ OperationFactoryContext

Create a new OperationFactoryContext

Parameters:

  • context
    • The context to use or the current context if nil

  • authority (defaults to: nil)
    • If authority is nil or the empty string, then coordinate operations

    from any authority will be searched, with the restrictions set in the authority_to_authority_preference database table. If authority is set to “any”, then coordinate operations from any authority will be searched If authority is a non-empty string different of “any”, then coordinate operations will be searched only in that authority namespace.



23
24
25
26
# File 'lib/proj/operation_factory_context.rb', line 23

def initialize(context, authority: nil)
  @pointer = Api.proj_create_operation_factory_context(context, authority)
  ObjectSpace.define_finalizer(self, self.class.finalize(@pointer))
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



4
5
6
# File 'lib/proj/operation_factory_context.rb', line 4

def context
  @context
end

Instance Method Details

#allow_use_intermediate_crs=(value) ⇒ Object

Set whether an intermediate pivot CRS can be used for researching coordinate operations between a source and target CRS.

Parameters:

  • value (PROJ_INTERMEDIATE_CRS_USE)
    • Whether and how intermediate CRS may be used



105
106
107
# File 'lib/proj/operation_factory_context.rb', line 105

def allow_use_intermediate_crs=(value)
  Api.proj_operation_factory_context_set_allow_use_intermediate_crs(self.context, self, value)
end

#allowed_intermediate_crs=(values) ⇒ Object

Restrict the potential pivot CRSs that can be used when trying to build a coordinate operation between two CRS that have no direct operation.

Parameters:

  • values (Array)
    • Array of string with the format [“auth_name1”, “code1”, “auth_name2”, “code2”]



113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/proj/operation_factory_context.rb', line 113

def allowed_intermediate_crs=(values)
  # Convert strings to C chars
  values_ptr = values.map do |value|
    FFI::MemoryPointer.from_string(value)
  end

  # Add extra item at end for null pointer
  pointer = FFI::MemoryPointer.new(:pointer, values.size + 1)
  pointer.write_array_of_pointer(values_ptr)

  Api.proj_operation_factory_context_set_allowed_intermediate_crs(self.context, self, pointer)
end

#area_of_interest_name=(value) ⇒ Object

Set the name of the desired area of interest for the resulting coordinate transformations.

Parameters:

  • value
    • Name of the area. Must be known of the database.



67
68
69
# File 'lib/proj/operation_factory_context.rb', line 67

def area_of_interest_name=(value)
  Api.proj_operation_factory_context_set_area_of_interest_name(self.context, self, value)
end

#ballpark_transformations=(value) ⇒ Object

Specifies whether ballpark transformations are allowed.

Parameters:

  • value
    • Set to True allow ballpark transformations otherwise False



42
43
44
# File 'lib/proj/operation_factory_context.rb', line 42

def ballpark_transformations=(value)
  Api.proj_operation_factory_context_set_allow_ballpark_transformations(self.context, self, value ? 1 : 0)
end

#create_operations(source, target) ⇒ Array

Find a list of CoordinateOperation from source_crs to target_crs

Parameters:

  • source (Crs)

    Source CRS. Must not be nil.

  • target (Crs)

    Target CRS. Must not be nil.

Returns:

  • (Array)
    • Returns a list of operations



34
35
36
37
# File 'lib/proj/operation_factory_context.rb', line 34

def create_operations(source, target)
  ptr = Api.proj_create_operations(self.context, source, target, self)
  PjObjects.new(ptr, self.context)
end

#crs_extent_use=(value) ⇒ Object

Set how source and target CRS extent should be used when considering if a transformation can be used (only takes effect if no area of interest is explicitly defined).

Parameters:

  • value (PROJ_CRS_EXTENT_USE)

    How source and target CRS extent should be used.



75
76
77
# File 'lib/proj/operation_factory_context.rb', line 75

def crs_extent_use=(value)
  Api.proj_operation_factory_context_set_crs_extent_use(self.context, self, value)
end

#desired_accuracy=(value) ⇒ Object

Set the desired accuracy of the resulting coordinate transformations.

Parameters:

  • value (Float)
    • Accuracy in meters. Set to 0 to disable the filter.



49
50
51
# File 'lib/proj/operation_factory_context.rb', line 49

def desired_accuracy=(value)
  Api.proj_operation_factory_context_set_desired_accuracy(self.context, self, value)
end

#discard_superseded=(value) ⇒ Object

Set whether transformations that are superseded (but not deprecated) should be discarded.

Parameters:

  • value (bool)
    • Whether to discard superseded crses



129
130
131
# File 'lib/proj/operation_factory_context.rb', line 129

def discard_superseded=(value)
  Api.proj_operation_factory_context_set_discard_superseded(self.context, self, value ? 1 : 0)
end

#grid_availability=(value) ⇒ Object

Set how grid availability is used.

@param [PROJ_GRID_AVAILABILITY_USE] - Use how grid availability is used.


90
91
92
# File 'lib/proj/operation_factory_context.rb', line 90

def grid_availability=(value)
  Api.proj_operation_factory_context_set_grid_availability_use(self.context, self, value)
end

#set_area_of_interest(west, south, east, north) ⇒ Object

Set the desired area of interest for the resulting coordinate transformations. For an area of interest crossing the anti-meridian, west_lon_degree will be greater than east_lon_degree.

Parameters:

  • west

    West longitude (in degrees).

  • south

    South latitude (in degrees).

  • east

    East longitude (in degrees).

  • north

    North latitude (in degrees).



60
61
62
# File 'lib/proj/operation_factory_context.rb', line 60

def set_area_of_interest(west, south, east, north)
  Api.proj_operation_factory_context_set_area_of_interest(self.context, self, west, south, east, north)
end

#spatial_criterion=(value) ⇒ Object

Set the spatial criterion to use when comparing the area of validity of coordinate operations with the area of interest / area of validity of source and target CRS.

@param value [PROJ_SPATIAL_CRITERION] spatial criterion to use


83
84
85
# File 'lib/proj/operation_factory_context.rb', line 83

def spatial_criterion=(value)
  Api.proj_operation_factory_context_set_spatial_criterion(self.context, self, value)
end

#to_ptrObject



133
134
135
# File 'lib/proj/operation_factory_context.rb', line 133

def to_ptr
  @pointer
end

#use_proj_alternative_grid_names=(value) ⇒ Object

Set whether PROJ alternative grid names should be substituted to the official authority names.

Parameters:

  • value (boolean)
    • Whether PROJ alternative grid names should be used



97
98
99
# File 'lib/proj/operation_factory_context.rb', line 97

def use_proj_alternative_grid_names=(value)
  Api.proj_operation_factory_context_set_use_proj_alternative_grid_names(self.context, self, value ? 1 : 0)
end