vtdata library
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
vtCRS Class Reference

Inherits OGRSpatialReference.

Public Member Functions

vtCRSoperator= (const vtCRS &ref)
 
bool operator== (const vtCRS &ref) const
 
bool operator!= (const vtCRS &ref) const
 
void SetUTMZone (int iZone)
 
int GetUTMZone () const
 
OGRErr SetDatum (int iDatum)
 
int GetDatum () const
 
LinearUnits GetUnits () const
 
int GuessEPSGCode () const
 
OGRErr SetGeogCSFromDatum (int iDatum)
 
bool SetProjectionSimple (bool bUTM, int iUTMZone, int iDatum)
 
void SetSpatialReference (OGRSpatialReference *pRef)
 
const char * GetProjectionName () const
 
const char * GetProjectionNameShort () const
 
bool GetTextDescription (char *type, char *value) const
 
bool SetTextDescription (const char *type, const char *value)
 
bool ReadProjFile (const char *filename)
 
bool WriteProjFile (const char *filename) const
 
void SetDymaxion (bool bTrue)
 
bool IsDymaxion () const
 

Static Public Member Functions

static double GeodesicDistance (const DPoint2 &in, const DPoint2 &out, bool bQuick=false)
 

Protected Member Functions

void LogDescription () const
 

Protected Attributes

bool m_bDymaxion
 

Detailed Description

The vtCRS class represents an earth coordinate reference system (CRS), which is generally a projected coordinate system (PCS). It is based on the class OGRSpatialReference which represents a full OpenGIS Spatial Reference System. The vtCRS class extends OGRSpatialReference with several useful methods.

Member Function Documentation

double vtCRS::GeodesicDistance ( const DPoint2 geo1,
const DPoint2 geo2,
bool  bQuick = false 
)
static

Given two geographic coordinates (longitude/latitude in degrees), return the geodesic arc distance in meters. The WGS84 spheroid is used.

int vtCRS::GetDatum ( ) const

Return the datum as an EPSG code (an integer in the range of 6120 - 6904), or -1 if the datum could not be determined.

const char * vtCRS::GetProjectionName ( ) const

Return a string describing the type of projection.

Example:
"Geographic", "Transverse_Mercator", "Albers_Conic_Equal_Area"
const char * vtCRS::GetProjectionNameShort ( ) const

Return a very short string describing the type of projection.

Example values are "Geo", "UTM", "TM", "Albers", "LCC", etc. or "Unknown" if it is unknown.
bool vtCRS::GetTextDescription ( char *  type,
char *  value 
) const

Get the projection as a text description. If the projection is Geographic or UTM, then a "simple" type string will be returned. For all other projection types, a WKT string is returned.

Parameters
typeA string buffer to contain the type of description. This buffer should be at least 7 characters long to contain either the word "simple" or "wkt".
valueA string buffer to contain the full description. This buffer should be at least 2048 characters long to contain either a simple or WKT description.
LinearUnits vtCRS::GetUnits ( ) const

Return the kind of horizontal units used by the projection. This is also called "linear units."

Returns
  • LU_DEGREES - Arc Degrees
  • LU_METERS - Meters
  • LU_FEET_INT - Feet (International Foot)
  • LU_FEET_US - Feet (U.S. Survey Foot)
int vtCRS::GetUTMZone ( ) const

Get the UTM zone of the projection.

Returns
  • 1 through 60 in the northern hemisphere
  • -1 through -60 for the southern hemisphere
  • 0 if the projection is not UTM
int vtCRS::GuessEPSGCode ( ) const

Try to determine the EPSG code that corresponds to the current projection. This important capability is mysteriously absent from the underlying libraries (OGR, PROJ.4) so it is implemented here.

Returns
An EPSG coordinate system code, or -1 if it couldn't be guessed.
bool vtCRS::operator!= ( const vtCRS ref) const

Inequality operator.

vtCRS & vtCRS::operator= ( const vtCRS ref)

Assignment operator.

bool vtCRS::operator== ( const vtCRS ref) const

Equality operator.

bool vtCRS::ReadProjFile ( const char *  filename)

Read the projection from a .prj file.

If the filename does not have the file extension ".prj", this method will look for a file which has the same name with a ".prj" extension.

Returns
true if successful.
OGRErr vtCRS::SetDatum ( int  iDatum)

Set the datum to an EPSG Datum code, a value in the range (6120 - 6904).

Here are the codes for some of the better-known datums:

  • NAD27 6267
  • NAD83 6269
  • WGS84 6326
OGRErr vtCRS::SetGeogCSFromDatum ( int  iDatum)

Set the projection to a fresh, new geographical coordinate system based on the indicated Datum.

bool vtCRS::SetProjectionSimple ( bool  bUTM,
int  iUTMZone,
int  iDatum 
)

Convenient way to set a simple projection.

Parameters
bUTMtrue for UTM, false for Geographic.
iUTMZoneIf UTM, this is the zone: 1 through 60 in the northern hemisphere, -1 through -60 for the southern hemisphere.
iDatumThe Datum as either an old USGS code or an EPSG code
void vtCRS::SetSpatialReference ( OGRSpatialReference *  pRef)

Set the projection by copying from a OGRSpatialReference.

bool vtCRS::SetTextDescription ( const char *  type,
const char *  value 
)

Set the projection using a text description.

Parameters
typeThe type of description, either "simple" for short simple string, or "wkt" for a full-length WKT (Well-Known Text) description.
valueThe description itself. A WKT description should be a single string, with no extra whitespace. A simple string can have the following forms:
  • geo, datum D
  • utm, datum D, zone Z
Example:
proj.SetTextDescription("simple", "utm, datum WGS_84, zone 11");
void vtCRS::SetUTMZone ( int  iZone)

Get the UTM zone of the projection.

Parameters
iZoneShould be one of the following values:
  • 1 through 60 for the northern hemisphere
  • -1 through -60 for the southern hemisphere
bool vtCRS::WriteProjFile ( const char *  filename) const

Write the projection to a .prj file.

Returns
true if successful.