Public Member Functions

# OGR_SRSNode Class Reference

`#include <ogr_spatialref.h>`

List of all members.

## Public Member Functions
| OGR_SRSNode (const char *=NULL)
int | GetChildCount () const
OGR_SRSNode * | GetChild (int)
OGR_SRSNode * | GetNode (const char *)
void | InsertChild (OGR_SRSNode *, int)
void | AddChild (OGR_SRSNode *)
int | FindChild (const char *) const
void | DestroyChild (int)
void | StripNodes (const char *)
const char * | GetValue () const
void | SetValue (const char *)
void | MakeValueSafe ()
OGRErr | FixupOrdering ()
OGR_SRSNode * | Clone () const
OGRErr | importFromWkt (char **)
OGRErr | exportToWkt (char **) const
OGRErr | applyRemapper (const char *pszNode, char **papszSrcValues, char **papszDstValues, int nStepSize=1, int bChildOfHit=FALSE)

## Detailed Description

Objects of this class are used to represent value nodes in the parsed representation of the WKT SRS format. For instance UNIT["METER",1] would be rendered into three OGR_SRSNodes. The root node would have a value of UNIT, and two children, the first with a value of METER, and the second with a value of 1.

Normally application code just interacts with the OGRSpatialReference object, which uses the OGR_SRSNode to implement it's data structure; however, this class is user accessable for detailed access to components of an SRS definition.

## Constructor & Destructor Documentation

OGR_SRSNode::OGR_SRSNode | ( | const char * | pszValueIn = `NULL` | ) |

Constructor.

Parameters:

  | pszValueIn | this optional parameter can be used to initialize the value of the node upon creation. If omitted the node will be created with a value of "". Newly created OGR_SRSNodes have no children.

Referenced by Clone().

## Member Function Documentation

void OGR_SRSNode::AddChild | ( | OGR_SRSNode * | poNew | ) |

Add passed node as a child of target node.

Note that ownership of the passed node is assumed by the node on which the method is invoked ... use the Clone() method if the original is to be preserved. New children are always added at the end of the list.

Parameters:

  | poNew | the node to add as a child.

References InsertChild().

Referenced by Clone(), OGRSpatialReference::CloneGeogCS(), OGRSpatialReference::importFromCRSURL(), OGRSpatialReference::importFromProj4(), OGRSpatialReference::importFromURN(), OGRSpatialReference::importFromWkt(), OGRSpatialReference::morphFromESRI(), OGRSpatialReference::morphToESRI(), OGRSpatialReference::SetAngularUnits(), OGRSpatialReference::SetAuthority(), OGRSpatialReference::SetAxes(), OGRSpatialReference::SetCompoundCS(), OGRSpatialReference::SetExtension(), OGRSpatialReference::SetFromUserInput(), OGRSpatialReference::SetGeogCS(), OGRSpatialReference::SetNode(), OGRSpatialReference::SetProjParm(), OGRSpatialReference::SetTargetLinearUnits(), OGRSpatialReference::SetTOWGS84(), and OGRSpatialReference::SetVertCS().

OGRErr OGR_SRSNode::applyRemapper | ( | const char * | pszNode,
|  | char ** | papszSrcValues,
|  | char ** | papszDstValues,
|  | int | nStepSize = `1`,
|  | int | bChildOfHit = `FALSE` |
| ) |  |  |

Remap node values matching list.

Remap the value of this node or any of it's children if it matches one of the values in the source list to the corresponding value from the destination list. If the pszNode value is set, only do so if the parent node matches that value. Even if a replacement occurs, searching continues.

Parameters:

  | pszNode | Restrict remapping to children of this type of node (eg. "PROJECTION")
  | papszSrcValues | a NULL terminated array of source string. If the node value matches one of these (case insensitive) then replacement occurs.
  | papszDstValues | an array of destination strings. On a match, the one corresponding to a source value will be used to replace a node.
  | nStepSize | increment when stepping through source and destination arrays, allowing source and destination arrays to be one interleaved array for instances. Defaults to 1.
  | bChildOfHit | Only TRUE if we the current node is the child of a match, and so needs to be set. Application code would normally pass FALSE for this argument.

Returns:
  returns OGRERR_NONE unless something bad happens. There is no indication returned about whether any replacement occured.

References applyRemapper(), GetChild(), GetChildCount(), and SetValue().

