MapLink Pro 11.2
Envitia MapLink Pro: The Ultimate Mapping Application Toolkit
Loading...
Searching...
No Matches
TSLOptimizedNetwork Class Reference

Detailed Description

This class represents a read-only network of nodes and links, where the nodes are TSLOptNode objects and the links are TSLOptLink objects. The network is optimized in both its usage of memory and vastly improved loading performance. When an optimized network is loaded into from disk, only its nodes and links are actually loaded into memory; all attribute and geometry information stays on disk. If a user requires this information, he must request it through the network.

Classes

class  const_link_iterator
 
class  const_node_iterator
 
class  const_turn_iterator
 
class  Query
 

Public Types

enum  query_type { tsl_nwk_find_nodes = 0 , tsl_nwk_find_links = 1 , tsl_nwk_find_both = 2 }
 

Public Member Functions

TSLVariant attribute (const TSLOptLink *link, int N) const
 
TSLVariant attribute (const TSLOptNode *node, int N) const
 
const_link_iterator beginLinks () const
 
const_link_iterator beginLinks (const const_node_iterator &it) const
 
const_link_iterator beginLinks (int src) const
 
const_node_iterator beginNodes () const
 
const_turn_iterator beginTurns () const
 
const_turn_iterator beginTurns (const const_node_iterator &it) const
 
const_turn_iterator beginTurns (int src) const
 
double coordinateScaleFactor () const
 
void destroy ()
 
const_link_iterator endLinks () const
 
const_link_iterator endLinks (const const_node_iterator &it) const
 
const_link_iterator endLinks (int src) const
 
const_node_iterator endNodes () const
 
const_turn_iterator endTurns () const
 
const_turn_iterator endTurns (const const_node_iterator &it) const
 
const_turn_iterator endTurns (int src) const
 
Queryfind (const TSLEnvelope &extent, const TSLOptNwkFinder &filter, query_type filter_mode=tsl_nwk_find_both) const
 
const_link_iterator findLink (const TSLCoord &location, int aperture) const
 
QueryfindLinks (const TSLCoord &location, int aperture, const TSLOptNwkFinder *filter=NULL, int limit=-1, bool useSpatialIndex=true)
 
const_node_iterator findNode (const TSLCoord &location, int aperture) const
 
TSLCoord firstPoint (const TSLOptLink *link) const
 
const TSLVariantgetAttributes (const TSLOptLink *link) const
 
const TSLVariantgetAttributes (const TSLOptNode *node) const
 
const TSLOptLinkgetLink (int index) const
 
const TSLOptNodegetNode (int index) const
 
TSLCoordSetgetPoints (const TSLOptLink *link) const
 
void invalidateSpatialIndex ()
 
bool isEdgeNode (int index) const
 
bool isLatLong () const
 
bool isStitchNode (int index) const
 
TSLCoord lastPoint (const TSLOptLink *link) const
 
bool loadSpatialIndex (TSLifstream &inputStream)
 
const TSLOptNodelinkDestinNode (const const_link_iterator &it) const
 
int linkDestinNodePos (const const_link_iterator &it) const
 
bool linkNodes (const const_link_iterator &it, TSLOptNode &src, TSLOptNode &dst) const
 
bool linkNodes (const TSLOptLink &link, TSLOptNode &src, TSLOptNode &dst) const
 
const TSLOptNodelinkSourceNode (const const_link_iterator &it) const
 
int linkSourceNodePos (const const_link_iterator &it) const
 
bool load (const char *fileName)
 
bool loadAttributes ()
 
bool loadGeometry ()
 
int numAttributes (const TSLOptLink *link) const
 
int numAttributes (const TSLOptNode *node) const
 
int numPoints (const TSLOptLink *link) const
 
TSLCoord point (const TSLOptLink *link, int N) const
 
bool saveSpatialIndex (TSLofstream &outputStream)
 
int sizeNodes () const
 
int sizeLinks () const
 
int sizeTurns () const
 
bool spatialIndexUpToDate () const
 
const_link_iterator turnDestinLink (const const_turn_iterator &it) const
 
const_link_iterator turnSourceLink (const const_turn_iterator &it) const
 
bool updateSpatialIndex ()
 
void * operator new (size_t size)
 
void * operator new (size_t size, char *filename, int line)
 

Member Enumeration Documentation

◆ query_type

