GL Studio C++ Runtime API
|
Map chart data source for loading Shapefiles. More...
#include <gls_map_shapefile.h>
Classes | |
class | RenderingAttorney |
struct | ShapePoint |
Cartesian coordinate used by the points that define the paths loaded from shapefiles. More... | |
Public Types | |
typedef void(* | RenderPointFeatureCB) (void *const userData, const char *featureSet, const char *featureType, double longitude, double latitude, const glsColor &color, const GeoRect ®ion, const double logicalHeight) |
typedef void(* | RenderLineFeatureCB) (void *const userData, const char *featureSet, const char *featureType, const DynamicArray< ShapePoint > &points, const GeoRect ®ion, const double logicalHeight) |
Public Member Functions | |
ShapefileMapChartDataSource () | |
Constructor. | |
~ShapefileMapChartDataSource () | |
Destructor - stops rendering and releases all libraries. | |
bool | LoadLibraryAs (const char *shapefileRootPath, LibraryID libraryID) |
bool | UnloadLibrary (LibraryID libraryID) |
DynamicArray< LibraryID > | GetLoadedLibraries () const |
bool | EnableLibraryRendering (LibraryID libraryID, bool enable=true) |
bool | IsLibraryRenderingEnabled (LibraryID libraryID, bool &isEnabled) const |
DynamicArray< const char * > | GetOrderedFeatureSetNames (LibraryID libraryID) const |
bool | SetOrderedFeatureSetNames (LibraryID libraryID, const DynamicArray< const char * > &orderedFeatureSetNames) |
DynamicArray< const char * > | GetFeatureTypes (LibraryID libraryID, const char *featureSet) const |
bool | GetFeatureSetVisibility (LibraryID libraryID, const char *featureSet, const char *featureType, bool &isVisible) const |
bool | SetFeatureSetVisibility (LibraryID libraryID, const char *featureSet, const char *featureType, bool isVisible) |
bool | GetFeatureSetPointStyle (LibraryID libraryID, const char *featureSet, const char *featureType, glsColor &color, RenderPointFeatureCB &renderCB, void *&userData, bool &useMapScale) const |
bool | SetFeatureSetPointStyle (LibraryID libraryID, const char *featureSet, const char *featureType, const glsColor &color, const RenderPointFeatureCB renderCB=NULL, void *const userData=NULL, const bool useMapScale=NULL) |
bool | GetFeatureSetLineStyle (LibraryID libraryID, const char *featureSet, const char *featureType, glsColor &color, float &width, uint16_t &stipplePattern, int &stippleMultiplier) const |
bool | GetFeatureSetLineStyle (const LibraryID libraryID, const char *const featureSet, const char *const featureType, RenderLineFeatureCB &renderCB, void *&userData) const |
bool | SetFeatureSetLineStyle (LibraryID libraryID, const char *featureSet, const char *featureType, glsColor color, float width=DEF_LINE_WIDTH, uint16_t stipplePattern=DEF_LINE_STIPPLE_PATTERN, int stippleMultiplier=0) |
bool | SetFeatureSetLineStyle (LibraryID libraryID, const char *featureSet, const char *featureType, const RenderLineFeatureCB renderCB, void *const userData=NULL) |
bool | GetFeatureSetFillStyle (LibraryID libraryID, const char *featureSet, const char *featureType, glsColor &color, bool &drawBoundary, glsColor &boundaryColor, float &boundaryWidth, uint16_t &boundaryStipplePattern, int &boundaryStippleMultiplier) const |
bool | SetFeatureSetFillStyle (LibraryID libraryID, const char *featureSet, const char *featureType, const glsColor &color, bool drawBoundary=false, const glsColor &boundaryColor=glsColor(0, 0, 0, 255), float boundaryWidth=DEF_LINE_WIDTH, uint16_t boundaryStipplePattern=DEF_LINE_STIPPLE_PATTERN, int boundaryStippleMultiplier=0) |
bool | GetFeatureSetTextStyle (LibraryID libraryID, const char *featureSet, const char *featureType, GlsFontBase *&glsFont, glsColor &textColor, double &scale, double &xOffset, double &yOffset, bool &isVisible) const |
bool | SetFeatureSetTextStyle (LibraryID libraryID, const char *featureSet, const char *featureType, GlsFontBase *glsFont, const glsColor &textColor=glsColor(0, 0, 0, 255), double scale=1.0, double xOffset=0.0f, double yOffset=0.0f, bool isVisible=true) |
bool | SetCacheDimensions (LibraryID libraryID, double degreesLongitude, double degreesLatitude) |
bool | GetAvailableCoverage (GeoRect *dest) DISTI_METHOD_OVERRIDE |
See base class. | |
LayerID | GetBestLayer (GlsMapView *view, GlsMapChart *chart) const DISTI_METHOD_OVERRIDE |
void | GetCellList (const GeoRect &coverage, LayerID layerID, double viewLogicalHeight, double viewGeoHeight, MapChartCellList &viewList) DISTI_METHOD_OVERRIDE |
See base class. | |
Public Member Functions inherited from GlsMapChartDataSource | |
virtual | ~GlsMapChartDataSource () |
Destructor for abstract base class. | |
virtual void | PostDraw (GlsMapView *view, GlsMapChart *chart) |
virtual bool | AreAllCellsLoaded (GlsMapView *view, GlsMapChart *chart) |
Additional Inherited Members | |
Protected Member Functions inherited from GlsMapChartDataSource | |
GlsMapChartDataSource () | |
Constructor for subclasses. | |
Map chart data source for loading Shapefiles.
A feature set often (but not always) comes from a single .shp file with a single Shapefile layer and contains different subtypes of features (e.g., natural.shp may have feature types "forest", "river", etc.).
For instance, the "natural" feature set could have black as the line color for all its features but override it to blue for rivers and green for forests.
typedef void( * RenderLineFeatureCB) (void *const userData, const char *featureSet, const char *featureType, const DynamicArray< ShapePoint > &points, const GeoRect ®ion, const double logicalHeight) |
Draw callback for a user supplied line feature render routine. This routine is called with the model matrix loaded appropriately as to draw at the correct location.
userData | user supplied data for callback (supplied with SetPointFeatureRenderCB()) |
featureSet | The name of the feature set (often corresponds to a single .shp file). |
featureType | The name of a type of feature within the feature set (e.g., in a "natural" feature set, there might be "water" and "forest" among others). |
points | the vertices of the path. |
region | region of the chart that is rendering |
logicalHeight | height in logical units corresponding to height of render region |
typedef void( * RenderPointFeatureCB) (void *const userData, const char *featureSet, const char *featureType, double longitude, double latitude, const glsColor &color, const GeoRect ®ion, const double logicalHeight) |
Draw callback for a user supplied point feature render routine. This routine is called with the model matrix loaded appropriately as to draw at the correct location using the origin (i.e., a vertex draw to (0,0) will map to the correct location as described by pointCoord. This routine does not need to save the model stack as the caller will push and pop (save) it accordingly.
userData | user supplied data for callback (supplied with SetPointFeatureRenderCB()) |
featureSet | The name of the feature set (often corresponds to a single .shp file). |
featureType | The name of a type of feature within the feature set (e.g., in a "natural" feature set, there might be "water" and "forest" among others). |
longitude | longitude of point feature |
latitude | longitude of point feature |
color | color assigned to point feature |
region | region of the chart that is rendering |
logicalHeight | height in logical units corresponding to height of render region |
bool EnableLibraryRendering | ( | LibraryID | libraryID, |
bool | enable = true |
||
) |
Enable a given library to render. By default, only one library is set to render at a time. This function allows the user to render multiple libraries at a time, which may be useful if the libraries have orthogonal features in them, e.g., one library for roads, one for buildings, etc. (More commonly, a library has multiple feature sets within it, and each library covers the same geographic area but represents a different scale or level of detail.) Libraries are rendered in the order of their LibraryIDs, starting with the smallest value on the "bottom" of the texture and the next smallest writing on top of it (possibly overwriting).
libraryID | The library to update. If not found, this function emits a warning to the console and returns false without changing rendering. |
enable | Whether the library should be enabled (defaults to true). |
|
virtual |
See base class
Reimplemented from GlsMapChartDataSource.
bool GetFeatureSetFillStyle | ( | LibraryID | libraryID, |
const char * | featureSet, | ||
const char * | featureType, | ||
glsColor & | color, | ||
bool & | drawBoundary, | ||
glsColor & | boundaryColor, | ||
float & | boundaryWidth, | ||
uint16_t & | boundaryStipplePattern, | ||
int & | boundaryStippleMultiplier | ||
) | const |
Retrieves the current fill style of the features in feature set.
libraryID | The library to query. | |
featureSet | The name of the feature set (often corresponds to a single .shp file). If null or not found, it emits a warning to the console and returns false. | |
featureType | The name of a type of feature within the feature set (e.g., in the "natural" feature set, there might be "water" and "forest" among others). If null or empty, it returns the default visibility for the feature set. If not found, it emits a warning to the console and returns false. | |
[out] | color | The fill color for the requested features. |
[out] | drawBoundary | Whether or not to draw the area boundary |
[out] | boundaryColor | The boundary color for the requested features. |
[out] | boundaryWidth | The line width |
[out] | boundaryStipplePattern | The stipple pattern for lines (see documentation of glLineStipple()) |
[out] | boundaryStippleMultiplier | The multiplier for stippling (see documentation of glLineStipple()) |
bool GetFeatureSetLineStyle | ( | LibraryID | libraryID, |
const char * | featureSet, | ||
const char * | featureType, | ||
glsColor & | color, | ||
float & | width, | ||
uint16_t & | stipplePattern, | ||
int & | stippleMultiplier | ||
) | const |
Retrieves the current line style of the features in feature set.
libraryID | The library to query. | |
featureSet | The name of the feature set (often corresponds to a single .shp file). If null or not found, it emits a warning to the console and returns false. | |
featureType | The name of a type of feature within the feature set (e.g., in the "natural" feature set, there might be "water" and "forest" among others). If null or empty, it returns the default line style for the feature set. If not found, it emits a warning to the console and returns false. | |
[out] | color | The line color for the requested features. |
[out] | width | The line width for the requested features. |
[out] | stipplePattern | The line stipple pattern for the requested features. |
[out] | stippleMultiplier | The line stipple multiplier for the requested features. |
bool GetFeatureSetLineStyle | ( | const LibraryID | libraryID, |
const char *const | featureSet, | ||
const char *const | featureType, | ||
RenderLineFeatureCB & | renderCB, | ||
void *& | userData | ||
) | const |
Retrieves the current line callback for the feature set.
libraryID | The library to query. | |
featureSet | The name of the feature set (often corresponds to a single .shp file). If null or not found, it emits a warning to the console and returns false. | |
featureType | The name of a type of feature within the feature set (e.g., in the "natural" feature set, there might be "water" and "forest" among others). If null or empty, it returns the default line style for the feature set. If not found, it emits a warning to the console and returns false. | |
[out] | renderCB | The line callback |
[out] | userData | The user data passed to the callback |
bool GetFeatureSetPointStyle | ( | LibraryID | libraryID, |
const char * | featureSet, | ||
const char * | featureType, | ||
glsColor & | color, | ||
RenderPointFeatureCB & | renderCB, | ||
void *& | userData, | ||
bool & | useMapScale | ||
) | const |
Retrieves the current point style of the features in feature set.
libraryID | The library to query. | |
featureSet | The name of the feature set (often corresponds to a single .shp file). If null or not found, it emits a warning to the console and returns false. | |
featureType | The name of a type of feature within the feature set (e.g., in the "natural" feature set, there might be "water" and "forest" among others). If null or empty, it returns the default point style for the feature set. If not found, it emits a warning to the console and returns false. | |
[out] | color | The point color for the requested features. |
[out] | renderCB | render callback else NULL for no callback |
[out] | userData | user supplied data to be handed to callback |
[out] | useMapScale | true if point feature should scale with the map (will become larger as the view zooms in), false is point feature should scale to attempt maintain the same size in logical space regardless of the map zoom |
bool GetFeatureSetTextStyle | ( | LibraryID | libraryID, |
const char * | featureSet, | ||
const char * | featureType, | ||
GlsFontBase *& | glsFont, | ||
glsColor & | textColor, | ||
double & | scale, | ||
double & | xOffset, | ||
double & | yOffset, | ||
bool & | isVisible | ||
) | const |
Retrieves the current text style of the features in feature set.
libraryID | The library to query. | |
featureSet | The name of the feature set (often corresponds to a single .shp file). If null or not found, it emits a warning to the console and returns false. | |
featureType | The name of a type of feature within the feature set (e.g., in the "natural" feature set, there might be "water" and "forest" among others). If null or empty, it returns the default visibility for the feature set. If not found, it emits a warning to the console and returns false. | |
[out] | glsFont | The instance of a font in this GL Studio project |
[out] | textColor | The text color for the requested features. |
[out] | isVisible | Whether the text is visible for the requested features. |
[out] | scale | The scale of the text (default = 1.0) |
[out] | xOffset | horizontal offset from the default text location (text starts at the center of its objects extents) |
[out] | yOffset | vertical offset from the default text location (text starts at the center of its objects extents) |
bool GetFeatureSetVisibility | ( | LibraryID | libraryID, |
const char * | featureSet, | ||
const char * | featureType, | ||
bool & | isVisible | ||
) | const |
Retrieves the current visibility of the features in the given feature set, optionally limited to a single feature type.
libraryID | The library to query. | |
featureSet | The name of the feature set (often corresponds to a single .shp file). If null, empty, or not found, it emits a warning to the console and returns false. | |
featureType | The name of a type of feature within the feature set (e.g., in a "natural" feature set, there might be "water" and "forest" among others). If null or empty, it returns the default visibility for the feature set. If not found, it emits a warning to the console and returns false. | |
[out] | isVisible | Whether the requested features are visible. |
DynamicArray<const char*> GetFeatureTypes | ( | LibraryID | libraryID, |
const char * | featureSet | ||
) | const |
Returns a list of feature types in the given featureSetName within the given library.
libraryID | The library to query. |
featureSet | The name of the feature set. If null or not found, this function emits an error to the console and returns an empty array. |
DynamicArray<LibraryID> GetLoadedLibraries | ( | ) | const |
Returns a list of all currently loaded library IDs.
DynamicArray<const char*> GetOrderedFeatureSetNames | ( | LibraryID | libraryID | ) | const |
Returns a list of feature set names in the order they are to be drawn, from bottom to top.
libraryID | The library to query. If not found, the function emits a warning to the console and returns an empty array. |
bool IsLibraryRenderingEnabled | ( | LibraryID | libraryID, |
bool & | isEnabled | ||
) | const |
Query whether a given library is set to render.
libraryID | The library to update. If not found, this function emits a warning to the console and returns false without changing the output parameter. | |
[out] | isEnabled | Whether the library is enabled |
bool LoadLibraryAs | ( | const char * | shapefileRootPath, |
LibraryID | libraryID | ||
) |
Load a Shapefile (or files) from the given path and associate it with a given library identifier.
shapefileRootPath | path to Shapefile or directory containing Shapefile(s). Multiple files in one folder will be considered one library. If null, empty, or not found, the function emits an error and returns false. |
libraryID | The library ID (see note), often the scale of this library. It acts as a handle to this library for other operations on it using this data source. |
If the path loads successfully but the ID has already been used, it will unload the old data and replace it with the data from this path after emitting a warning to the console (unload first to avoid the warning).
The library ID also controls what order multiple enabled libraries are rendered in, starting with the lowest libraryID and going to the largest.
bool SetCacheDimensions | ( | LibraryID | libraryID, |
double | degreesLongitude, | ||
double | degreesLatitude | ||
) |
Sets the geographical size of the region to cache. Each library has its own cache region.
libraryID | The library whose cache size to adjust. |
degreesLongitude | the width of cache size in degrees of longitude |
degreesLatitude | the height of cache size in degrees of latitude |
bool SetFeatureSetFillStyle | ( | LibraryID | libraryID, |
const char * | featureSet, | ||
const char * | featureType, | ||
const glsColor & | color, | ||
bool | drawBoundary = false , |
||
const glsColor & | boundaryColor = glsColor(0, 0, 0, 255) , |
||
float | boundaryWidth = DEF_LINE_WIDTH , |
||
uint16_t | boundaryStipplePattern = DEF_LINE_STIPPLE_PATTERN , |
||
int | boundaryStippleMultiplier = 0 |
||
) |
Sets the fill style for polygon features in the feature set.
libraryID | The library to query. |
featureSet | The name of the feature set. If null, sets the style for all features sets. If non-null and not found, this function emits a warning to the console and returns false |
featureType | The name of the feature. If null or empty, it applies to the default attributes for the feature set. If not found, it creates a new feature attribute override entry. |
color | The RGBA color value for filling polygons. |
boundaryColor | The boundary color for the requested features. |
drawBoundary | Whether or not to draw the area boundary |
boundaryWidth | The line width |
boundaryStipplePattern | The stipple pattern for lines (see documentation of glLineStipple()) |
boundaryStippleMultiplier | The multiplier for stippling (see documentation of glLineStipple()) |
bool SetFeatureSetLineStyle | ( | LibraryID | libraryID, |
const char * | featureSet, | ||
const char * | featureType, | ||
glsColor | color, | ||
float | width = DEF_LINE_WIDTH , |
||
uint16_t | stipplePattern = DEF_LINE_STIPPLE_PATTERN , |
||
int | stippleMultiplier = 0 |
||
) |
Sets the line style (outline for polygon features) for features in a set.
libraryID | The library to query. |
featureSet | The name of the feature set. If null, sets the style for all features sets. If non-null and not found, this function emits a warning to the console and returns false |
featureType | The name of the feature. If null or empty, it applies to the default attributes for the feature set. If not found, it creates a new feature attribute override entry. |
color | The RGBA color value for lines |
width | The line width |
stipplePattern | The stipple pattern for lines (see documentation of glLineStipple()) |
stippleMultiplier | The multiplier for stippling (see documentation of glLineStipple()) |
bool SetFeatureSetLineStyle | ( | LibraryID | libraryID, |
const char * | featureSet, | ||
const char * | featureType, | ||
const RenderLineFeatureCB | renderCB, | ||
void *const | userData = NULL |
||
) |
Sets the line callback for features in a set.
libraryID | The library to query. |
featureSet | The name of the feature set. If null, sets the style for all features sets. If non-null and not found, this function emits a warning to the console and returns false |
featureType | The name of the feature. If null or empty, it applies to the default attributes for the feature set. If not found, it creates a new feature attribute override entry. |
renderCB | the line callback |
userData | The optional user data passed to the callback, can be NULL if unused. |
bool SetFeatureSetPointStyle | ( | LibraryID | libraryID, |
const char * | featureSet, | ||
const char * | featureType, | ||
const glsColor & | color, | ||
const RenderPointFeatureCB | renderCB = NULL , |
||
void *const | userData = NULL , |
||
const bool | useMapScale = NULL |
||
) |
Sets the point style (outline for polygon features) for features in a set.
libraryID | The library to query. |
featureSet | The name of the feature set. If null, sets the style for all features sets. If non-null and not found, this function emits a warning to the console and returns false |
featureType | The name of the feature. If null or empty, it applies to the default attributes for the feature set. If not found, it creates a new feature attribute override entry. |
color | The RGBA color value for points |
renderCB | render callback else NULL for no callback |
userData | user supplied data to be handed to callback |
useMapScale | true if point feature should scale with the map (will become larger as the view zooms in), false is point feature should scale to attempt maintain the same size in logical space regardless of the map zoom |
bool SetFeatureSetTextStyle | ( | LibraryID | libraryID, |
const char * | featureSet, | ||
const char * | featureType, | ||
GlsFontBase * | glsFont, | ||
const glsColor & | textColor = glsColor(0, 0, 0, 255) , |
||
double | scale = 1.0 , |
||
double | xOffset = 0.0f , |
||
double | yOffset = 0.0f , |
||
bool | isVisible = true |
||
) |
Sets the text style for a feature set.
libraryID | The library to query. |
featureSet | The name of the feature set. If null, sets the style for all features sets. If non-null and not found, this function emits a warning to the console and returns false |
featureType | The name of the feature. If null or empty, it applies to the default attributes for the feature set. If not found, it creates a new feature attribute override entry. |
glsFont | The instance of a font in this GL Studio project |
textColor | Color of the text. (Defaults to black.) |
isVisible | Whether the text is visible for the requested features. |
scale | The scale of the text (default = 1.0) |
xOffset | horizontal offset from the default text location (text starts at the center of its objects extents) |
yOffset | vertical offset from the default text location (text starts at the center of its objects extents) |
bool SetFeatureSetVisibility | ( | LibraryID | libraryID, |
const char * | featureSet, | ||
const char * | featureType, | ||
bool | isVisible | ||
) |
Sets the visibility for features in a feature set.
libraryID | The library to update. |
featureSet | The name of the feature set. If null, sets the visibility for all features sets. If non-null and not found, this function emits a warning to the console and returns false without changing visibility. |
featureType | The type of feature within the feature set. If null or empty, it applies to the default feature set. If not found, it creates a new feature attribute override entry. |
isVisible | The visibility to be applied. |
bool SetOrderedFeatureSetNames | ( | LibraryID | libraryID, |
const DynamicArray< const char * > & | orderedFeatureSetNames | ||
) |
Sets the feature set names in the order they are to be drawn.
libraryID | The library to update. |
orderedFeatureSetNames | The list of names in order from bottom to top. If any feature set name is null, empty, or does not exist or if a name is missing from the list, a warning is emitted to the console, and the function returns false without changing draw order. |
bool UnloadLibrary | ( | LibraryID | libraryID | ) |
Unloads a given library.