Referenced by applyRemapper(), OGRSpatialReference::morphFromESRI(), and OGRSpatialReference::morphToESRI().

OGR_SRSNode * OGR_SRSNode::Clone | ( |  | ) | const

Make a duplicate of this node, and it's children.

Returns:
  a new node tree, which becomes the responsiblity of the caller.

References AddChild(), and OGR_SRSNode().

Referenced by OGRSpatialReference::Clone(), OGRSpatialReference::CloneGeogCS(), OGRSpatialReference::CopyGeogCSFrom(), OGRSpatialReference::importFromCRSURL(), OGRSpatialReference::importFromProj4(), OGRSpatialReference::importFromURN(), OGRSpatialReference::morphFromESRI(), OGRSpatialReference::SetCompoundCS(), OGRSpatialReference::SetFromUserInput(), OGRSpatialReference::SetGeocCS(), and OGRSpatialReference::StripVertical().

void OGR_SRSNode::DestroyChild | ( | int | iChild | ) |

Remove a child node, and it's subtree.

Note that removing a child node will result in children after it being renumbered down one.

Parameters:

  | iChild | the index of the child.

Referenced by OGRSpatialReference::CopyGeogCSFrom(), OGRSpatialReference::importFromESRI(), OGRSpatialReference::morphFromESRI(), OGRSpatialReference::morphToESRI(), OGRSpatialReference::SetAuthority(), OGRSpatialReference::SetAxes(), OGRSpatialReference::SetGeogCS(), OGRSpatialReference::SetStatePlane(), OGRSpatialReference::SetTargetLinearUnits(), OGRSpatialReference::SetTOWGS84(), and StripNodes().

OGRErr OGR_SRSNode::exportToWkt | ( | char ** | ppszResult | ) | const

Convert this tree of nodes into WKT format.

Note that the returned WKT string should be freed with OGRFree() or CPLFree() when no longer needed. It is the responsibility of the caller.

Parameters:

  | ppszResult | the resulting string is returned in this pointer.

Returns:
  currently OGRERR_NONE is always returned, but the future it is possible error conditions will develop.

References exportToWkt().

Referenced by OGRSpatialReference::exportToWkt(), and exportToWkt().

int OGR_SRSNode::FindChild | ( | const char * | pszValue | ) | const

Find the index of the child matching the given string.

Note that the node value must match pszValue with the exception of case. The comparison is case insensitive.

Parameters:

  | pszValue | the node value being searched for.

Returns:
  the child index, or -1 on failure.

Referenced by OGRSpatialReference::CopyGeogCSFrom(), OGRSpatialReference::Fixup(), OGRSpatialReference::GetAuthorityCode(), OGRSpatialReference::GetAuthorityName(), OGRSpatialReference::morphFromESRI(), OGRSpatialReference::SetAngularUnits(), OGRSpatialReference::SetAuthority(), OGRSpatialReference::SetAxes(), OGRSpatialReference::SetGeogCS(), OGRSpatialReference::SetStatePlane(), OGRSpatialReference::SetTargetLinearUnits(), OGRSpatialReference::SetTOWGS84(), and StripNodes().

OGRErr OGR_SRSNode::FixupOrdering | ( |  | ) |

Correct parameter ordering to match CT Specification.

Some mechanisms to create WKT using OGRSpatialReference, and some imported WKT fail to maintain the order of parameters required according to the BNF definitions in the OpenGIS SF-SQL and CT Specifications. This method attempts to massage things back into the required order.

This method will reorder the children of the node it is invoked on and then recurse to all children to fix up their children.

Returns:
  OGRERR_NONE on success or an error code if something goes wrong.

References FixupOrdering(), GetChild(), GetChildCount(), and GetValue().

Referenced by OGRSpatialReference::FixupOrdering(), and FixupOrdering().

OGR_SRSNode * OGR_SRSNode::GetChild | ( | int | iChild | ) |

Fetch requested child.

Parameters:

  | iChild | the index of the child to fetch, from 0 to GetChildCount() - 1.

Returns:
  a pointer to the child OGR_SRSNode, or NULL if there is no such child.