The type of query

Enumerator
tsl_nwk_find_nodes 

search for nodes only

tsl_nwk_find_links 

search for links only

tsl_nwk_find_both 

search for both nodes and links

Member Function Documentation

◆ attribute() [1/2]

TSLVariant TSLOptimizedNetwork::attribute ( const TSLOptLink * link,
int N ) const

Queries the supplied link for the attribute at the specified index.

Parameters
linkA pointer to the TSLOptLink object.
NThe index position.
Returns
the link's attribute at the specified index.

◆ attribute() [2/2]

TSLVariant TSLOptimizedNetwork::attribute ( const TSLOptNode * node,
int N ) const

Queries the supplied node for the attribute at the specified index.

Parameters
nodeA pointer to the TSLOptNode object.
NThe index position.
Returns
the node's attribute at the specified index.

◆ beginLinks() [1/3]

const_link_iterator TSLOptimizedNetwork::beginLinks ( ) const

Access method (const) for links in the network.

Returns a const_link_iterator to the first link.

◆ beginLinks() [2/3]

const_link_iterator TSLOptimizedNetwork::beginLinks ( const const_node_iterator & it) const

Access method (const) for the links outgoing from a given node in the network.

Parameters
itReference to the node iterator.
Returns
a const_link_iterator to the first outgoing link of the node associated with the given const_node_iterator.

◆ beginLinks() [3/3]

const_link_iterator TSLOptimizedNetwork::beginLinks ( int src) const

Access method (const) for the links outgoing from a given node in the network.

Parameters
srcThe index of the node.
Returns
a const_link_iterator to the first outgoing link of the node at the given index.

◆ beginNodes()

const_node_iterator TSLOptimizedNetwork::beginNodes ( ) const

Access method (const) for nodes in the network.

Returns a const_node_iterator to the first node.

◆ beginTurns() [1/3]

const_turn_iterator TSLOptimizedNetwork::beginTurns ( ) const

Access method (const) for turns in the network.

Returns a const_turn_iterator to the first turn.

◆ beginTurns() [2/3]

const_turn_iterator TSLOptimizedNetwork::beginTurns ( const const_node_iterator & it) const

Access method (const) for the turns outgoing from a given node in the network.

Parameters
itA reference to the const node iterator.
Returns
a const_turn_iterator to the first outgoing turn of the node associated with the given const_node_iterator.

◆ beginTurns() [3/3]

const_turn_iterator TSLOptimizedNetwork::beginTurns ( int src) const

Access method (const) for the turns outgoing from a given node in the network.

Parameters
srcThe index of the node.
Returns
a const_turn_iterator to the first outgoing turn of the node at the given index.

◆ coordinateScaleFactor()

double TSLOptimizedNetwork::coordinateScaleFactor ( ) const

Returns the scale factor for geometries and positions.

The optimized network stores all node positions and link geometries as scaled values. Therefore, to obtain true positions and geometries, users must divide positions and geometries returned by the optimized network by this scaling factor.

e.g. double node_latitude = node.position().y() / m_optimizedNwk->coordinateScaleFactor();

◆ destroy()

void TSLOptimizedNetwork::destroy ( )

Deletes the TSLOptimizedNetwork object.

◆ endLinks() [1/3]

const_link_iterator TSLOptimizedNetwork::endLinks ( ) const

Access method (const) for links in the network.

Returns a const_link_iterator to one past the last link.

◆ endLinks() [2/3]

const_link_iterator TSLOptimizedNetwork::endLinks ( const const_node_iterator & it) const

Access method (const) for the links outgoing from a given node in the network.

Parameters
itA reference to the const node iterator.
Returns
a const_link_iterator to one past the last outgoing link of the node associated with the given const_node_iterator.

◆ endLinks() [3/3]

const_link_iterator TSLOptimizedNetwork::endLinks ( int src) const

Access method (const) for the links outgoing from a given node in the network.

Parameters
srcThe index of the node.
Returns
a const_link_iterator to one past the last outgoing link of the node at the given index.

◆ endNodes()

const_node_iterator TSLOptimizedNetwork::endNodes ( ) const

Access method (const) for nodes in the network.

Returns a const_node_iterator to one past the last node.

◆ endTurns() [1/3]

const_turn_iterator TSLOptimizedNetwork::endTurns ( ) const

