![]() |
MapLink Pro 11.1.1.0.
Envitia MapLink Pro: The Ultimate Mapping Application Toolkit
|
This draws a Latitude / Longitude grid over a map data layer.
This adds special features to allow configuration of the rendering. Use the setFeatureRendering() method to configure the rendering options for these.
At present, the available feature names are:
Label Positioning:
Line labels are setup by default to be positioned with latitude labels at the left hand side of the projection or screen and longitude labels at the bottom of the projection or screen. This can be modified by the user using the functions setLatitudeLabelPosition and setLongitudeLabelPosition. These functions take a bitmask value, see TSLGridLabelPosition, allowing a single option (e.g. latitude labels displayed on the RHS of the projection/screen) or a combination of options (e.g. latitude labels displayed on top and bottom of the projection/screen). The current values of the label position bitmasks can be obtained using the functions getLatitudeLabelPosition and getLongitudeLabelPosition.
The setSpacing() method with feature set to "lonMajorDegree" or "latMajorDegree" sets the distance between the major grid lines (in degrees). The default is 10 degrees.
The line rendering can be disabled by setting the edge style to 0. If the edge style is 0 then a symbol will be drawn if the feature rendering for a symbol is setup.
If the rendering for display of tenths and minutes are both setup, then neither is displayed.
The user can provide a TSLLatLongGridDataLayerFormatCallback to format the text drawn at each grid interval. If a callback is not supplied then it will default to decimal degrees. The user can also provide a TSLLatLongGridDataLayerFormatCallback to format the text drawn for subgrid labels. If a callback is not supplied then it will default to decimal degrees with a maximum of 3 decimal places.
Coordinate Systems:
The layer requires a Coordinate Systems to allow it to work out the grid points. The layer by default will use the Drawing Surface Coordinate System. This may be changed by the user by a call to addDataLayer with a coordinate system providing layer.
In both cases the Coordinate System must be correctly setup before the first draw of the grid layer or before calling addDataLayer as the layer takes a copy of the Coordinate System.
If the coordinate system is changed on the Drawing Surface or a map with a new coordinate system is loaded into the map data-layer then notifiedChanged should be called with true. This will cause the cache to be flushed and the Coordinate System to be queried again.
If you delete the map data-layer associated with the layer then you should call setDataLayer with NULL.
Public Types | |
enum | TSLSubGridLabelPositionEnum { TSLSubGridLabelDefaultCentre = 0 , TSLSubGridLabelLHSBottom = 1 , TSLSubGridLabelRHSBottom = 2 , TSLSubGridLabelLHSTop = 3 , TSLSubGridLabelRHSTop = 4 } |
enum | TSLGridLabelPosition { TSLGridLabelLegacy = 0 , TSLGridLabelLHS = 1 , TSLGridLabelRHS = 2 , TSLGridLabelTop = 4 , TSLGridLabelBottom = 8 } |
typedef TSLSubGridLabelPositionEnum | TSLSubGridLabelPosEnum |
deprecated | |
Public Member Functions | |
TSLLatLongGridDataLayer () | |
bool | getCentre (double &latitude, double &longitude) const |
TSLLatLongGridDataLayerFormatCallback * | getFormatCallback (void **arg) const |
TSLGridDetailLevelChangeEnum | getGridLevelChangeMode () const |
TSLBitMask | getLatitudeLabelPosition () const |
TSLBitMask | getLongitudeLabelPosition () const |
TSLLatLongGridDataLayerFormatCallback * | getSubGridFormatCallback (void **arg) const |
TSLSubGridLabelPositionEnum | getSubGridLabelPosition () const |
bool | localDatum () const |
void | localDatum (bool useLocalDatum) |
void | setDataLayer (TSLDataLayer *dataLayer) |
void | setFormatCallback (TSLLatLongGridDataLayerFormatCallback *callbackFunc, void *arg) |
void | setGridLevelChangeMode (TSLGridDetailLevelChangeEnum mode=TSLGridLevelChangeAutomatic) |
bool | setLatitudeLabelPosition (const TSLBitMask labelPosition=TSLGridLabelLHS) |
bool | setLongitudeLabelPosition (const TSLBitMask labelPosition) |
bool | setSpacing (const char *const feature, int spacing) |
void | setSubGridFormatCallback (TSLLatLongGridDataLayerFormatCallback *callbackFunc, void *arg) |
void | setSubGridLabelPosition (TSLSubGridLabelPositionEnum position=TSLSubGridLabelDefaultCentre) |
bool | snap (TSLCoord *snap_pt, double &latitude, double &longitude, bool force_snap=false, bool snapToMiddle=false) |
void | snapable (bool value) |
bool | snapable () const |
void | tickLength (int degrees, int tenthsMinutes) |
void | ticks (bool ticks) |
void * | operator new (size_t size) TSL_NO_THROW |
void * | operator new (size_t size, char *filename, int line) |
![]() | |
void | addDrawingCallback (TSLDataLayerDrawingCallback *drawingCallback) |
bool | addFeatureRendering (const char *featureName, TSLFeatureID featureID) |
bool | addLoader (TSLFileLoader *loader, TSLLoaderAppCallback callback, void *arg, TSLAllLoadedCallback allLoadedCallback=0, void *arg2=0) |
bool | addPathList (const TSLPathList *path_list) |
void | cancelFlashback () |
bool | clearFeatureRendering (const char *featureName, TSLFeatureID featureID) |
TSLDataHandler * | createDataHandler (const char *config_file=0) |
TSLHistoryVersion | currentVersion () const |
TSLDataHandler * | dataHandler () |
const TSLDataHandler * | dataHandler () const |
void | destroy () |
bool | entityIsVisible (const TSLEntity *entity, const TSLDrawingSurface *drawingSurface) const |
const TSLFeatureClassList * | featureList () const |
const TSLFeatureClassList * | featureList (const char *detailLayerName) const |
bool | fileModificationTime (const char *filename, TSLTimeType &lastModificationTime) |
TSLEntity * | findEntity (TSLTMC x, TSLTMC y, TSLTMC aperture, int depth, const char *featureName=0, int drawingSurfaceID=-1) |
bool | findFile (const char *filename, TSLSimpleString &foundPath) const |
void | flashbackToTimestamp (TSLHistoryTimestamp timestamp, TSLLayerArchiveCallback archiveCallback, void *arg=0) |
void | flashbackToTimestamp (TSLHistoryTimestamp timestamp, TSLLayerArchiveTileCallback archiveTileCallback, void *arg=0) |
void | flashbackToVersion (TSLHistoryVersion version, TSLLayerArchiveCallback archiveCallback, void *arg=0) |
void | flashbackToVersion (TSLHistoryVersion version, TSLLayerArchiveTileCallback archiveTileCallback, void *arg=0) |
bool | getActiveLayerName (const TSLEnvelope &extent, double screenResolution, TSLSimpleString &activeLayerName) const |
TSLEntityIterator * | getEntityIterator (const char *detailLayer, TSLSelector *selector=NULL, TSLEnvelope *extent=NULL, bool splitOptimisedPrimitives=true) |
bool | getFeatureRendering (const char *featureName, TSLFeatureID featureID, TSLRenderingAttributeInt attribute, int *result) const |
bool | getFeatureRendering (const char *featureName, TSLFeatureID featureID, TSLRenderingAttributeDouble attribute, double *result) const |
bool | getFeatureRendering (const char *featureName, TSLFeatureID featureID, TSLRenderingAttributeBool attribute, bool *result) const |
bool | getFeatureRendering (const char *featureName, TSLFeatureID featureID, TSLRenderingAttributes *result) const |
TSLFileLoader * | getLoader () |
bool | getMUExtent (double *x1, double *y1, double *x2, double *y2, int drawingSurfaceID=-1) const |
bool | getTMCExtent (TSLTMC *x1, TSLTMC *y1, TSLTMC *x2, TSLTMC *y2, int drawingSurfaceID=-1) const |
bool | getUUExtent (double *x1, double *y1, double *x2, double *y2, const TSLDrawingSurface *drawingSurface) const |
bool | importHistory (TSLHistoryVersion mapVersion, TSLHistoryTimestamp timestamp, TSLHistoryImportSet *historySet) |
bool | latLongToTMC (double latitude, double longitude, TSLTMC *x, TSLTMC *y, bool local=false) const |
bool | latLongToTMC (int num, double *latitudes, double *longitudes, TSLTMC *xs, TSLTMC *ys, bool local=false) const |
TSLDataLayerTypeEnum | layerType () const |
bool | loadData (const char *filename) |
bool | loadRendering (const char *filename) |
void | notifyChanged (bool changed=true) |
TSLMapQuery * | query (TSLTMC x1, TSLTMC y1, TSLTMC x2, TSLTMC y2, int depth=-1, const char *featureName=NULL, int drawingSurfaceID=-1) const |
TSLMapQuery * | query (TSLTMC x1, TSLTMC y1, TSLTMC x2, TSLTMC y2, TSLSelector *selector, int drawingSurfaceID=-1) const |
const TSLCoordinateSystem * | getCoordinateSystem () const |
bool | queryVersionHistory (const TSLEnvelope &extent, TSLVersionHistorySet &history) |
void | refreshFlashback () |
bool | removeData () |
void | releaseResources (int surfaceID) |
bool | saveRendering (const char *filename, TSLMapLinkVersion ver=TSL_CURRENT_MAPLINK_VERSION) |
bool | setCoordinateSystem (const TSLCoordinateSystem *coordinateSystem) |
bool | setFeatureRendering (const char *featureName, TSLFeatureID featureID, TSLRenderingAttributeInt attribute, int value) |
bool | setFeatureRendering (const char *featureName, TSLFeatureID featureID, TSLRenderingAttributeDouble attribute, double value) |
bool | setFeatureRendering (const char *featureName, TSLFeatureID featureID, TSLRenderingAttributeBool attribute, bool value) |
bool | setFeatureRendering (const char *featureName, TSLFeatureID featureID, TSLRenderingAttributes *value) |
bool | TMCToLatLong (TSLTMC x, TSLTMC y, double *latitude, double *longitude, bool local=false, bool boundCheck=true) const |
bool | TMCToLatLong (int num, TSLTMC *xs, TSLTMC *ys, double *latitudes, double *longitudes, bool local=false) const |
const TSLVersionHistorySet * | versionHistory () const |
deprecated
Bitmask defining the positions available for the display position of the Major and Degree level Grid labels.
Apart from the TSLGridLabelLegacy position which is mutually exclusive, the positions can be used individually or in combination with each other.
(LHS: Left Hand Side, RHS: Right Hand Side)
Enumeration defining the positions available for the display position of the SubGrid label.
(LHS: Left Hand Side, RHS: Right Hand Side)
TSLLatLongGridDataLayer::TSLLatLongGridDataLayer | ( | ) |
bool TSLLatLongGridDataLayer::getCentre | ( | double & | latitude, |
double & | longitude ) const |
Gets the latitude and longitude of the centre of the last view displayed.
latitude | [output] centre latitude. |
longitude | [output] centre longitude. |
TSLLatLongGridDataLayerFormatCallback * TSLLatLongGridDataLayer::getFormatCallback | ( | void ** | arg | ) | const |
Queries the data layer to see if a user defined callback, to format the text drawn at each grid interval, has been set.
arg | If this parameter is provided, it will be pointed to the user defined value passed to the setFormatCallback method. If no callback has been set, it will be pointed at NULL |
TSLGridDetailLevelChangeEnum TSLLatLongGridDataLayer::getGridLevelChangeMode | ( | ) | const |
This method allows users to retrieve the current Grid Level Change Mode.
TSLBitMask TSLLatLongGridDataLayer::getLatitudeLabelPosition | ( | ) | const |
This method allows users to retrieve the value of the bitmask used to determine the position of the latitude line labels. The positions available are:
Apart from the TSLGridLabelLegacy position which is mutually exclusive, the positions can be used individually or in combination with each other.
TSLBitMask TSLLatLongGridDataLayer::getLongitudeLabelPosition | ( | ) | const |
This method allows users to retrieve the value of the bitmask used to determine the position of the longitude line labels. The positions available are:
Apart from the TSLGridLabelLegacy position which is mutually exclusive, the positions can be used individually or in combination with each other.
TSLLatLongGridDataLayerFormatCallback * TSLLatLongGridDataLayer::getSubGridFormatCallback | ( | void ** | arg | ) | const |
Queries the data layer to see if a user defined callback, to format the text drawn for a subgrid label, has been set.
arg | If this parameter is provided, it will be pointed to the user defined value passed to the setSubGridFormatCallback method. If no callback has been set, it will be pointed at NULL |
TSLSubGridLabelPositionEnum TSLLatLongGridDataLayer::getSubGridLabelPosition | ( | ) | const |
This method allows users to retrieve the enum denoting the position where the Sub Grid Label is displayed.
bool TSLLatLongGridDataLayer::localDatum | ( | ) | const |
This returns whether local or WGS84 datum is being used.
Returns true if local datum is used, false if WGS84 datum is used.
void TSLLatLongGridDataLayer::localDatum | ( | bool | useLocalDatum | ) |
This sets whether local or WGS84 datum is being used.
useLocalDatum | Pass true to use local datum, false to use WGS84 datum |
void * TSLLatLongGridDataLayer::operator new | ( | size_t | size | ) |
Allocation override for API redirection
void * TSLLatLongGridDataLayer::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.
void TSLLatLongGridDataLayer::setDataLayer | ( | TSLDataLayer * | dataLayer | ) |
This sets the map layer that the grid is to overlay.
You should call this method with the layer whenever the coordinate-system is changed. This will cause the grid cache to be flushed and re-calculated.
dataLayer | The Coordinate Providing Data Layer for the grid to use for its latitude longitude conversions. |
void TSLLatLongGridDataLayer::setFormatCallback | ( | TSLLatLongGridDataLayerFormatCallback * | callbackFunc, |
void * | arg ) |
This method allows users to provide a callback to format the text drawn at each grid interval. If a callback is not supplied then it will default to decimal degrees.
callbackFunc | The callback to be used. If NULL is passed then the existing callback will be removed and will revert to the default functionality |
arg | This user value will be passed to the callback function when it is called. It will remain in the ownership of the user. |
void TSLLatLongGridDataLayer::setGridLevelChangeMode | ( | TSLGridDetailLevelChangeEnum | mode = TSLGridLevelChangeAutomatic | ) |
This method allows users to change the Grid Level Change Mode. The modes available are:
NOTE: If the Manual mode is used then the User needs to be aware that setting of Sub Grids at too high a zoom level will seriously impinge on performance and memory usage.
mode | The Change mode to be used. If NULL is passed then the default functionality i.e. level changes are determined automatically by the TSLLatLongGridDataLayer |
bool TSLLatLongGridDataLayer::setLatitudeLabelPosition | ( | const TSLBitMask | labelPosition = TSLGridLabelLHS | ) |
This method allows users to change the position of the latitude line labels. The positions available are:
Apart from the TSLGridLabelLegacy position which is mutually exclusive, the positions can be used individually or in combination with each other.
The default position for latitude labels is the TSLGridLabelLegacy, i.e. display left.
labelPosition | The bitmask defining the position(s) at which to display the latitude line labels. |
bool TSLLatLongGridDataLayer::setLongitudeLabelPosition | ( | const TSLBitMask | labelPosition | ) |
This method allows users to change the position of the longitude line labels. The positions available are:
Apart from the TSLGridLabelLegacy position which is mutually exclusive, the positions can be used individually or in combination with each other.
The default position for longitude labels is the TSLGridLabelLegacy, i.e. display bottom edge.
labelPosition | The bitmask defining the position(s) at which to display the longitude line labels. |
bool TSLLatLongGridDataLayer::setSpacing | ( | const char *const | feature, |
int | spacing ) |
Set the spacing between the major latitude and longitude grid lines.
The default spacing is 10 degrees.
feature | either "lonMajorDegree" or "latMajorDegree" |
spacing | between the grid lines in degrees (range 1 to 30) |
void TSLLatLongGridDataLayer::setSubGridFormatCallback | ( | TSLLatLongGridDataLayerFormatCallback * | callbackFunc, |
void * | arg ) |
This method allows users to provide a callback to format the text drawn at for a subgrid label. If a callback is not supplied then it will default to decimal degrees, with a maximum of 3 decimal places.
callbackFunc | The callback to be used. If NULL is passed then the existing callback will be removed and will revert to the default functionality |
arg | This user value will be passed to the callback function when it is called. It will remain in the ownership of the user. |
void TSLLatLongGridDataLayer::setSubGridLabelPosition | ( | TSLSubGridLabelPositionEnum | position = TSLSubGridLabelDefaultCentre | ) |
This method allows users to change the position of the SubGrid label. The positions available are:
(LHS: Left Hand Side, RHS: Right Hand Side)
position | The position enumeration defining the position at which to display the Sub Grid label. If NULL is passed then the default position is used. |
bool TSLLatLongGridDataLayer::snap | ( | TSLCoord * | snap_pt, |
double & | latitude, | ||
double & | longitude, | ||
bool | force_snap = false, | ||
bool | snapToMiddle = false ) |
This method returns the point snapped to given the initial position.
snap_pt | on entry the point to snap, on exit this may be changed to the centre or lower left of the grid square. |
latitude | [output] latitude of the snapped point |
longitude | [output] longitude of the snapped point |
force_snap | snap to the grid square even if snapable() would return false. |
snapToMiddle | if true then snap the point to the middle of the square |
bool TSLLatLongGridDataLayer::snapable | ( | ) | const |
Returns true if snap() snaps points to the nearest grid square, false otherwise.
void TSLLatLongGridDataLayer::snapable | ( | bool | value | ) |
This controls whether snap() snaps points to the nearest grid square.
value | Pass true if snap is to snap to the nearest grid square. |
void TSLLatLongGridDataLayer::tickLength | ( | int | degrees, |
int | tenthsMinutes ) |
Set the pixel size of the tick lengths.
degrees | the length of the degree tick in pixels (default 8 pixels) |
tenthsMinutes | the length of the tenths or minutes tick in pixels (default 2 pixels) |
void TSLLatLongGridDataLayer::ticks | ( | bool | ticks | ) |
Draw ticks on the latitude and longitude lines.
ticks | If the value is true then a tick is drawn every degree or 0.1 degree. |