Referenced by applyRemapper(), OGRSpatialReference::EPSGTreatsAsLatLong(), OGRSpatialReference::EPSGTreatsAsNorthingEasting(), OGRSpatialReference::exportToPCI(), OGRSpatialReference::exportToProj4(), OGRSpatialReference::FindProjParm(), FixupOrdering(), OGRSpatialReference::GetAngularUnits(), OGRSpatialReference::GetAttrValue(), OGRSpatialReference::GetAuthorityCode(), OGRSpatialReference::GetAuthorityName(), OGRSpatialReference::GetAxis(), OGRSpatialReference::GetExtension(), OGRSpatialReference::GetInvFlattening(), OGRSpatialReference::GetPrimeMeridian(), OGRSpatialReference::GetProjParm(), OGRSpatialReference::GetSemiMajor(), OGRSpatialReference::GetTargetLinearUnits(), OGRSpatialReference::GetTOWGS84(), OGRSpatialReference::importFromProj4(), OGRSpatialReference::importFromURN(), OGRSpatialReference::IsSame(), MakeValueSafe(), OGRSpatialReference::morphFromESRI(), OGRSpatialReference::morphToESRI(), OGRSpatialReference::SetAngularUnits(), OGRSpatialReference::SetExtension(), OGRSpatialReference::SetFromUserInput(), OGRSpatialReference::SetLinearUnitsAndUpdateParameters(), OGRSpatialReference::SetNode(), OGRSpatialReference::SetProjParm(), OGRSpatialReference::SetTargetLinearUnits(), StripNodes(), and OGRSpatialReference::StripVertical().

int OGR_SRSNode::GetChildCount | ( |  | ) | const`[inline]`

Get number of children nodes.

Returns:
  0 for leaf nodes, or the number of children nodes.

Referenced by applyRemapper(), OGRSpatialReference::EPSGTreatsAsLatLong(), OGRSpatialReference::EPSGTreatsAsNorthingEasting(), OGRSpatialReference::exportToPCI(), OGRSpatialReference::exportToProj4(), OGRSpatialReference::FindProjParm(), FixupOrdering(), OGRSpatialReference::GetAngularUnits(), OGRSpatialReference::GetAttrValue(), OGRSpatialReference::GetAuthorityCode(), OGRSpatialReference::GetAuthorityName(), OGRSpatialReference::GetAxis(), OGRSpatialReference::GetExtension(), OGRSpatialReference::GetInvFlattening(), OGRSpatialReference::GetPrimeMeridian(), OGRSpatialReference::GetSemiMajor(), OGRSpatialReference::GetTargetLinearUnits(), OGRSpatialReference::GetTOWGS84(), OGRSpatialReference::importFromProj4(), OGRSpatialReference::IsSame(), MakeValueSafe(), OGRSpatialReference::morphToESRI(), OGRSpatialReference::SetAngularUnits(), OGRSpatialReference::SetExtension(), OGRSpatialReference::SetLinearUnitsAndUpdateParameters(), OGRSpatialReference::SetNode(), OGRSpatialReference::SetProjParm(), OGRSpatialReference::SetTargetLinearUnits(), OGRSpatialReference::SetTOWGS84(), and StripNodes().

OGR_SRSNode * OGR_SRSNode::GetNode | ( | const char * | pszName | ) |

Find named node in tree.

This method does a pre-order traversal of the node tree searching for a node with this exact value (case insensitive), and returns it. Leaf nodes are not considered, under the assumption that they are just attribute value nodes.

If a node appears more than once in the tree (such as UNIT for instance), the first encountered will be returned. Use GetNode() on a subtree to be more specific.

Parameters:

  | pszName | the name of the node to search for.

Returns:
  a pointer to the node found, or NULL if none.

References GetNode().

Referenced by OGRSpatialReference::exportToProj4(), OGRSpatialReference::GetAttrNode(), GetNode(), and OGRSpatialReference::SetGeocCS().

const char * OGR_SRSNode::GetValue | ( |  | ) | const`[inline]`

Fetch value string for this node.

Returns:
  A non-NULL string is always returned. The returned pointer is to the internal value of this node, and should not be modified, or freed.

