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

Detailed Description

Utility class providing some useful functions.

Static Public Member Functions

static bool appendData (TSLStandardDataLayer *layer, const char *filename, const char *filter, const TSLFeatureCodeMapping *featureCodeMapping, int noFeatures, double xscale, double yscale, double xoffset=0, double yoffset=0, const char *configfile="", bool expandMultiPartObjects=true, bool decomplexifyOnImport=false)
 
static bool convertTMFTileToHostFormat (const char *inFilename, const char *outFilename)
 
static bool exportData (TSLStandardDataLayer *layer, const char *filename, const char *filter, const TSLFeatureCodeMapping *featureCodeMapping, int noFeatures, double xscale, double yscale, double xoffset=0, double yoffset=0, const char *configfile="")
 
static const char * getMapLinkHome ()
 
static const char * getMapLinkUserHome ()
 
static const char * getMapLinkVersion (int *majorVersionNumber, int *minorVersionNumber)
 
static unsigned int getThreadedOptions ()
 
static void setMaxThreads (unsigned int max)
 
static int getMaxThreads ()
 
static bool importData (TSLStandardDataLayer *layer, const char *filename, const char *filter, const TSLFeatureCodeMapping *featureCodeMapping, int noFeatures, double xscale, double yscale, double xoffset=0, double yoffset=0, const char *configfile="", bool expandMultiPartObjects=true, bool decomplexifyOnImport=false)
 
static bool nearestPointOnLine (const TSLCoordSet &coordSet, bool closed, TSLCoord &s1, TSLCoord &s2, TSLCoord &pt)
 
static bool rotateEnvelope (TSLEnvelope *env, double rotation, TSLTMC cx, TSLTMC cy)
 
static void setMapLinkHome (const char *newHome, bool setDefault=false)
 
static void setThreadedOptions (unsigned int flags)
 
static int sizeOfEntity (const TSLEntity *entity)
 
static bool unlockSupport (TSLKeyedOption option, const char *key)
 
static bool validateEntityUpdates (TSLMapDataLayer *map, const TSLEntitySet *updatedData, const TSLPolygon *boundary, TSLSLMEntityRefHandler *refHandler, const int *featuresToIgnore=NULL, int numberToIgnore=0, const char *brokenFeatureAttributeKey="BK")
 
static bool tslsupported (TSLKeyedOption opt)
 

Member Function Documentation

◆ appendData()

static bool TSLUtilityFunctions::appendData ( TSLStandardDataLayer * layer,
const char * filename,
const char * filter,
const TSLFeatureCodeMapping * featureCodeMapping,
int noFeatures,
double xscale,
double yscale,
double xoffset = 0,
double yoffset = 0,
const char * configfile = "",
bool expandMultiPartObjects = true,
bool decomplexifyOnImport = false )
static

Import a data file from the named file using the specified import filter.

Any data imported will be appended to the current contents of the data layer.

Parameters
layerStandard Data Layer to import data into.
filenameName of file to append.
filterImport filter to use.
featureCodeMappingdefines how to map Native Feature Codes defined in the source data to MapLink Feature IDs used in the system.
noFeaturesnumber of features in the featureCodeMapping array.
xscaleNumber of TMC units per import unit
yscaleNumber of TMC units per import unit
xoffsetOffset to use in import units
yoffsetOffset to use in import units
configfileAny special info
expandMultiPartObjectsIf true, will flatten multi-part objects on import. If false multi-part objects are imported as is. Default is true for compatibility.
decomplexifyOnImportIf true, polygons will be decomplexified on import. Note that this can have a significant impact on import performance.
Returns
true on success, false otherwise.

◆ convertTMFTileToHostFormat()

static bool TSLUtilityFunctions::convertTMFTileToHostFormat ( const char * inFilename,
const char * outFilename )
static

Convert the specified file to use the byte order of the host platform.

This method allows the user to load in a TMF file in either Windows NT or UNIX byte-order format and save it out using the byte-order of the host platform. This will obviate the need for the byte-swapping to be done when loading the tiles from disk which will improve the performance of system.

Parameters
inFilenamethe name of the TMF file to load
outFilenamethe name to save the byte-swapped file to.
Returns
true if successfully saved, false otherwise.

◆ exportData()

static bool TSLUtilityFunctions::exportData ( TSLStandardDataLayer * layer,
const char * filename,
const char * filter,
const TSLFeatureCodeMapping * featureCodeMapping,
int noFeatures,
double xscale,
double yscale,
double xoffset = 0,
double yoffset = 0,
const char * configfile = "" )
static

Export a layer to the named file using the specified import filter.