Access method (const) for turns in the network.

Returns a const_turn_iterator to one past the last turn.

◆ endTurns() [2/3]

const_turn_iterator TSLOptimizedNetwork::endTurns ( const const_node_iterator & it) const

Access method (const) for the turns outgoing from a given node in the network.

Parameters
itA reference to the const node iterator.
Returns
a const_turn_iterator to one past the last outgoing turn of the node associated with the given const_node_iterator.

◆ endTurns() [3/3]

const_turn_iterator TSLOptimizedNetwork::endTurns ( int src) const

Access method (const) for the turns outgoing from a given node in the network.

Parameters
srcThe index of the node.
Returns
a const_turn_iterator to one past the last outgoing turn of the node at the given index.

◆ find()

Query * TSLOptimizedNetwork::find ( const TSLEnvelope & extent,
const TSLOptNwkFinder & filter,
query_type filter_mode = tsl_nwk_find_both ) const

Returns a query object which contains the elements satisfying the filter criteria and search mode supplied by the client. Checks the status of the Spatial Index. If the Spatial Index is valid, then if links are being searched for the Spatial Index is used.

Parameters
extentThe region to query.
filterA reference to a finder object.
filter_modeAny of TSLOptimizedNetwork::tsl_nwk_find_nodes / tsl_nwk_find_links / tsl_nwk_find_both.

◆ findLink()

const_link_iterator TSLOptimizedNetwork::findLink ( const TSLCoord & location,
int aperture ) const

Finds the nearest link based on location and (square) aperture. Checks the status of the Spatial Index. If the Spatial Index is valid, then if links are being searched for the Spatial Index is used.

Parameters
locationThe centre point of area to search.
apertureThe distance from the centre point to search.
Returns
a link_iterator that refers to the link that was found.

◆ findLinks()

Query * TSLOptimizedNetwork::findLinks ( const TSLCoord & location,
int aperture,
const TSLOptNwkFinder * filter = NULL,
int limit = -1,
bool useSpatialIndex = true )

Function that returns a set (Query) of Links within the boundary of the search area, dependent on additional optional filter logic. If the Spatial Index is valid, then it is used for the search and the links within the query object are ordered by distance and the distance is also stored in the query. All links should be within the aperture distance set. Initially, the set should contain all the Links that are within the boundary of the aperture from the location. This can be reduced by the optional filter and limit. If the Limit is supplied then the query object is restricted to return only this number of links or less. The limit is only used if the Spatial Index is valid.

Parameters
locationThe centre point of area to search.
apertureThe distance from the centre point to search.
filterOptional Filter object.
limitOptional limit on the number of links to return.
useSpatialIndexIf true the spatial index for the loaded network will be used if it is valid. If no spatial index is available then the standard search method will be used. Defaults to true.

◆ findNode()

const_node_iterator TSLOptimizedNetwork::findNode ( const TSLCoord & location,
int aperture ) const

Finds the nearest node based on location and (square) aperture.

Parameters
locationThe centre point of area to search.
apertureThe distance from the centre point to search.
Returns
a node_iterator that refers to the link that was found.

◆ firstPoint()

TSLCoord TSLOptimizedNetwork::firstPoint ( const TSLOptLink * link) const

Queries the supplied link for its first point.

Parameters
linkA pointer to the TSLOptLink object.
Returns
the link's first point (as a TSLCoord). If isLatLong() true, the point is a scaled longitude and latitude pair, where scaled longitude = point().x() and scaled latitude = point().y(). In order to get true latitude / longitude, divide the relevant values by coordinateScaleFactor().

◆ getAttributes() [1/2]

const TSLVariant * TSLOptimizedNetwork::getAttributes ( const TSLOptLink * link) const

Queries the supplied link for its attributes.

Parameters
linkA pointer to the TSLOptLink object.
Note
the user is responsible for destroying the returned pointer.

◆ getAttributes() [2/2]

const TSLVariant * TSLOptimizedNetwork::getAttributes ( const TSLOptNode * node) const

Queries the supplied node for its attributes.

Parameters
nodeA pointer to the TSLOptNode object.
Note
the user is responsible for destroying the returned pointer.

◆ getLink()

const TSLOptLink & TSLOptimizedNetwork::getLink ( int index) const

Access method (const) for links.

Parameters
indexThe index position.
Returns
a reference to the (const) Link object at the specified position.

