Main Page   Namespace List   Class Hierarchy   Compound List   File List   Header Files   Sources   Namespace Members   Compound Members   File Members  

MapDataDocument Class Reference

An internal representation of a Map-Data XML document. More...

#include <MapDataDocument.h>

List of all members.


Public Members

 MapDataDocument (void)
The only constructor for a MapDataDocument. More...

virtual ~MapDataDocument (void)
const vector2origin (void) const
Get the top left corner of the map area. More...

double height (void) const
Get the height of the map area. More...

double width (void) const
Get the width of the map area. More...

const map< string, vector2 * >& named_points (void) const
Get the list of named points. More...

const vector< vector2 * >& anon_points (void) const
Get the list of anonymous points. More...

const map< string, curve * >& curves (void) const
Get the list of named curves. More...

const set< vector2 * >& fixed_points (void) const
Get the list of the fixed points. More...

const vector< constraint * >& constraints (void) const
Get the list of the constraints on the point positions. More...

set< vector2 * > all_points (void) const
Create a simple list of all the named and anonymous points. More...

void read ( InputSource &source, MapperErrorHandler &err_handler )
Read a Map-Data document. More...

void write ( ostream &out, const double tol )
Write a Map-Data document as text. More...

unsigned precision
The number of decimal places for coordinates.


Detailed Description

An internal representation of a Map-Data XML document.

Implementation:
The class uses a private data member to store a Xerces-C++ DOM_Document representation of the XML document.

Definition at line 80 of file MapDataDocument.h.


Member Function Documentation

MapDataDocument::MapDataDocument (void)

The only constructor for a MapDataDocument.

Postconditions:
 assert( this->origin() == vector2(0,0) );
 assert( this->height() == 0.0 );
 assert( this->width() == 0.0 );
 assert( this->named_points().empty() );
 assert( this->anon_points().empty() );
 assert( this->curves().empty() );
 assert( this->fixed_points().empty() );
 assert( this->constraints().empty() );
 assert( this->precision = 6 );

Definition at line 38 of file MapDataDocument.cpp.

MapDataDocument::~MapDataDocument (void) [virtual]

Definition at line 63 of file MapDataDocument.cpp.

const vector2 & MapDataDocument::origin (void) const [inline]

Get the top left corner of the map area.

This is the point given by the x and y attributes of the Map-Data element.

Returns:
The coordinates of the corner.

Definition at line 114 of file MapDataDocument.h.

double MapDataDocument::height (void) const [inline]

Get the height of the map area.

This is the value given by the height attribute of the Map-Data element.

Returns:
The height.

Definition at line 127 of file MapDataDocument.h.

double MapDataDocument::width (void) const [inline]

Get the width of the map area.

This is the value given by the width attribute of the Map-Data element.

Returns:
The width.

Definition at line 140 of file MapDataDocument.h.

const map<string,vector2 *>& MapDataDocument::named_points (void) const [inline]

Get the list of named points.

Each entry in the map corresponds to either a Point element or a Point-alias element in the Map-Data document. Each point is represented by a vector2 object.

Returns:
a mapping of point identifiers (corresponding to to id attributes) to their corresponding vector2 objects.

Invariants:
No null entries:
 assert( !this->named_points().count(n) || this->named_points[n] );

Definition at line 166 of file MapDataDocument.h.

const vector<vector2 *>& MapDataDocument::anon_points (void) const [inline]

Get the list of anonymous points.

Each entry in the map corresponds to a Traced-point element without a point attribute in the Map-Data document.

Returns:
a list of point positions.

Invariants:
No null entries:
 assert( this->anon_points().size() < i || this->anon_points[i] );

Definition at line 187 of file MapDataDocument.h.

const map<string,curve *>& MapDataDocument::curves (void) const [inline]

Get the list of named curves.

Each entry in the map corresponds to a a Curve element in the Map-Data document.

Returns:
a mapping of curve identifiers (corresponding to to id attributes) to curve objects representing the identified curve.

Invariants:
No null entries:
 assert( !this->curve().count(n) || this->curve[n] );

Definition at line 209 of file MapDataDocument.h.

const set<vector2 *>& MapDataDocument::fixed_points (void) const [inline]

Get the list of the fixed points.