Parameters
layerStandard Data Layer to export data from
filenameName of file to export to
filterExport filter to use
featureCodeMappingdefines how to map MapLink Feature IDs used in the system to Native Feature Codes to be defined in the destination data
noFeaturesnumber of features in the featureCodeMapping array
xscaleNumber of TMC units per export unit
yscaleNumber of TMC units per export unit
xoffsetOffset to use in export units
yoffsetOffset to use in export units
configfileConfiguration file that is passed to the import filter. How this file is used is a detail specific to the filter. If an absolute path name is given then this is used verbatim. If only the filename is given then the standard locations (depending on OS) are searched, including the MapLink installation bin directory. An absolute path name should be used to guarantee the correct file is used for both import and export.
Returns
true on success, false otherwise.

◆ getMapLinkHome()

static const char * TSLUtilityFunctions::getMapLinkHome ( )
static

Return the path to the home directory of MapLink, dependent on the version of the library.

◆ getMapLinkUserHome()

static const char * TSLUtilityFunctions::getMapLinkUserHome ( )
static

Returns the path to the current user's local home directory of MapLink, dependent on the version of the library.

◆ getMapLinkVersion()

static const char * TSLUtilityFunctions::getMapLinkVersion ( int * majorVersionNumber,
int * minorVersionNumber )
static

Return version information for the library.

Returns a pointer to static memory containing a string description of the version.

◆ getMaxThreads()

static int TSLUtilityFunctions::getMaxThreads ( )
static

MapLink is capable of executing certain processes in parallel.

This method allows the user to query the maximum number of parallel threads.

Returns
The maximum number of threads.

◆ getThreadedOptions()

static unsigned int TSLUtilityFunctions::getThreadedOptions ( )
static

MapLink is thread safe when used in particular scenarios. Please refer to the Developers Guide for additional information.

This method allows the user to query the thread locks settings.

Returns a set of bits as defined by TSLThreadedOptionsEnum.

◆ importData()

static bool TSLUtilityFunctions::importData ( TSLStandardDataLayer * layer,
const char * filename,
const char * filter,
const TSLFeatureCodeMapping * featureCodeMapping,
int noFeatures,
double xscale,
double yscale,
double xoffset = 0,
double yoffset = 0,
const char * configfile = "",
bool expandMultiPartObjects = true,
bool decomplexifyOnImport = false )
static

Import a data file from the named file using the specified import filter.

The current contents of the data layer will be destroyed.

Parameters
layerStandard Data Layer to import data into
filenameName of file to import
filterImport filter to use. This corresponds to the name of the library you wish to use, without its file extension. For example, to use the ShapeFile filter, this should be listed as 'shpfilter' as this is the name of the library as it appears in the MapLink bin directory.
featureCodeMappingdefines how to map Native Feature Codes defined in the source data to MapLink Feature IDs used in the system
noFeaturesnumber of features in the featureCodeMapping array
xscaleNumber of TMC units per import unit
yscaleNumber of TMC units per import unit
xoffsetOffset to use in import units
yoffsetOffset to use in import units
configfileConfiguration file that is passed to the import filter. How this file is used is a detail specific to the filter. If an absolute path name is given then this is used verbatim. If only the filename is given then the standard locations (depending on OS) are searched, including the MapLink installation bin directory. An absolute path name should be used to guarantee the correct file is used for both import and export.
expandMultiPartObjectsIf true, will flatten multi-part objects on import. If false multi-part objects are imported as is. Default is true for compatibility.
decomplexifyOnImportIf true, polygons will be decomplexified on import. Note that this can have a significant impact on import performance.
Returns
true on success, false otherwise.

◆ nearestPointOnLine()

static bool TSLUtilityFunctions::nearestPointOnLine ( const TSLCoordSet & coordSet,
bool closed,
TSLCoord & s1,
TSLCoord & s2,
TSLCoord & pt )
static

Calculates the nearest point within the coordinate set.

Parameters
coordSetThe coordinate set.
closedSet to true, if the coordinate set is closed; false for an open set.
s1The points defining the start of the line segment which will contain the required point.
s2The points defining the end of the line segment which will contain the required point.
ptThe nearest point.
Returns
true if the closest point is found, false otherwise.

◆ rotateEnvelope()

static bool TSLUtilityFunctions::rotateEnvelope ( TSLEnvelope * env,
double rotation,
TSLTMC cx,
TSLTMC cy )
static

Updates an envelope with the extent of its rotated rectangle.

The angle specified is in radians, +ve anti-clockwise from the x-axis. Rotates about specified centre, in TMC.

Returns true if ok, false if the maths would blow (ie. resultant coordinate would not fit into TMC space.).

◆ setMapLinkHome()