◆ getNode()

const TSLOptNode & TSLOptimizedNetwork::getNode ( int index) const

Access method (const) for nodes.

Parameters
indexThe index position.
Returns
a reference to the (const) Node object at the specified position.

◆ getPoints()

TSLCoordSet * TSLOptimizedNetwork::getPoints ( const TSLOptLink * link) const

Queries the supplied link for its points.

Parameters
linkA pointer to the TSLOptLink object.
Returns
a TSLCoordSet* that references the points. Each member of the TSLCoordSet is a point which represents the position. If isLatLong() returns true, then the position is a scaled longitude and latitude pair, where scaled longitude = getPoints[i].x() and scaled latitude = getPoints[i].y(). In order to get true latitude / longitude, divide the relevant values by coordinateScaleFactor().
Note
the user is responsible for destroying the returned pointer.

◆ invalidateSpatialIndex()

void TSLOptimizedNetwork::invalidateSpatialIndex ( )

Function that invalidates the Spatial Index. An example of when to use this function would be when a Link has had its geometry changed.

◆ isEdgeNode()

bool TSLOptimizedNetwork::isEdgeNode ( int index) const

Returns true if the node is an edge node, false otherwise.

Parameters
indexThe index of the node.

◆ isLatLong()

bool TSLOptimizedNetwork::isLatLong ( ) const

Query method for the type of units of node position / link geometry.

Returns true if co-ordinates/geometry are in lat/long; false if in TMC.

◆ isStitchNode()

bool TSLOptimizedNetwork::isStitchNode ( int index) const

Returns true if the node is a stitch node, false otherwise.

Parameters
indexThe index of the node.

◆ lastPoint()

TSLCoord TSLOptimizedNetwork::lastPoint ( const TSLOptLink * link) const

Queries the supplied link for its last point.

Parameters
linkA pointer to the TSLOptLink object.

@returnReturns the link's last point (as a TSLCoord). If isLatLong() true, the point is a scaled longitude and latitude pair, where scaled longitude = point().x() and scaled latitude = point().y(). In order to get true latitude / longitude, divide the relevant values by coordinateScaleFactor().

◆ linkDestinNode()

const TSLOptNode & TSLOptimizedNetwork::linkDestinNode ( const const_link_iterator & it) const

Query method for links.

Parameters
itA reference to the const_link_iterator pointing to the link.
Returns
a reference to the link's destination (const) Node object.

◆ linkDestinNodePos()

int TSLOptimizedNetwork::linkDestinNodePos ( const const_link_iterator & it) const

Query method for links.

Parameters
itA reference to the const_link_iterator pointing to the link.
Returns
the index of the link's destination node.

◆ linkNodes() [1/2]

bool TSLOptimizedNetwork::linkNodes ( const const_link_iterator & it,
TSLOptNode & src,
TSLOptNode & dst ) const

Query method for links. Returns the link's source & destination Node objects, via the supplied arguments.

Parameters
itA reference to the const_link_iterator pointing to the link.
srcA reference to the link's source Node object.
dstA reference to the link's destination Node object.
Returns
true if link exists, false otherwise.

◆ linkNodes() [2/2]

bool TSLOptimizedNetwork::linkNodes ( const TSLOptLink & link,
TSLOptNode & src,
TSLOptNode & dst ) const

Query method for links. Returns the link's source & destination Node objects, via the supplied arguments.

Parameters
linkA reference to the const Link object.
srcA reference to the link's source Node object.
dstA reference to the link's destination Node object.
Returns
true if link exists, false otherwise.

◆ linkSourceNode()

const TSLOptNode & TSLOptimizedNetwork::linkSourceNode ( const const_link_iterator & it) const

Query method for links.

Parameters
itA reference to the const_link_iterator pointing to the link.
Returns
a reference to the link's source (const) Node object.

◆ linkSourceNodePos()

int TSLOptimizedNetwork::linkSourceNodePos ( const const_link_iterator & it) const

Query method for links.

Parameters
itA reference to the const_link_iterator pointing to the link.
Returns
the index of the link's source node.

◆ load()

bool TSLOptimizedNetwork::load ( const char * fileName)

Loads and initialises the optimized network. Only the topology information is loaded into memory - the node / link attributes and the link geometry needed to be loaded separately.