Each entry in the map corresponds to a Fixed-point element in the Map-Data document.

Returns:
a list of pointers to the fixed points

Invariants:
No null entries:
 assert( this->fixed_points().size() < i || this->fixed_points[i] );

Definition at line 229 of file MapDataDocument.h.

const vector<constraint *>& MapDataDocument::constraints (void) const [inline]

Get the list of the constraints on the point positions.

Each entry in the map corresponds to a element in the Map-Data document that explicitly specifies a constraint, or corresponds to the constraints created implicitly from Traced-point elements. Elements that explicitly indicate a constraint are Angle, Bearing, Distance, Through and Vector elements.

Returns:
a list of pointers to the constraint objects that represent the constraints constraints.

Invariants:
No null entries:
 assert( this->fixed_points().size() < i || this->fixed_points[i] );

Definition at line 254 of file MapDataDocument.h.

set<vector2 *> MapDataDocument::all_points (void) const

Create a simple list of all the named and anonymous points.

Returns:
the set of all points

Definition at line 132 of file MapDataDocument.cpp.

void MapDataDocument::read (InputSource & source, MapperErrorHandler & err_handler)

Read a Map-Data document.

The internal representation stored by this object is altered to correspond to the input document. The function must parse the input document. It handles input and parsing errors using a provided error handling object.

Parameters:
source   the document to read
err_handler   the error handler

The function converts Map-Data elements to objects as follows.

Tag of Element Conversion Done
Angle Create a coresponding new angle_constraint object, add the object to the constraints() list.
Area-feature Do nothing.
Cite Do nothing.
Constraint-group Do nothing
Coord Create a coresponding new vector2 object, and add the object to the param list of the corresponding curve.
Curve-segment Create a coresponding new curve_segment object.
Distance Create a coresponding new distance_constraint object, add the object to the constraints() list.
Fixed-point Add the indicated point to the fixed_points() list, and set the coordinates of the point to the given values.
Linear-feature Do nothing
Line-segment Do nothing.
Name Do nothing.
Path-node Do nothing.
Point Create a coresponding new vector2 object, and add the object to the named_points() map.
Point-alias Use the named_points map to find the corresponding existing point. Add an extra entry to the named_points() map, so this alias also indicates the existing point.
Point-feature Do nothing
Through Create a coresponding new through_constraint object, add the object to the constraints() list.
Tracing Create a delaunay::triangulation object for all is traced points. For all the triangles in that triangulation that are not border triangles, create an angle_constraint object for each vertex, to constrain the angle at that vertex. Add those constraints to the constraints() list.
Traced-point If the point is anonymous, create a new vector2 object for it and add a pointer to the new object to the anon_points() list. Otherwise, look up the point in the named_points() map.
Units Check whether the angle units are degrees. Issue an error if they are not.
Vector Create a coresponding new vector_constraint object, and add the object to the constraints() list.

Implementation:
The parsing is done using the Apache Xerces-C++ parser. The internal DOM object is set to the DOM object created by the parser. Elements of that DOM that correspond to points, curves, constraints, etc. created by the processing have their user data set to be a pointer to the created object. For example, an Angle element has a pointer to the angle_constraint created to represent it. These user-data points are used for updating the DOM object.

Definition at line 93 of file MapDataDocument.cpp.

void MapDataDocument::write (ostream & out, const double tol)

Write a Map-Data document as text.

The output routine must calculate some data to produce the text output. This requires a calculation tolerance. so it is consistent with its internal representation. This uses the user data references pointing from the elements to the corresponding internal representation. The output text has explicitly stated values for all attributes that have implicit or default values.

Parameters:
out   the stram to write to
tol   the calculation tolerance

Preconditions:
 assert( 0 < tol && tol < 1 );

Implementation:
The function updates the internal DOM representation of an element for outputing that element. It uses the user-data points of the DOM elements to access the corresponding raw data.

Definition at line 121 of file MapDataDocument.cpp.


Member Data Documentation

unsigned MapDataDocument::precision

The number of decimal places for coordinates.

Definition at line 270 of file MapDataDocument.h.


The documentation for this class was generated from the following files:
Generated at Sun Jul 14 20:38:15 2002 for Mapper by doxygen 1.0.0 written by Dimitri van Heesch, © 1997-1999