10.2.5: AGSSpatialReference Class Reference
10.2.5
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
AGSSpatialReference Class Reference

Description

Instances of this class represent a spatial reference. Each spatial reference can be represented by either a well-known ID (wkid), or a well-known text (wkt). Spatial References define the spatial properties of a geometry, for instance the coordinate system it uses. There are 2 broad classes of coordinate systems - Geographic & Projected. A Geographic Coordinate system uses a 3-dimensional spherical surface to define locations on the earth. A Projected Coordinate system on the other hand uses a flat, 2-dimensional surface. More information about spatial references, map projections, and coordinate systems is available here.

It is very important to associate spatial data, such as geometry objects, with corresponding spatial references.

Defined in:
AGSSpatialReference.h ( ArcGIS library)

Since
1.0
Inheritance diagram for AGSSpatialReference:
<AGSCoding>

Instance Methods

(double) - convertValue:fromUnit:
 
(double) - convertValue:toUnit:
 
(void) - decodeWithJSON:
 
(NSDictionary *) - encodeToJSON
 
(void) - encodeToJSON:forKey:
 
(id) - initWithJSON:
 
(id) - initWithWKID:
 
(id) - initWithWKID:WKT:
 
(id) - initWithWKT:
 
(BOOL) - inLinearUnits
 
(BOOL) - isAnyWebMercator
 
(BOOL) - isEqualToSpatialReference:
 
(BOOL) - isEqualToWKID:
 
(BOOL) - isSupported
 
(BOOL) - isWGS84
 
(AGSSRUnit- unit
 

Class Methods

(id) + spatialReferenceWithWKID:
 
(id) + spatialReferenceWithWKID:WKT:
 
(id) + spatialReferenceWithWKT:
 
(AGSSpatialReference *) + webMercatorSpatialReference
 
(AGSSpatialReference *) + wgs84SpatialReference
 

Properties

NSUInteger wkid
 
NSString * wkt
 

Method Documentation

- (double) convertValue: (double)  val
fromUnit: (AGSSRUnit fromUnit 

Converts the value from a specified unit to the same unit as the current spatial reference. Will return nan if trying to convert between angular and linear units, for example, Decimal Degrees and Meters.

Parameters
valThe value to convert.
fromUnitThe unit to convert from.
Returns
The converted value.
Since
1.8
- (double) convertValue: (double)  val
toUnit: (AGSSRUnit unit 

Converts the value in the same unit as the current spatial reference to a specified unit. Will return nan if trying to convert between angular and linear units, for example, Decimal Degrees and Meters.

Parameters
valThe value to convert.
unitThe unit to convert to.
Returns
The converted value.
Since
1.8
- (void) decodeWithJSON: (NSDictionary *)  json
optionalinherited

Decode object from JSON representation.

Parameters
jsonThe JSON representation of the object to be decoded.
Since
1.0
- (NSDictionary *) encodeToJSON
optionalinherited

Encode and return JSON representation for object.

Returns
JSON representation of object.
Since
1.0
- (void) encodeToJSON: (NSMutableDictionary *)  json
forKey: (NSString *)  key 

Encodes spatial reference to json conditionally based on existence of a wkt

Parameters
jsonThe dictionary to encode spatial reference to.
keyThe encoded spatial reference is paired with.
Since
1.0
- (id) initWithJSON: (NSDictionary *)  json
optionalinherited

Initialize and return object from JSON representation.

Parameters
jsonThe JSON representation of the object to be created.
Returns
Object decoded from JSON representation.
Since
1.0

Reimplemented in AGSWebMapFeatureCollection.

- (id) initWithWKID: (NSUInteger)  wkid

Initialize a spatial reference with wkid.

Parameters
wkidThe well-known ID to initialize the spatial reference with.
Since
1.0
- (id) initWithWKID: (NSUInteger)  wkid
WKT: (NSString *)  wkt 

Initialize spatial reference with well-known ID and text. This is the designated initializer.

Parameters
wkidThe well-known ID.
wktThe well-known text.
Returns
A new spatial reference object.
Since
1.0
- (id) initWithWKT: (NSString *)  wkt

Initialize a spatial reference with wkt.

Parameters
wktThe well-known text to initialize the spatial reference with.
Since
1.0
- (BOOL) inLinearUnits

Whether the unit for this spatial reference is linear.

Since
10.2
- (BOOL) isAnyWebMercator

Returns YES if wkid equals any of the "web mercator" projections.

Since
1.0
- (BOOL) isEqualToSpatialReference: (AGSSpatialReference *)  sr

Returns YES if spatial references are both web mercator. If not, it will return YES if wkid or wkt are equal.

Parameters
srThe AGSSpatialReference to be compared.
Since
1.0
- (BOOL) isEqualToWKID: (NSUInteger)  wkid

Returns YES if spatial reference and wkid are both web mercator. If not, it will return YES if wkid is equal.

Parameters
wkidThe well-known ID to be compared.
Since
2.2
- (BOOL) isSupported

Returns YES if the spatial reference's wkid or wkt is supported by the the AGSGeometryEngine

Since
10.1.1
- (BOOL) isWGS84

Returns YES if wkid equals 4326.

Since
1.0
+ (id) spatialReferenceWithWKID: (NSUInteger)  wkid

Initialize an autoreleased spatial reference with wkid.

Parameters
wkidThe well-known ID to initialize the spatial reference with.
Since
1.0
+ (id) spatialReferenceWithWKID: (NSUInteger)  wkid
WKT: (NSString *)  wkt 

Create new autoreleased spatial reference object.

Parameters
wkidThe well-known ID.
wktThe well-known text.
Returns
A new spatial reference object.
Since
1.0
+ (id) spatialReferenceWithWKT: (NSString *)  wkt

Initialize an autoreleased spatial reference with wkt.

Parameters
wktThe well-known text to initialize the spatial reference with.
Since
1.0
- (AGSSRUnit) unit

The units that the spatial reference coordinates are in.

Since
1.8
+ (AGSSpatialReference*) webMercatorSpatialReference

Returns a spatial reference object in web mercator.

Since
1.8
+ (AGSSpatialReference*) wgs84SpatialReference

Returns a spatial reference object in WGS84 (4326).

Since
1.8

Property Documentation

- (NSUInteger) wkid
readnonatomicassign

The well-known ID of the spatial reference.

Since
1.0
- (NSString*) wkt
readnonatomiccopy

The well-known text of the spatial reference.

Availability:
This feature is only available with services from ArcGIS Server 10.0 or above

Since
1.0