tsc_CustomProjection

Inherit from this abstract base class to implement a concrete instance of a projection.  The instance will include the ability to edit and display projection parameters as well as to use the parameters to perform the projection transformation.

tsc_CustomProjections are created by tsc_CustomProjectionType class instances and are held by SurveyCore.  It is typical for many calls to be made to instances of this class so be aware of efficiency.

Also please note that you will probably be called on multiple threads and occassionally asked to perform UI as part of another application (e.g.: your custom projection can be used by a General Survey user without your application having been started).  Please implement UI as simple, self-contained forms.

For an introduction to map projections please refer to this wikipedia article.

Constructor

The class is required to be told which type created it.

tsc_CustomProjection (const tsc_CustomProjectionType& type);

Abstract methods

Create a deep copy of this projection.

virtual tsc_CustomProjection* Clone() const;

Compare another instance of your projection type to the current one.  SurveyCore code will check that the two projection types match.

virtual bool IsIdentical(tsc_CustomProjection* potentialMatch) const;

Generate the JXL to represent your projection, jxl is an empty element to be populated with your data.

The JXL returned will be wrapped with your JxlName and plugin data (plugin data is for information purposes and does affect the JxlName match).

Consider adding a version attribute so that you can detect old versions of your data.

virtual void RenderJxl(tsc_XmlElement& jxl) const;

Load parameters from jxl, SurveyCore will manage the matching of Jxl projection fragments to your type.

virtual bool LoadFromJxl(const tsc_XmlElement& jxl);

Report on any files required to calculate, support or define the projection.  Use full paths, tsc_Path macros are accepted.

virtual void RequiredSupportFiles(tsc_StringList& addToList) const;

Reset the projection parameters back to the default values.

virtual void ResetToDefaults();

Implement the projection transformation, this needs to be quick and thread-safe.  Return double_Nulls for error cases.

Note that height will be passed through unchanged, projections have no vertical component.

virtual tsc_Local GridToLocal (const tsc_Grid&   grid, const tsc_Ellipsoid& ellipsoid) const;

virtual tsc_Grid  LocalToGrid (const tsc_Local& local, const tsc_Ellipsoid& ellipsoid) const;

Display a modal tsc_Form that concisely shows, and allows the editing of, the specific parameters for this projection.

virtual bool RunEditParametersForm();

Display a modal form that concisely shows the specific parameters for this projection (read-only).

virtual void RunReviewParametersForm() const;

Methods

Retrieves the type that created this instance.

const tsc_CustomProjectionType& GetType() const;

Override to return any projection instance specific name, e.g. "NZLC Mt Pleasant".  By default this will return the name of the projection type.

virtual tsc_String GetDisplayName() const;

Returns the projection scale factor for the given local ellipsoid location.  If your projection has a scale factor formula then override this function.  By default it will use the EstimateScaleFactor function below.

virtual double ScaleFactor (const tsc_Local& local, const tsc_Ellipsoid& ellipsoid) const;

Calculates the combination of the projection scale factor at the location and the scale factor due to elevation above the local ellipsoid surface.  There is no need to override unless you have a custom formula.

virtual double CombinedScaleFactor (const tsc_Local& local, const tsc_Ellipsoid& ellipsoid, const double& elevation) const;

If your algorthim does not define a scale factor formula, the estimate method moves 5m North and estimates one for you.

virtual double EstimateScaleFactor (const tsc_Local& local, const tsc_Ellipsoid& ellipsoid) const;

The tsc_CustomProjection class also supports the tsc_IReviewable interface.  Default implementations are already in place but you can override these to produce more elaborate reviewing functionality.

In all cases refer to the tsc_IReviewable documentation for more details.

Generate a review tree structure for your projection.

virtual void GetReviewTree(tsc_UiTree& tree, bool expanded);

Return true if you have a custom form to review the projection record data.

virtual bool HasReviewForm();

Implement your modal form and return an appropriate tsc_ReviewActions.

virtual enum tsc_ReviewActions ShowReviewForm();

The default review UI tree for custom projections, already called by default but available here for use in custom UI trees.

void GetDefaultReviewTree(tsc_UiTree& tree) const;

Statics

A small number to check for divides by 0.0.

static const double NearlyZero;