Class: PROJ::CRS
- Inherits:
-
Object
- Object
- PROJ::CRS
- Includes:
- Common
- Defined in:
- lib/simple-proj.rb,
ext/rb_proj.c
Instance Method Summary collapse
- #_dump_data ⇒ Object
- #_load_data(wkt) ⇒ Object
-
#initialize(definition) ⇒ Object
constructor
Constructs a CRS object with an argument.
-
#normalize_for_visualization ⇒ self
Normalizes the axis order which is the one expected for visualization purposes.
Methods included from Common
#ellipsoid_parameters, #id_auth_name, #id_code, #initialize_copy, #name, #to_epsg_code, #to_proj_string, #to_projjson, #to_projjson_as_hash, #to_wkt, #to_wkt2_2015, #to_wkt2_2015_simplified, #to_wkt2_2018, #to_wkt2_2018_simplified, #to_wkt_esri, #to_wkt_gdal
Constructor Details
#initialize(definition) ⇒ Object
Constructs a CRS object with an argument. The argument should be a String object one of
a proj-string,
a WKT string,
an object code (like “EPSG:4326”, “urn:ogc:def:crs:EPSG::4326”,
“urn:ogc:def:coordinateOperation:EPSG::1671”),
a OGC URN combining references for compound coordinate reference
systems (e.g “urn:ogc:def:crs,crs:EPSG::2393,crs:EPSG::5717” or
custom abbreviated syntax “EPSG:2393+5717”),
a OGC URN combining references for concatenated operations (e.g.
“urn:ogc:def:coordinateOperation,coordinateOperation:EPSG::3895,
coordinateOperation:EPSG::1618”)
708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 |
# File 'ext/rb_proj.c', line 708
static VALUE
rb_crs_initialize (VALUE self, VALUE vdef1)
{
Proj *proj;
PJ *ref;
int errno;
Data_Get_Struct(self, Proj, proj);
ref = proj_create(PJ_DEFAULT_CTX, StringValuePtr(vdef1));
if ( ! ref ) {
errno = proj_context_errno(PJ_DEFAULT_CTX);
rb_raise(rb_eRuntimeError, "%s", proj_errno_string(errno));
}
if ( proj_is_crs(ref) ) {
proj->ref = ref;
}
else {
rb_raise(rb_eRuntimeError, "should be crs definition");
}
return Qnil;
}
|
Instance Method Details
#_dump_data ⇒ Object
180 181 182 |
# File 'lib/simple-proj.rb', line 180 def _dump_data return to_wkt end |
#_load_data(wkt) ⇒ Object
184 185 186 |
# File 'lib/simple-proj.rb', line 184 def _load_data (wkt) initialize_copy self.class.new(wkt) end |
#normalize_for_visualization ⇒ self
Normalizes the axis order which is the one expected for visualization purposes. If the axis order of its source or target CRS is northing, easting, then an axis swap operation will be inserted.
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'ext/rb_proj.c', line 175
static VALUE
rb_proj_normalize_for_visualization (VALUE self)
{
Proj *proj;
PJ *ref, *orig;
int errno;
Data_Get_Struct(self, Proj, proj);
orig = proj->ref;
ref = proj_normalize_for_visualization(PJ_DEFAULT_CTX, orig);
if ( ! ref ) {
errno = proj_context_errno(PJ_DEFAULT_CTX);
rb_raise(rb_eRuntimeError, "%s", proj_errno_string(errno));
}
proj->ref = ref;
proj_destroy(orig);
return self;
}
|