Exception: Proj::Error

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

Overview

Represents error thrown by Proj

Constant Summary collapse

PROJ_ERR_INVALID_OP =

Error codes typically related to coordinate operation initialization

1024
PROJ_ERR_INVALID_OP_WRONG_SYNTAX =

Other/unspecified error related to coordinate operation initialization

PROJ_ERR_INVALID_OP + 1
PROJ_ERR_INVALID_OP_MISSING_ARG =

Invalid pipeline structure, missing +proj argument, etc

PROJ_ERR_INVALID_OP + 2
PROJ_ERR_INVALID_OP_ILLEGAL_ARG_VALUE =

Missing required operation parameter

PROJ_ERR_INVALID_OP + 3
PROJ_ERR_INVALID_OP_MUTUALLY_EXCLUSIVE_ARGS =

One of the operation parameter has an illegal value

PROJ_ERR_INVALID_OP + 4
PROJ_ERR_INVALID_OP_FILE_NOT_FOUND_OR_INVALID =

Mutually exclusive arguments

PROJ_ERR_INVALID_OP + 5
PROJ_ERR_COORD_TRANSFM =

Error codes related to transformation on a specific coordinate

2048
PROJ_ERR_COORD_TRANSFM_INVALID_COORD =

Other error related to coordinate transformation

PROJ_ERR_COORD_TRANSFM + 1
PROJ_ERR_COORD_TRANSFM_OUTSIDE_PROJECTION_DOMAIN =

For e.g lat > 90deg

PROJ_ERR_COORD_TRANSFM + 2
PROJ_ERR_COORD_TRANSFM_NO_OPERATION =

Coordinate is outside of the projection domain. e.g approximate mercator with |longitude - lon_0| > 90deg, or iterative convergence method failed

PROJ_ERR_COORD_TRANSFM + 3
PROJ_ERR_COORD_TRANSFM_OUTSIDE_GRID =

No operation found, e.g if no match the required accuracy, or if ballpark transformations were asked to not be used and they would be only such candidate

PROJ_ERR_COORD_TRANSFM + 4
PROJ_ERR_COORD_TRANSFM_GRID_AT_NODATA =

Point to transform falls outside grid or subgrid

PROJ_ERR_COORD_TRANSFM + 5
PROJ_ERR_OTHER =

Other type of errors

4096
PROJ_ERR_OTHER_API_MISUSE =

Error related to a misuse of PROJ API

PROJ_ERR_OTHER + 1
PROJ_ERR_OTHER_NO_INVERSE_OP =

No inverse method available

PROJ_ERR_OTHER + 2
PROJ_ERR_OTHER_NETWORK_ERROR =

Failure when accessing a network resource

PROJ_ERR_OTHER + 3

Class Method Summary collapse

Class Method Details

.category(errno) ⇒ Object

Converts an errno to a error category



65
66
67
68
69
# File 'lib/proj/error.rb', line 65

def self.category(errno)
  self.constants.find do |constant|
    self.const_get(constant) == errno
  end
end

.check_context(context) ⇒ Object

Check the context to see if an error occurred. If an error has happened will raise an exception.



30
31
32
33
34
35
# File 'lib/proj/error.rb', line 30

def self.check_context(context)
  unless context.errno == 0
    # raise(self, "#{self.category(context.errno)}: #{self.message(context)}")
    raise(self, self.message(context, context.errno))
  end
end

.check_object(pj_object) ⇒ Object



37
38
39
40
41
42
43
44
45
46
# File 'lib/proj/error.rb', line 37

def self.check_object(pj_object)
  # It would be nice if Proj exposed the proj_context_errno_set method so
  # we don't need a pj_object
  context = pj_object.context
  unless context.errno == 0
    message = self.message(context, context.errno)
    Api.proj_errno_reset(pj_object)
    raise(self, message)
  end
end

.message(context, errno) ⇒ Object

Returns the current error-state of the context. An non-zero error codes indicates an error.

See proj.org/development/reference/functions.html#c.proj_errno_string proj_errno_string

return [String]

Parameters:

  • context (Context)

    The context the error occurred in

  • errno (Integer)

    The error number



56
57
58
59
60
61
62
# File 'lib/proj/error.rb', line 56

def self.message(context, errno)
  if Api.method_defined?(:proj_context_errno_string)
    Api.proj_context_errno_string(context, errno)
  elsif Api.method_defined?(:proj_errno_string)
    Api.proj_errno_string(errno)
  end
end