Holds information about coordinate system and projection of the data. More...
Public Member Functions | |
bool | Clear () |
Returns object to initial empty state. More... | |
GeoProjection | Clone () |
Creates a copy GeoProjection object More... | |
bool | CopyFrom (GeoProjection sourceProj) |
Copies information from another GeoProjection object. More... | |
string | ExportToEsri () |
Exports projection string to ESRI WKT format. More... | |
string | ExportToProj4 () |
Exports information to the proj4 format. More... | |
string | ExportToWKT () |
Exports information to the WKT format. More... | |
string | get_ErrorMsg (int ErrorCode) |
Gets the description of the specific error code. More... | |
bool | get_GeogCSParam (tkGeogCSParameter Name, ref double pVal) |
Gets specified parameter of the geographic coordinate system. More... | |
bool | get_IsSame (GeoProjection proj) |
Returns a boolean value which indicates whether 2 projections are identical. More... | |
bool | get_IsSameExt (GeoProjection proj, Extents bounds, int numSamplingPoints) |
Performs a test of identity for 2 projections. More... | |
bool | get_IsSameGeogCS (GeoProjection proj) |
Returns a boolean value which indicates whether 2 projections belong to the same geographic coordinate system. More... | |
bool | get_ProjectionParam (tkProjectionParameter Name, ref double Value) |
Returns specified parameter of the projection More... | |
bool | ImportFromAutoDetect (string proj) |
Initializes geoprojection from the input string of arbitrary format. More... | |
bool | ImportFromEPSG (int projCode) |
Initializes geoprojection object from EPSG numeric code. More... | |
bool | ImportFromESRI (string proj) |
Initializes geoprojection object from ESRI WKT format. More... | |
bool | ImportFromProj4 (string proj) |
Initializes geoprojection object from proj4 format. More... | |
bool | ImportFromWKT (string proj) |
Initializes geoprojection object from OGC WKT format. More... | |
bool | ReadFromFile (string Filename) |
Initializes geoprojection from the specified file. More... | |
bool | ReadFromFileEx (string Filename, bool esri) |
Reads projection string from a file. More... | |
bool | SetGoogleMercator () |
Sets so called Google Mercator projection (aka Spherical Mercator; EPSG:3857), commonly used by tile servers. More... | |
void | SetNad83Projection (tkNad83Projection Projection) |
Initializes the object with NAD83 projection specified by enumerated constant. More... | |
void | SetWellKnownGeogCS (tkCoordinateSystem newVal) |
Initializes the object with well known geographic coordinate system. More... | |
bool | SetWgs84 () |
Sets WGS84 geographic coordinates system (EPSG:4326). More... | |
void | SetWgs84Projection (tkWgs84Projection Projection) |
Initializes the object with WGS84 projection specified by enumerated constant. More... | |
bool | StartTransform (GeoProjection target) |
Opens transformation to the specified target projection. The transformation will be used by GeoProjection. Transform calls until GeoProjection.StopTransform is called. More... | |
void | StopTransform () |
Stops transformation created by GeoProjection.StartTransform call. More... | |
bool | Transform (ref double x, ref double y) |
Transforms a single point from this projection to target projection specified in GeoProjection.StartTransform call. More... | |
bool | TryAutoDetectEpsg (out int epsgCode) |
Tries to determine EPSG code projection currently stored in the object. More... | |
bool | WriteToFile (string Filename) |
Writes projection string in ESRI WKT format to the specified file. More... | |
bool | WriteToFileEx (string Filename, bool esri) |
Writes projection string to a file. More... | |
Properties | |
string | GeogCSName [get] |
Returns the name of the coordinate system. More... | |
ICallback | GlobalCallback [get, set] |
Gets or sets a callback object which is used to report errors. More... | |
bool | HasTransformation [get] |
Gets a value indicating whether transformation to some target projection was opened with GeoProjection.StartTransform() call. More... | |
double | InverseFlattening [get] |
Returns the inverse flattening of the reference ellipsoid of the coordinate system. More... | |
bool | IsEmpty [get] |
Gets a boolean value which indicates whether any projection definition is stored in the object. More... | |
bool | IsFrozen [get] |
Gets a value indicating whether the object can be changed. More... | |
bool | IsGeographic [get] |
Gets a boolean value which indicates whether the coordinate system stored in the object is the geographic one. More... | |
bool | IsLocal [get] |
Gets a boolean value which indicates whether the coordinate system stored in the object is the local one. More... | |
bool | IsProjected [get] |
Gets a boolean value which indicates whether the coordinate system stored in the object is the projected one. More... | |
string | Key [get, set] |
A text string associated with the instance of the class. Any value can be stored by developer in this property. More... | |
int | LastErrorCode [get] |
Retrieves the numeric code of the last error that took place in the class. More... | |
tkUnitsOfMeasure | LinearUnits [get] |
Gets the linear units from projection definition. More... | |
string | Name [get] |
Returns the name of the coordinate system. More... | |
string | ProjectionName [get] |
The name of the projected coordinate system. More... | |
double | SemiMajor [get] |
Returns the half of the major axis of the reference ellipsoid. More... | |
double | SemiMinor [get] |
Returns the half of the minor axis of the reference ellipsoid. More... | |
Holds information about coordinate system and projection of the data.
1. Formats and initialization. Information about coordinate system and projection can be represented in several formats:
EPSG codes represent a standardization effort to map each projection to the unique code. It's recommended to use these codes whenever possible. GeoProjection.ImportFromAutoDetect() method implements logic to discern the format of the provided projection string.
Projection is usually stored in a separate file with .prj extension which accompany the data file. GeoProjection.ReadFromFile() and GeoProjection.WriteToFile() to interact with projection file.
2. Classification and parameters. Coordinate systems are split in 2 broad categories:
Use GeoProjection.IsGeographic, GeoProjection.IsProjected properties to distinguish geographical and projected coordinate systems. To retrieve parameters of geographic coordinate system - GeoProjection.get_GeogCSParam. To extract parameters of the projection use GeoProjection.get_ProjectionParam.
3. Well-known coordinate systems. The most widely spread geographic coordinate system is so called WGS84. It is based on WGS84 datum and uses GRS80 ellipsoid. Universal Transverse Mercator is the most widely used projection of this coordinate system, which defines sixty 6-degree zones which cover the whole globe. There are several methods to setup the widely used coordinate systems and projections: GeoProjection.SetWellKnownGeogCS(), GeoProjection.SetWgs84Projection(), GeoProjection.SetNad83Projection().
The definition of WGS84 coordinate system and projection in different formats can be as following:
bool GeoProjection.Clear | ( | ) |
Returns object to initial empty state.
GeoProjection GeoProjection.Clone | ( | ) |
Creates a copy GeoProjection object
It's not guaranteed that exact clone will be created. The method uses GeoProjection.ExportFromWKT and GeoProjection.ImportFromWKT pair of methods which may yield slightly different result, as ExportToWKT may add defaults for parameters missing in initial Proj4 definition.
bool GeoProjection.CopyFrom | ( | GeoProjection | sourceProj | ) |
Copies information from another GeoProjection object.
sourceProj | The geoprojection to copy information from. |
string GeoProjection.ExportToEsri | ( | ) |
Exports projection string to ESRI WKT format.
string GeoProjection.ExportToProj4 | ( | ) |
Exports information to the proj4 format.
string GeoProjection.ExportToWKT | ( | ) |
string GeoProjection.get_ErrorMsg | ( | int | ErrorCode | ) |
Gets the description of the specific error code.
ErrorCode | The error code returned by ShapefileCategories.LastErrorCode. |
bool GeoProjection.get_GeogCSParam | ( | tkGeogCSParameter | Name, |
ref double | pVal | ||
) |
Gets specified parameter of the geographic coordinate system.
Name | The parameter to return. |
pVal | The returned value of the parameter. |
bool GeoProjection.get_IsSame | ( | GeoProjection | proj | ) |
Returns a boolean value which indicates whether 2 projections are identical.
Projections will be reported as non-identical if at least one of parameters differ between them, even if it doesn't affect the reprojection process. For example, different name of the datums, while all the parameters of the datums match.
proj | The projection object to compare the current projection with. |
bool GeoProjection.get_IsSameExt | ( | GeoProjection | proj, |
Extents | bounds, | ||
int | numSamplingPoints | ||
) |
Performs a test of identity for 2 projections.
The method perform reprojection of the random points in the given extents to WGS84 coordinate system (EPSG:4326) for both projections being compared. In case the coordinates of the projected points match - projections are considered the same. This doesn't mean that result of test will be the same for some other extents or that projection definitions are completely identical. But it ensures that data layers with these 2 projection can be displayed jointly within the tested extents.
proj | The compared projection definition. |
bounds | The bounding box to take random points for comparison from. |
numSamplingPoints | Number of the random points to take for sampling. |
bool GeoProjection.get_IsSameGeogCS | ( | GeoProjection | proj | ) |
Returns a boolean value which indicates whether 2 projections belong to the same geographic coordinate system.
proj | The compared projection definition. |
bool GeoProjection.get_ProjectionParam | ( | tkProjectionParameter | Name, |
ref double | Value | ||
) |
Returns specified parameter of the projection
Name | The parameter to return. |
Value | The returned value of the parameter. |
bool GeoProjection.ImportFromAutoDetect | ( | string | proj | ) |
Initializes geoprojection from the input string of arbitrary format.
See GDAL documentation on particular formats supported.
proj | The string to initialize projection from. |
bool GeoProjection.ImportFromEPSG | ( | int | projCode | ) |
Initializes geoprojection object from EPSG numeric code.
projCode | EPSG code. |
bool GeoProjection.ImportFromESRI | ( | string | proj | ) |
Initializes geoprojection object from ESRI WKT format.
proj | The string in the ESRI WKT format. |
bool GeoProjection.ImportFromProj4 | ( | string | proj | ) |
Initializes geoprojection object from proj4 format.
proj | The string in the proj4 format. |
bool GeoProjection.ImportFromWKT | ( | string | proj | ) |
Initializes geoprojection object from OGC WKT format.
proj | The string in the OGC WKT format. |
bool GeoProjection.ReadFromFile | ( | string | Filename | ) |
Initializes geoprojection from the specified file.
The method is used by MapWinGIS for reading projection of the data layer. The file with projection must have the same name as the name of the data file and .prj extension.
Filename | The name of the file to read projection string from. |
bool GeoProjection.ReadFromFileEx | ( | string | Filename, |
bool | esri | ||
) |
Reads projection string from a file.
Filename | The filename. |
esri | If set to true ESRI WKT format is used. |
bool GeoProjection.SetGoogleMercator | ( | ) |
Sets so called Google Mercator projection (aka Spherical Mercator; EPSG:3857), commonly used by tile servers.
void GeoProjection.SetNad83Projection | ( | tkNad83Projection | Projection | ) |
Initializes the object with NAD83 projection specified by enumerated constant.
Projection | Numeric code of the projection (EPSG code). |
void GeoProjection.SetWellKnownGeogCS | ( | tkCoordinateSystem | newVal | ) |
Initializes the object with well known geographic coordinate system.
newVal | Numeric code of the projection (EPSG code). |
bool GeoProjection.SetWgs84 | ( | ) |
Sets WGS84 geographic coordinates system (EPSG:4326).
Equirectangular projection will be implicitly used during rendering.
void GeoProjection.SetWgs84Projection | ( | tkWgs84Projection | Projection | ) |
Initializes the object with WGS84 projection specified by enumerated constant.
Projection | Numeric code of the projection (EPSG code). |
bool GeoProjection.StartTransform | ( | GeoProjection | target | ) |
Opens transformation to the specified target projection. The transformation will be used by GeoProjection. Transform calls until GeoProjection.StopTransform is called.
target | The target projection. |
void GeoProjection.StopTransform | ( | ) |
Stops transformation created by GeoProjection.StartTransform call.
bool GeoProjection.Transform | ( | ref double | x, |
ref double | y | ||
) |
Transforms a single point from this projection to target projection specified in GeoProjection.StartTransform call.
x | X coordinate of point to transform. |
y | Y coordinate of point to transform. |
bool GeoProjection.TryAutoDetectEpsg | ( | out int | epsgCode | ) |
Tries to determine EPSG code projection currently stored in the object.
epsgCode | Determined epsgCode or -1 on failure. |
It uses GDAL's OGRSpatialReference.AutoIdentifyEPSG method and recognized limited number of commonly used coordinate systems (WGS84, NAD83, etc) and their zonal projections, plus information stored in Authority node for WKT format will be used as well.
bool GeoProjection.WriteToFile | ( | string | Filename | ) |
Writes projection string in ESRI WKT format to the specified file.
Filename | The name of the file to write the string in. |
bool GeoProjection.WriteToFileEx | ( | string | Filename, |
bool | esri | ||
) |
Writes projection string to a file.
Filename | The filename. |
esri | If set to true ESRI WKT format is used. |
|
get |
Returns the name of the coordinate system.
An empty string will be returned unless GeoProjection.IsGeographic property returns true.
|
getset |
Gets or sets a callback object which is used to report errors.
|
get |
Gets a value indicating whether transformation to some target projection was opened with GeoProjection.StartTransform() call.
|
get |
Returns the inverse flattening of the reference ellipsoid of the coordinate system.
|
get |
Gets a boolean value which indicates whether any projection definition is stored in the object.
|
get |
Gets a value indicating whether the object can be changed.
When frozen all the methods which can change the inner state of object will fail. The property is set to true for map projection applied with AxMap.SetGeoProjection (see details there).
|
get |
Gets a boolean value which indicates whether the coordinate system stored in the object is the geographic one.
|
get |
Gets a boolean value which indicates whether the coordinate system stored in the object is the local one.
|
get |
Gets a boolean value which indicates whether the coordinate system stored in the object is the projected one.
|
getset |
A text string associated with the instance of the class. Any value can be stored by developer in this property.
|
get |
Retrieves the numeric code of the last error that took place in the class.
The usage of this property clears the error code.
|
get |
Gets the linear units from projection definition.
|
get |
Returns the name of the coordinate system.
Either GeoProjection.GeogCSName or GeoProjection.ProjectionName will be returned depending on the type of coordinate system.
|
get |
The name of the projected coordinate system.
An empty string will be returned unless GeoProjection.IsProjected property returns true.
|
get |
Returns the half of the major axis of the reference ellipsoid.
|
get |
Returns the half of the minor axis of the reference ellipsoid.