OGR
Classes | Public Member Functions | List of all members
OGR_SRSNode Class Reference

#include <ogr_spatialref.h>

Classes

struct  Listener
 

Public Member Functions

 OGR_SRSNode (const char *=nullptr)
 
void RegisterListener (const std::shared_ptr< Listener > &listener)
 
int IsLeafNode () const
 
int GetChildCount () const
 
OGR_SRSNodeGetChild (int)
 
const OGR_SRSNodeGetChild (int) const
 
OGR_SRSNodeGetNode (const char *)
 
const OGR_SRSNodeGetNode (const char *) const
 
void InsertChild (OGR_SRSNode *, int)
 
void AddChild (OGR_SRSNode *)
 
int FindChild (const char *) const
 
void DestroyChild (int)
 
void ClearChildren ()
 
void StripNodes (const char *)
 
const char * GetValue () const
 
void SetValue (const char *)
 
void MakeValueSafe ()
 
OGR_SRSNodeClone () const
 
OGRErr importFromWkt (char **)
 
OGRErr importFromWkt (const char **)
 
OGRErr exportToWkt (char **) const
 
OGRErr exportToPrettyWkt (char **, int=1) const
 

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 its data structure; however, this class is user accessible for detailed access to components of an SRS definition.

Constructor & Destructor Documentation

◆ OGR_SRSNode()

OGR_SRSNode::OGR_SRSNode ( const char *  pszValueIn = nullptr)
explicit

Constructor.

Parameters
pszValueInthis 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

◆ AddChild()

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
poNewthe node to add as a child.

References InsertChild().

Referenced by Clone(), OGRSpatialReference::SetAuthority(), OGRSpatialReference::SetAxes(), OGRSpatialReference::SetExtension(), OGRSpatialReference::SetNode(), OGRSpatialReference::SetProjParm(), and OGRSpatialReference::SetTargetLinearUnits().

◆ ClearChildren()

void OGR_SRSNode::ClearChildren ( )

Clear children nodes

References CPLFree.

◆ Clone()

OGR_SRSNode * OGR_SRSNode::Clone ( ) const

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

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

References AddChild(), and OGR_SRSNode().

◆ DestroyChild()

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
iChildthe index of the child.

Referenced by OGRSpatialReference::SetAuthority(), OGRSpatialReference::SetAxes(), OGRSpatialReference::SetTargetLinearUnits(), and StripNodes().

◆ exportToPrettyWkt()

OGRErr OGR_SRSNode::exportToPrettyWkt ( char **  ppszResult,
int  nDepth = 1 
) const

Convert this tree of nodes into pretty WKT format.

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

Parameters
ppszResultthe resulting string is returned in this pointer.
nDepthdepth of the node
Returns
currently OGRERR_NONE is always returned, but the future it is possible error conditions will develop.

< Success

References CPLCalloc(), CPLMalloc(), CSLDestroy(), exportToPrettyWkt(), GetChildCount(), and OGRERR_NONE.

Referenced by exportToPrettyWkt().

◆ exportToWkt()

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 CPLFree() when no longer needed. It is the responsibility of the caller.

Parameters
ppszResultthe resulting string is returned in this pointer.
Returns
currently OGRERR_NONE is always returned, but the future it is possible error conditions will develop.

< Success

References CPLCalloc(), CPLMalloc(), CSLDestroy(), exportToWkt(), and OGRERR_NONE.

Referenced by exportToWkt().

◆ FindChild()

int OGR_SRSNode::FindChild ( const char *  pszValueIn) 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
pszValueInthe node value being searched for.
Returns
the child index, or -1 on failure.

References EQUAL.

Referenced by OGRSpatialReference::GetAuthorityCode(), OGRSpatialReference::GetAuthorityName(), OGRSpatialReference::SetAuthority(), OGRSpatialReference::SetAxes(), OGRSpatialReference::SetTargetLinearUnits(), and StripNodes().

◆ GetChild() [1/2]

OGR_SRSNode * OGR_SRSNode::GetChild ( int  iChild)

◆ GetChild() [2/2]

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

Fetch requested child.

Parameters
iChildthe 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.

◆ GetChildCount()

int OGR_SRSNode::GetChildCount ( ) const
inline

◆ GetNode() [1/2]

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
pszNamethe name of the node to search for.
Returns
a pointer to the node found, or NULL if none.

References EQUAL, and GetNode().

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

◆ GetNode() [2/2]

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

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
pszNamethe name of the node to search for.
Returns
a pointer to the node found, or NULL if none.

References GetNode().

◆ GetValue()

const char * OGR_SRSNode::GetValue ( ) const
inline

◆ importFromWkt() [1/2]

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 its children is consumed from the input string, and the input string pointer is then updated to point to the remaining (unused) input.

Parameters
ppszInputPointer 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.
Deprecated:
GDAL 2.3. Use importFromWkt(const char**) instead.

Referenced by importFromWkt().

◆ importFromWkt() [2/2]

OGRErr OGR_SRSNode::importFromWkt ( const 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 its children is consumed from the input string, and the input string pointer is then updated to point to the remaining (unused) input.

Parameters
ppszInputPointer 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.
Since
GDAL 2.3

References importFromWkt().

◆ InsertChild()

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
poNewthe node to add as a child.
iChildposition to insert, use 0 to insert at the beginning.

References CPLRealloc().

Referenced by AddChild().

◆ IsLeafNode()

int OGR_SRSNode::IsLeafNode ( ) const
inline

Return whether this is a leaf node.

Returns
TRUE or FALSE

◆ MakeValueSafe()

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().

◆ RegisterListener()

void OGR_SRSNode::RegisterListener ( const std::shared_ptr< Listener > &  listener)

Register a (single) listener.

◆ SetValue()

void OGR_SRSNode::SetValue ( const char *  pszNewValue)

Set the node value.

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

References CPLFree, and CPLStrdup().

Referenced by OGRSpatialReference::SetExtension(), OGRSpatialReference::SetNode(), OGRSpatialReference::SetProjParm(), and OGRSpatialReference::SetTargetLinearUnits().

◆ StripNodes()

void OGR_SRSNode::StripNodes ( const char *  pszName)

Strip child nodes matching name.

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

Parameters
pszNamethe name for nodes that should be removed.

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

Referenced by StripNodes().


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

Generated for GDAL by doxygen 1.8.14.