Module: OGR::SpatialReferenceMixins::Initializers::ClassMethods

Defined in:
lib/ogr/extensions/spatial_reference/initializers.rb

Instance Method Summary collapse

Instance Method Details

#build_spatial_ref(spatial_reference_or_wkt = nil) ⇒ OGR::SpatialReference

Returns:

Raises:



123
124
125
126
127
128
129
130
131
132
# File 'lib/ogr/extensions/spatial_reference/initializers.rb', line 123

def build_spatial_ref(spatial_reference_or_wkt = nil)
  object = new(spatial_reference_or_wkt)
  ogr_err = yield object.c_pointer

  OGR::ErrorHandling.handle_ogr_err("Unable to build SpatialReference") do
    ogr_err
  end

  object
end

#new_from_epsg(code) ⇒ OGR::SpatialReference

Parameters:

Returns:



15
16
17
18
19
20
# File 'lib/ogr/extensions/spatial_reference/initializers.rb', line 15

def new_from_epsg(code)
  srs = new
  srs.import_from_epsg(code)

  srs
end

#new_from_epsga(code) ⇒ OGR::SpatialReference

Parameters:

Returns:



24
25
26
27
28
29
# File 'lib/ogr/extensions/spatial_reference/initializers.rb', line 24

def new_from_epsga(code)
  srs = new
  srs.import_from_epsga(code)

  srs
end

#new_from_erm(projection_name, datum_name, linear_unit_name) ⇒ OGR::SpatialReference

Parameters:

  • projection_name (String)

    I.e. “NUTM11” or “GEOGRAPHIC”.

  • datum_name (String)

    I.e. “NAD83”.

  • linear_unit_name (String)

    Plural form of linear units, i.e. “FEET”.

Returns:



35
36
37
38
39
40
# File 'lib/ogr/extensions/spatial_reference/initializers.rb', line 35

def new_from_erm(projection_name, datum_name, linear_unit_name)
  srs = new
  srs.import_from_erm(projection_name, datum_name, linear_unit_name)

  srs
end

#new_from_esri(prj_text) ⇒ OGR::SpatialReference

Parameters:

Returns:



44
45
46
47
48
49
# File 'lib/ogr/extensions/spatial_reference/initializers.rb', line 44

def new_from_esri(prj_text)
  srs = new
  srs.import_from_esri(prj_text)

  srs
end

#new_from_mapinfo(coord_sys) ⇒ OGR::SpatialReference

Parameters:

  • coord_sys (String)

    The Mapinfo style CoordSys definition string.

Returns:



53
54
55
56
57
58
# File 'lib/ogr/extensions/spatial_reference/initializers.rb', line 53

def new_from_mapinfo(coord_sys)
  srs = new
  srs.import_from_mapinfo(coord_sys)

  srs
end

#new_from_pci(proj, units, *proj_params) ⇒ OGR::SpatialReference

Parameters:

Returns:



64
65
66
67
68
69
# File 'lib/ogr/extensions/spatial_reference/initializers.rb', line 64

def new_from_pci(proj, units, *proj_params)
  srs = new
  srs.import_from_pci(proj, units, *proj_params)

  srs
end

#new_from_proj4(proj4) ⇒ OGR::SpatialReference

Parameters:

Returns:



73
74
75
76
77
78
# File 'lib/ogr/extensions/spatial_reference/initializers.rb', line 73

def new_from_proj4(proj4)
  srs = new
  srs.import_from_proj4(proj4)

  srs
end

#new_from_url(url) ⇒ OGR::SpatialReference

Parameters:

  • url (String)

    URL to fetch the spatial reference from.

Returns:



82
83
84
85
86
87
# File 'lib/ogr/extensions/spatial_reference/initializers.rb', line 82

def new_from_url(url)
  srs = new
  srs.import_from_url(url)

  srs
end

#new_from_usgs(projection_system_code, zone, datum, *proj_params) ⇒ OGR::SpatialReference

Parameters:

  • projection_system_code

Returns:



91
92
93
94
95
96
# File 'lib/ogr/extensions/spatial_reference/initializers.rb', line 91

def new_from_usgs(projection_system_code, zone, datum, *proj_params)
  srs = new
  srs.import_from_usgs(projection_system_code, zone, datum, *proj_params)

  srs
end

#new_from_wkt(wkt) ⇒ OGR::SpatialReference

This wipes the existing SRS definition and reassigns it based on the contents of wkt.

Parameters:

Returns:



103
104
105
106
107
108
# File 'lib/ogr/extensions/spatial_reference/initializers.rb', line 103

def new_from_wkt(wkt)
  srs = new
  srs.import_from_wkt(wkt)

  srs
end

#new_from_xml(xml) ⇒ OGR::SpatialReference

Use for importing a GML coordinate system.

Parameters:

Returns:



114
115
116
117
118
119
# File 'lib/ogr/extensions/spatial_reference/initializers.rb', line 114

def new_from_xml(xml)
  srs = new
  srs.import_from_xml(xml)

  srs
end