Parameters
fileNameThe name of the network file.
Returns
true of the topology is loaded successfully.

◆ loadAttributes()

bool TSLOptimizedNetwork::loadAttributes ( )

Loads the node & link attributes.

Returns true of the attributes are loaded successfully.

◆ loadGeometry()

bool TSLOptimizedNetwork::loadGeometry ( )

Loads the link geometry.

Returns true of the geometry is loaded successfully.

◆ loadSpatialIndex()

bool TSLOptimizedNetwork::loadSpatialIndex ( TSLifstream & inputStream)

Function that reads and creates the Spatial Index from a file stream. If the Spatial Index already exists, it is deleted. Returns true on success or false on error.

Parameters
inputStreamReference to stream.

◆ numAttributes() [1/2]

int TSLOptimizedNetwork::numAttributes ( const TSLOptLink * link) const

Returns the number of attributes assigned to the supplied link.

Parameters
linkA pointer to the TSLOptLink object.

◆ numAttributes() [2/2]

int TSLOptimizedNetwork::numAttributes ( const TSLOptNode * node) const

Returns the number of attributes assigned to the supplied node.

Parameters
nodeA pointer to the TSLOptNode object.

◆ numPoints()

int TSLOptimizedNetwork::numPoints ( const TSLOptLink * link) const

Returns the number of points describing the geometry of the supplied link.

Parameters
linkA pointer to the TSLOptLink object.

◆ operator new() [1/2]

void * TSLOptimizedNetwork::operator new ( size_t size)

These are here to avoid being documented Allocation override for API redirection.

◆ operator new() [2/2]

void * TSLOptimizedNetwork::operator new ( size_t size,
char * filename,
int line )

When included in an MFC application in debug mode, the debug new expects this to be here. Override it and return the same as the normal one. The library must include it when compiled in release mode, since the user's application may be in debug mode.

◆ point()

TSLCoord TSLOptimizedNetwork::point ( const TSLOptLink * link,
int N ) const

Queries the supplied link for the point at the specified index.

Parameters
linkA pointer to the TSLOptLink object.
NThe index position.
Returns
the point (as a TSLCoord) at the specified index. If isLatLong() returns true, the point is a scaled longitude and latitude pair, where scaled longitude = point().x() and scaled latitude = point().y(). In order to get true latitude / longitude, divide the relevant values by coordinate ScaleFactor().

◆ saveSpatialIndex()

bool TSLOptimizedNetwork::saveSpatialIndex ( TSLofstream & outputStream)

Function that saves the Spatial Index to a file stream. Will only save the Spatial Index if it has previously been built. Returns true on success, or false if an error occurred, for example, the Spatial Index was not valid.

Parameters
outputStreamReference to stream.

◆ sizeLinks()

int TSLOptimizedNetwork::sizeLinks ( ) const

Query method for links in the network.

Returns the number of links in the network.

◆ sizeNodes()

int TSLOptimizedNetwork::sizeNodes ( ) const

Query method for nodes in the network.

Returns the number of nodes in the network.

◆ sizeTurns()

int TSLOptimizedNetwork::sizeTurns ( ) const

Query method for turns in the network.

Returns the number of turns in the network.

◆ spatialIndexUpToDate()

bool TSLOptimizedNetwork::spatialIndexUpToDate ( ) const

Returns the status of the Spatial Index.

Returns true if the spatial index is valid and can be used, false otherwise.

◆ turnDestinLink()

const_link_iterator TSLOptimizedNetwork::turnDestinLink ( const const_turn_iterator & it) const

Query method for turns.

Parameters
itA reference to the const_turn_iterator pointing to the turn.
Returns
the const_link_iterator pointing to the turn's destination link.

◆ turnSourceLink()

const_link_iterator TSLOptimizedNetwork::turnSourceLink ( const const_turn_iterator & it) const

Query method for turns.

Parameters
itA reference to the const_turn_iterator pointing to the turn.
Returns
the const_link_iterator pointing to the turn's source link.

◆ updateSpatialIndex()

bool TSLOptimizedNetwork::updateSpatialIndex ( )

Function that updates the Networks Spatial Index. If the Spatial Index exists, it is deleted and rebuilt. If the Spatial Index doesn't exist it is constructed.

Returns true if the Spatial Index was created successfully. Returns false if an error was encountered. The TSLErrorStack should be interrogated for further information.