Referenced by OGRSpatialReference::EPSGTreatsAsLatLong(), OGRSpatialReference::EPSGTreatsAsNorthingEasting(), OGRSpatialReference::exportToPCI(), OGRSpatialReference::exportToProj4(), OGRSpatialReference::FindProjParm(), FixupOrdering(), OGRSpatialReference::GetAngularUnits(), OGRSpatialReference::GetAttrValue(), OGRSpatialReference::GetAuthorityCode(), OGRSpatialReference::GetAuthorityName(), OGRSpatialReference::GetAxis(), OGRSpatialReference::GetExtension(), OGRSpatialReference::GetInvFlattening(), OGRSpatialReference::GetPrimeMeridian(), OGRSpatialReference::GetProjParm(), OGRSpatialReference::GetSemiMajor(), OGRSpatialReference::GetTargetLinearUnits(), OGRSpatialReference::GetTOWGS84(), OGRSpatialReference::importFromCRSURL(), OGRSpatialReference::importFromProj4(), OGRSpatialReference::importFromURN(), OGRSpatialReference::IsCompound(), OGRSpatialReference::IsGeocentric(), OGRSpatialReference::IsGeographic(), OGRSpatialReference::IsProjected(), OGRSpatialReference::IsSame(), OGRSpatialReference::IsVertical(), OGRSpatialReference::morphFromESRI(), OGRSpatialReference::morphToESRI(), OGRSpatialReference::SetExtension(), OGRSpatialReference::SetFromUserInput(), OGRSpatialReference::SetGeocCS(), OGRSpatialReference::SetLinearUnitsAndUpdateParameters(), OGRSpatialReference::SetNode(), OGRSpatialReference::SetProjCS(), OGRSpatialReference::SetProjection(), OGRSpatialReference::SetProjParm(), OGRSpatialReference::SetVertCS(), and OGRSpatialReference::StripCTParms().

OGRErr OGR_SRSNode::importFromWkt | ( | char ** | ppszInput | ) |

Import from WKT string.

This method will wipe the existing children and value of this node, and reassign them based on the contents of the passed WKT string. Only as much of the input string as needed to construct this node, and it's children is consumed from the input string, and the input string pointer is then updated to point to the remaining (unused) input.

Parameters:

  | ppszInput | Pointer to pointer to input. The pointer is updated to point to remaining unused input text.

Returns:
  OGRERR_NONE if import succeeds, or OGRERR_CORRUPT_DATA if it fails for any reason.

void OGR_SRSNode::InsertChild | ( | OGR_SRSNode * | poNew,
|  | int | iChild |
| ) |  |  |

Insert the passed node as a child of target node, at the indicated position.

Note that ownership of the passed node is assumed by the node on which the method is invoked ... use the Clone() method if the original is to be preserved. All existing children at location iChild and beyond are push down one space to make space for the new child.

Parameters:

  | poNew | the node to add as a child.
  | iChild | position to insert, use 0 to insert at the beginning.

Referenced by AddChild(), OGRSpatialReference::CopyGeogCSFrom(), OGRSpatialReference::morphFromESRI(), OGRSpatialReference::SetGeocCS(), OGRSpatialReference::SetGeogCS(), OGRSpatialReference::SetProjCS(), OGRSpatialReference::SetProjection(), and OGRSpatialReference::SetTOWGS84().

void OGR_SRSNode::MakeValueSafe | ( |  | ) |

Massage value string, stripping special characters so it will be a database safe string.

The operation is also applies to all subnodes of the current node.

References GetChild(), GetChildCount(), and MakeValueSafe().

Referenced by MakeValueSafe().

void OGR_SRSNode::SetValue | ( | const char * | pszNewValue | ) |

Set the node value.

Parameters:

  | pszNewValue | the new value to assign to this node. The passed string is duplicated and remains the responsibility of the caller.

Referenced by applyRemapper(), OGRSpatialReference::morphFromESRI(), OGRSpatialReference::morphToESRI(), OGRSpatialReference::SetAngularUnits(), OGRSpatialReference::SetExtension(), OGRSpatialReference::SetNode(), OGRSpatialReference::SetProjParm(), and OGRSpatialReference::SetTargetLinearUnits().

void OGR_SRSNode::StripNodes | ( | const char * | pszName | ) |

Strip child nodes matching name.

Removes any decendent nodes of this node that match the given name. Of course children of removed nodes are also discarded.

Parameters:

  | pszName | the name for nodes that should be removed.

References DestroyChild(), FindChild(), GetChild(), GetChildCount(), and StripNodes().

Referenced by OGRSpatialReference::exportToPrettyWkt(), OGRSpatialReference::importFromEPSG(), OGRSpatialReference::StripCTParms(), and StripNodes().

The documentation for this class was generated from the following files:

- ogr_spatialref.h
- ogr_srsnode.cpp

Generated for GDAL by 1.7.1.