static void TSLUtilityFunctions::setMapLinkHome ( const char * newHome,
bool setDefault = false )
static

Sets the path of the MapLink home directory.

This is intended for use by applications, which are deployed without a MapLink installation. MapLink uses this path to locate plugins and configuration files, when not otherwise specified by the application.

The directory provided should contain the 'bin' and 'config' directories of the application.

Parameters
newHomeThe directory to use as the MapLink home directory
setDefaultReserved for future use.

◆ setMaxThreads()

static void TSLUtilityFunctions::setMaxThreads ( unsigned int max)
static

MapLink is capable of executing certain processes in parallel.

This method allows the user to set the maximum number of parallel threads.

Parameters
maxMaximum number of threads

◆ setThreadedOptions()

static void TSLUtilityFunctions::setThreadedOptions ( unsigned int flags)
static

MapLink is thread safe when used in particular scenarios. Please refer to the Developers Guide for additional information.

This method allows the user to set or unset the use of thread locks. This is required in certain situations where we are unable to detect the particular user scenario.

Parameters
flagsa set of bits as defined by TSLThreadedOptionsEnum.

◆ sizeOfEntity()

static int TSLUtilityFunctions::sizeOfEntity ( const TSLEntity * entity)
static

Returns the in-memory size in bytes of the provided entity. If the entity is a TSLEntitySet then the returned size will include any entities within the set. If the entity has a TSLDataSet then this will also be included in the returned size.

◆ tslsupported()

static bool TSLUtilityFunctions::tslsupported ( TSLKeyedOption opt)
static

Deprecated methods. Use the new methods which allow feature code mapping to occur.

◆ unlockSupport()

static bool TSLUtilityFunctions::unlockSupport ( TSLKeyedOption option,
const char * key )
static

Enables extended support features protected by license keys, such as File Format Interoperability and JPEG2000 file support.

Important Notes: The license key to unlock support needs to be obtained directly from Envitia. This is not the MapLink Studio filter license key. To obtain a key, contact suppo.nosp@m.rt@e.nosp@m.nviti.nosp@m.a.co.nosp@m.m. Please be aware that acquiring a key may increase the cost of your runtime license.

Parameters
optionthe option being enabled.
keythe license key to enable the option.
Returns
True if successful , False otherwise.

◆ validateEntityUpdates()

static bool TSLUtilityFunctions::validateEntityUpdates ( TSLMapDataLayer * map,
const TSLEntitySet * updatedData,
const TSLPolygon * boundary,
TSLSLMEntityRefHandler * refHandler,
const int * featuresToIgnore = NULL,
int numberToIgnore = 0,
const char * brokenFeatureAttributeKey = "BK" )
static

Checks the areas of entities within the given entity set against the original versions of those entities within the map in order to check that replacement, addition and removal of these entities would not cause a hole or overlapping features to be created in the map.

This validation uses the following rules: 1) The combined area of all entities within the given entity set should equal the combined area of the original entities in the map. Entities which have a negative feature ID are assumed to be departing from the map. Entities with positive feature IDs will be treated as either modifications to an existing entity if the map contains an entity with the same entity ID, otherwise they will be considered to be new additions to the map.

Any entities that have the broken attribute (defined by the brokenFeatureAttributeKey parameter, default BK) set to true in their TSLDataSet will not be included in the area calculation. For these entities, both the original entity in the map and the entity in the given entity set will not be counted, even if only one of the entities has the broken attribute.

Entities which are departing from the map in the given entity set but which are not present in the map will not cause the validation to fail. An information note will be placed on the TSLErrorStack for each of these entities.

2) The area of the boundary of the update should equal the combined area of the entities within the set. If no boundary polygon is provided then this rule is ignored. Note that the boundary polygon provided must include any holes present in the update for this rule to pass. If any broken entities were detected when processing rule 1 a different error will be placed on the TSLErrorStack if this rule fails. This allows for an update which passes rule 1 but fails this rule due to the presence of the broken features to be detected.

Parameters
mapThe map against which the update is to be validated.
updatedDataAn entity set containing the update to validate.
boundaryA polygon that defines the boundary of the update.
refHandlerThe entity reference handler to use in conjunction with the map.
featuresToIgnoreAn optional list of feature codes to ignore. Entities with this feature code will not have their area included in the validation process.
numberToIgnoreThe size of the previous array.
brokenFeatureAttributeKeyThe two-character key code that represents the entry in an entity's dataset that indicates whether the entity is broken or not. By default this is BK (the default setting for imported OSMasterMap data as defined by the OSMastetMap.ini configuration file).
Returns
true if the above rules are satisfied, or false if they are not. In this case additional information will be added to the TSLErrorStack describing the cause of the failure.