GL Studio C++ Runtime API
gls_map_shapefile.h
Go to the documentation of this file.
1 /*! \file
2 \brief The shapefile data source for GlsMapToolkit.
3 
4 \par Copyright Information
5 
6  Copyright (c) 2016 The DiSTI Corporation.<br>
7  11301 Corporate Blvd; Suite 100<br>
8  Orlando, Florida 32817<br>
9  USA<br>
10  <br>
11  All rights reserved.<br>
12 
13 This Software contains proprietary trade secrets of DiSTI and may not be
14 reproduced, in whole or part, in any form, or by any means of electronic,
15 mechanical, or otherwise, without the written permission of DiSTI. Said
16 permission may be derived through the purchase of applicable DiSTI product
17 licenses which detail the distribution rights of this content and any
18 Derivative Works based on this or other copyrighted DiSTI Software.
19 
20 NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26 
27 LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34 EXCEED FIVE DOLLARS (US$5.00).
35 
36 The aforementioned terms and restrictions are governed by the laws of the
37 State of Florida and the United States of America.
38 */
39 
40 #ifndef INCLUDED_GLS_MAP_SHAPEFILE_H
41 #define INCLUDED_GLS_MAP_SHAPEFILE_H
42 #include "gls_include.h"
44 #include "scoped_ptr.h"
45 #include "shapefile_util.h"
46 
47 #define LIB_BASE_NAME "gls_map_shapefile"
48 #include "gls_auto_lib.h"
49 #undef LIB_BASE_NAME
50 
51 // Also auto-lib the third-party library GDAL
52 #undef GLS_LIB_TYPE
53 #undef GLS_LIB_CRT_SUFFIX
54 #undef GLS_AUTOLIB_SUFFIX
55 #define GLS_AUTOLIB_SUFFIX
56 #define GLS_LIB_TYPE
57 #define GLS_LIB_CRT_SUFFIX
58 #define LIB_BASE_NAME "gdal"
59 #include "gls_auto_lib.h"
60 #undef LIB_BASE_NAME
61 #undef GLS_LIB_TYPE
62 #undef GLS_LIB_CRT_SUFFIX
63 #undef GLS_AUTOLIB_SUFFIX
64 
65 namespace disti
66 {
67 class GlsFontBase;
68 /// \defgroup ds_Shapefile Shapefile
69 /// Shapefile data source
70 
71 ///////////////////////////////////////////////////////////////////////////////////////////////////
72 /// \brief Map chart data source for loading Shapefiles
73 ///
74 /// \note The ESRI Shapefile specification does not deal with shapefiles at different scales or
75 /// levels of detail (e.g., 1:100k, 1:250k, 1:1M, etc.). This program, paralleling the DNC
76 /// map data source, calls these different shapefiles "libraries". Multiple libraries can
77 /// be loaded simultaneously and then unloaded when desired, all in the same data source.
78 ///
79 /// \note The ESRI Shapefile specification calls sets of features "layers", but the MapToolkit
80 /// already used that term to refer to the different bin sizes it renders the Shapefile's
81 /// vector data at. Due to existing virtual function names with "layer" in them, we retain
82 /// MapToolkit's use of the term and substitute "feature set" (or use "Shapefile layer"
83 /// when necessary) for Shapfile's notion of a "layer".
84 ///
85 /// A feature set often (but not always) comes from a single .shp file with a single
86 /// Shapefile layer and contains different subtypes of features (e.g., natural.shp may have
87 /// feature types "forest", "river", etc.).
88 ///
89 /// \note Each library has a set of attributes (visibility, color, etc.) for each of
90 /// its feature sets, and each feature set has optional attributes to override the defaults
91 /// for a specific feature type within set. These default and overridden attributes can be
92 /// controlled with the setter and getter member functions.
93 ///
94 /// For instance, the "natural" feature set could have black as the line color for all its
95 /// features but override it to blue for rivers and green for forests.
96 ///
97 /// \ingroup ds_Shapefile
98 /// @{
99 ///////////////////////////////////////////////////////////////////////////////////////////////////
101 {
102 public:
103  typedef Shapefile::LibraryID LibraryID; // For easier reading
104  typedef Shapefile::LayerID LayerID;
105 
106  /////////////////////////////////////////////////////////////////////////////////////////////////////
107  /// Draw callback for a user supplied point feature render routine. This routine is called with the
108  /// model matrix loaded appropriately as to draw at the correct location using the origin (i.e., a
109  /// vertex draw to (0,0) will map to the correct location as described by pointCoord. This routine
110  /// does not need to save the model stack as the caller will push and pop (save) it accordingly.
111  /// \param userData user supplied data for callback (supplied with SetPointFeatureRenderCB())
112  /// \param featureSet The name of the feature set (often corresponds to a single .shp file).
113  /// \param featureType The name of a type of feature within the feature set (e.g., in a
114  /// "natural" feature set, there might be "water" and "forest" among others).
115  /// \param longitude longitude of point feature
116  /// \param latitude longitude of point feature
117  /// \param color color assigned to point feature
118  /// \param region region of the chart that is rendering
119  /// \param logicalHeight height in logical units corresponding to height of render region
120  typedef void ( *RenderPointFeatureCB )(
121  void* const userData,
122  const char* featureSet,
123  const char* featureType,
124  double longitude,
125  double latitude,
126  const glsColor& color,
127  const GeoRect& region,
128  const double logicalHeight );
129 
130  /////////////////////////////////////////////////////////////////////////////////////////////////////
131  /// Cartesian coordinate used by the points that define the paths loaded from shapefiles
132  struct ShapePoint
133  {
134  ShapePoint()
135  : x( 0.0f )
136  , y( 0.0f )
137  {
138  }
139 
140  ShapePoint( float x_, float y_ )
141  : x( x_ )
142  , y( y_ )
143  {
144  }
145 
146  float x; ///< \param x horizontal component of the point
147  float y; ///< \param y vertical component of the point
148  };
149 
150  /////////////////////////////////////////////////////////////////////////////////////////////////////
151  /// Draw callback for a user supplied line feature render routine. This routine is called with the
152  /// model matrix loaded appropriately as to draw at the correct location.
153  /// \param userData user supplied data for callback (supplied with SetPointFeatureRenderCB())
154  /// \param featureSet The name of the feature set (often corresponds to a single .shp file).
155  /// \param featureType The name of a type of feature within the feature set (e.g., in a
156  /// "natural" feature set, there might be "water" and "forest" among others).
157  /// \param points the vertices of the path.
158  /// \param region region of the chart that is rendering
159  /// \param logicalHeight height in logical units corresponding to height of render region
160  typedef void ( *RenderLineFeatureCB )(
161  void* const userData,
162  const char* featureSet,
163  const char* featureType,
164  const DynamicArray<ShapePoint>& points,
165  const GeoRect& region,
166  const double logicalHeight );
167 
168  /// Constructor
170 
171  /// Destructor - stops rendering and releases all libraries.
173 
174  /////////////////////////////////////////////////////////////////////////////////////////////////////
175  /// Load a Shapefile (or files) from the given path and associate it with a given library identifier.
176  ///
177  /// \param shapefileRootPath path to Shapefile or directory containing Shapefile(s). Multiple files
178  /// in one folder will be considered one library. If null, empty, or not found, the function
179  /// emits an error and returns false.
180  ///
181  /// \param libraryID The library ID (see note), often the scale of this library. It acts as a
182  /// handle to this library for other operations on it using this data source.
183  ///
184  /// If the path loads successfully but the ID has already been used, it will unload the old
185  /// data and replace it with the data from this path after emitting a warning to the console
186  /// (unload first to avoid the warning).
187  ///
188  /// The library ID also controls what order multiple enabled libraries are rendered in,
189  /// starting with the lowest libraryID and going to the largest.
190  ///
191  /// \note This method can be called repeatedly to add multiple libraries to this data source.
192  /// The loading of different libraries can take place in any order, and multiple libraries
193  /// can be loaded into the same data source object. Only the first library loaded is
194  /// enabled for rendering; EnableLibraryRendering() controls which library or libraries
195  /// render. The libraryID controls the order of rendering when multiple libraries are enabled.
196  ///
197  /// \sa UnloadLibrary()
198  /// \sa GetLoadedLibraries()
199  /// \sa EnableLibraryRendering()
200  /// \note We would name this LoadLibrary(), but Windows \#defines LoadLibrary, which interferes.
201  /// \return Returns whether the path was loaded successfully.
202  bool LoadLibraryAs( const char* shapefileRootPath, LibraryID libraryID );
203 
204  /// Unloads a given library.
205  /// \return true if the library was found.
206  /// \sa LoadLibraryAs()
207  /// \sa GetLoadedLibraries()
208  bool UnloadLibrary( LibraryID libraryID );
209 
210  /// Returns a list of all currently loaded library IDs.
211  /// \sa LoadLibraryAs()
212  /// \sa UnloadLibrary()
214 
215  ///////////////////////////////////////////////////////////////////////////////////////////////////
216  /// Enable a given library to render. By default, only one library is set to render at a time.
217  /// This function allows the user to render multiple libraries at a time, which may be useful
218  /// if the libraries have orthogonal features in them, e.g., one library for roads, one for
219  /// buildings, etc. (More commonly, a library has multiple feature sets within it, and each
220  /// library covers the same geographic area but represents a different scale or level of detail.)
221  /// Libraries are rendered in the order of their LibraryIDs, starting with the smallest value
222  /// on the "bottom" of the texture and the next smallest writing on top of it (possibly overwriting).
223  ///
224  /// \param libraryID The library to update. If not found, this function emits a warning to
225  /// the console and returns false without changing rendering.
226  /// \param enable Whether the library should be enabled (defaults to true).
227  /// \return true if the library was found.
228  /// \sa IsLibraryRenderingEnabled()
229  /// \sa LoadLibraryAs()
230  bool EnableLibraryRendering( LibraryID libraryID, bool enable = true );
231 
232  /// Query whether a given library is set to render.
233  /// \param libraryID The library to update. If not found, this function emits a warning to
234  /// the console and returns false without changing the output parameter.
235  /// \param[out] isEnabled Whether the library is enabled
236  /// \return true if the library was found.
237  /// \sa EnableLibraryRendering()
238  bool IsLibraryRenderingEnabled( LibraryID libraryID, bool& isEnabled ) const;
239 
240  /////////////////////////////////////////////////////////////////////////////////////////////////////
241  /// Returns a list of feature set names in the order they are to be drawn, from bottom to top.
242  /// \param libraryID The library to query. If not found, the function emits a warning to the console
243  /// and returns an empty array.
244  /// \note The caller is NOT responsible to delete the pointers in the array. They are guaranteed
245  /// valid until LoadLibraryAs() or UnloadLibrary() is called for this \a libraryID.
246  /// \sa SetOrderedFeatureSetNames()
247  /// \sa GetFeatureNames()
248  DynamicArray<const char*> GetOrderedFeatureSetNames( LibraryID libraryID ) const;
249 
250  /// Sets the feature set names in the order they are to be drawn.
251  /// \param libraryID The library to update.
252  /// \param orderedFeatureSetNames The list of names in order from bottom to top. If any feature
253  /// set name is null, empty, or does not exist or if a name is
254  /// missing from the list, a warning is emitted to the console,
255  /// and the function returns false without changing draw order.
256  /// \note Use GetOrderedFeatureSetNames() to get a valid list of feature set names, reorder them
257  /// in place, and pass the result into this function.
258  /// \note This function does NOT take ownership of the strings in the array, though it may already
259  /// have ownership if the array is a reordering of the result of GetOrderedFeatureSetNames().
260  /// \return true if all names were applied.
261  bool SetOrderedFeatureSetNames( LibraryID libraryID, const DynamicArray<const char*>& orderedFeatureSetNames );
262 
263  /// Returns a list of feature types in the given \a featureSetName within the given library.
264  /// \param libraryID The library to query.
265  /// \param featureSet The name of the feature set. If null or not found, this function
266  /// emits an error to the console and returns an empty array.
267  /// \note The caller is NOT responsible to delete/free the pointers in the returned array. They are
268  /// guaranteed valid until LoadLibraryAs() or UnloadLibrary() is called for this library.
269  DynamicArray<const char*> GetFeatureTypes( LibraryID libraryID, const char* featureSet ) const;
270 
271  /////////////////////////////////////////////////////////////////////////////////////////////////////
272  /// Retrieves the current visibility of the features in the given feature set, optionally limited to a single feature type.
273  /// \param libraryID The library to query.
274  /// \param featureSet The name of the feature set (often corresponds to a single .shp file). If null,
275  /// empty, or not found, it emits a warning to the console and returns false.
276  /// \param featureType The name of a type of feature within the feature set (e.g., in a
277  /// "natural" feature set, there might be "water" and "forest" among others).
278  /// If null or empty, it returns the default visibility for the feature set.
279  /// If not found, it emits a warning to the console and returns false.
280  /// \param[out] isVisible Whether the requested features are visible.
281  /// \return true if the feature set and type (if not null/empty) were found. If false, the
282  /// output parameter is unchanged.
283  bool GetFeatureSetVisibility( LibraryID libraryID, const char* featureSet, const char* featureType, bool& isVisible ) const;
284 
285  /// Sets the visibility for features in a feature set.
286  /// \param libraryID The library to update.
287  /// \param featureSet The name of the feature set. If null, sets the visibility for all features sets.
288  /// If non-null and not found, this function emits a warning to the console and
289  /// returns false without changing visibility.
290  /// \param featureType The type of feature within the feature set. If null or empty, it applies
291  /// to the default feature set. If not found, it creates a new feature attribute
292  /// override entry.
293  /// \param isVisible The visibility to be applied.
294  /// \note This can be called multiple times, once with \a featureType == NULL to set the default
295  /// and then with \a featureType != NULL to change specific features.
296  /// \return true if the feature set and was found.
297  bool SetFeatureSetVisibility( LibraryID libraryID, const char* featureSet, const char* featureType, bool isVisible );
298 
299  /////////////////////////////////////////////////////////////////////////////////////////////////////
300  /// Retrieves the current point style of the features in feature set.
301  /// \param libraryID The library to query.
302  /// \param featureSet The name of the feature set (often corresponds to a single .shp file).
303  /// If null or not found, it emits a warning to the console and returns false.
304  /// \param featureType The name of a type of feature within the feature set (e.g., in the
305  /// "natural" feature set, there might be "water" and "forest" among others).
306  /// If null or empty, it returns the default point style for the feature set.
307  /// If not found, it emits a warning to the console and returns false.
308  /// \param[out] color The point color for the requested features.
309  /// \param[out] renderCB render callback else NULL for no callback
310  /// \param[out] userData user supplied data to be handed to callback
311  /// \param[out] useMapScale true if point feature should scale with the map (will become larger as the view zooms in),
312  /// false is point feature should scale to attempt maintain the same size in logical space regardless
313  /// of the map zoom
314  /// \return true if the feature set and type (if not null/empty) were found. If false, the
315  /// output parameters are unchanged.
317  LibraryID libraryID,
318  const char* featureSet,
319  const char* featureType,
320  // Output params:
321  glsColor& color,
322  RenderPointFeatureCB& renderCB,
323  void*& userData,
324  bool& useMapScale ) const;
325 
326  /// Sets the point style (outline for polygon features) for features in a set.
327  /// \param libraryID The library to query.
328  /// \param featureSet The name of the feature set. If null, sets the style for all features sets.
329  /// If non-null and not found, this function emits a warning to the console and
330  /// returns false
331  /// \param featureType The name of the feature. If null or empty, it applies to the default
332  /// attributes for the feature set. If not found, it creates a new feature attribute
333  /// override entry.
334  /// \param color The RGBA color value for points
335  /// \param renderCB render callback else NULL for no callback
336  /// \param userData user supplied data to be handed to callback
337  /// \param useMapScale true if point feature should scale with the map (will become larger as the view zooms in),
338  /// false is point feature should scale to attempt maintain the same size in logical space regardless
339  /// of the map zoom
340  /// \note This can be called multiple times, once with \a featureType == NULL to set the default
341  /// and then with \a featureType != NULL to change specific features.
342  /// \return true if the feature set was found.
344  LibraryID libraryID,
345  const char* featureSet,
346  const char* featureType,
347  const glsColor& color,
348  const RenderPointFeatureCB renderCB = NULL,
349  void* const userData = NULL,
350  const bool useMapScale = NULL );
351 
352  /////////////////////////////////////////////////////////////////////////////////////////////////////
353  /// Retrieves the current line style of the features in feature set.
354  /// \param libraryID The library to query.
355  /// \param featureSet The name of the feature set (often corresponds to a single .shp file).
356  /// If null or not found, it emits a warning to the console and returns false.
357  /// \param featureType The name of a type of feature within the feature set (e.g., in the
358  /// "natural" feature set, there might be "water" and "forest" among others).
359  /// If null or empty, it returns the default line style for the feature set.
360  /// If not found, it emits a warning to the console and returns false.
361  /// \param[out] color The line color for the requested features.
362  /// \param[out] width The line width for the requested features.
363  /// \param[out] stipplePattern The line stipple pattern for the requested features.
364  /// \param[out] stippleMultiplier The line stipple multiplier for the requested features.
365  /// \return true if the feature set and type were found and they were set with the
366  /// corresponding overload of SetFeatureSetLineStyle(); false otherwise.
367  /// (If returning false, the output parameters are unchanged.)
369  LibraryID libraryID,
370  const char* featureSet,
371  const char* featureType,
372  // Output params:
373  glsColor& color,
374  float& width,
375  uint16_t& stipplePattern,
376  int& stippleMultiplier ) const;
377 
378  /////////////////////////////////////////////////////////////////////////////////////////////////////
379  /// Retrieves the current line callback for the feature set.
380  /// \param libraryID The library to query.
381  /// \param featureSet The name of the feature set (often corresponds to a single .shp file).
382  /// If null or not found, it emits a warning to the console and returns false.
383  /// \param featureType The name of a type of feature within the feature set (e.g., in the
384  /// "natural" feature set, there might be "water" and "forest" among others).
385  /// If null or empty, it returns the default line style for the feature set.
386  /// If not found, it emits a warning to the console and returns false.
387  /// \param[out] renderCB The line callback
388  /// \param[out] userData The user data passed to the callback
389  /// \return true if the feature set and type were found and they were set with the
390  /// corresponding overload of SetFeatureSetLineStyle(); false otherwise.
391  /// (If returning false, the output parameters are unchanged.)
393  const LibraryID libraryID,
394  const char* const featureSet,
395  const char* const featureType,
396  // Output params:
397  RenderLineFeatureCB& renderCB,
398  void*& userData ) const;
399 
400  /// Sets the line style (outline for polygon features) for features in a set.
401  /// \param libraryID The library to query.
402  /// \param featureSet The name of the feature set. If null, sets the style for all features sets.
403  /// If non-null and not found, this function emits a warning to the console and
404  /// returns false
405  /// \param featureType The name of the feature. If null or empty, it applies to the default
406  /// attributes for the feature set. If not found, it creates a new feature attribute
407  /// override entry.
408  /// \param color The RGBA color value for lines
409  /// \param width The line width
410  /// \param stipplePattern The stipple pattern for lines (see documentation of glLineStipple())
411  /// \param stippleMultiplier The multiplier for stippling (see documentation of glLineStipple())
412  /// \note There are two overloads of this function -- this one that supplies OpenGL line settings
413  /// and another that supplies a user callback for custom drawing. Calling this function with
414  /// the same \a libraryID, \a featureSet, and \a featureType as a previously configured with
415  /// a callback will discard the callback.
416  /// \return true if the feature set was found.
418  LibraryID libraryID,
419  const char* featureSet,
420  const char* featureType,
421  glsColor color,
422  float width = DEF_LINE_WIDTH,
423  uint16_t stipplePattern = DEF_LINE_STIPPLE_PATTERN,
424  int stippleMultiplier = 0 /* disabled */ );
425 
426  /// Sets the line callback for features in a set.
427  /// \param libraryID The library to query.
428  /// \param featureSet The name of the feature set. If null, sets the style for all features sets.
429  /// If non-null and not found, this function emits a warning to the console and
430  /// returns false
431  /// \param featureType The name of the feature. If null or empty, it applies to the default
432  /// attributes for the feature set. If not found, it creates a new feature attribute
433  /// override entry.
434  /// \param renderCB the line callback
435  /// \param userData The optional user data passed to the callback, can be NULL if unused.
436  /// \note There are two overloads of this function -- this one that supplies OpenGL line settings
437  /// and another that supplies a user callback for custom drawing. Calling this function with
438  /// the same \a libraryID, \a featureSet, and \a featureType as a previously configured with
439  /// OpenGL line settings will discard the OpenGL line settings.
440  /// \return true if the feature set was found. Will return false and have no effect if renderCB is NULL.
442  LibraryID libraryID,
443  const char* featureSet,
444  const char* featureType,
445  const RenderLineFeatureCB renderCB,
446  void* const userData = NULL );
447 
448  /////////////////////////////////////////////////////////////////////////////////////////////////////
449  /// Retrieves the current fill style of the features in feature set.
450  /// \param libraryID The library to query.
451  /// \param featureSet The name of the feature set (often corresponds to a single .shp file).
452  /// If null or not found, it emits a warning to the console and returns false.
453  /// \param featureType The name of a type of feature within the feature set (e.g., in the
454  /// "natural" feature set, there might be "water" and "forest" among others).
455  /// If null or empty, it returns the default visibility for the feature set.
456  /// If not found, it emits a warning to the console and returns false.
457  /// \param[out] color The fill color for the requested features.
458  /// \param[out] drawBoundary Whether or not to draw the area boundary
459  /// \param[out] boundaryColor The boundary color for the requested features.
460  /// \param[out] boundaryWidth The line width
461  /// \param[out] boundaryStipplePattern The stipple pattern for lines (see documentation of glLineStipple())
462  /// \param[out] boundaryStippleMultiplier The multiplier for stippling (see documentation of glLineStipple())
463  /// \return true if the feature set and type (if not null/empty) were found. If false, the
464  /// output parameter is unchanged.
465  bool GetFeatureSetFillStyle( LibraryID libraryID,
466  const char* featureSet,
467  const char* featureType,
468  // Output params:
469  glsColor& color,
470  bool& drawBoundary,
471  glsColor& boundaryColor,
472  float& boundaryWidth,
473  uint16_t& boundaryStipplePattern,
474  int& boundaryStippleMultiplier ) const;
475 
476  /// Sets the fill style for polygon features in the feature set.
477  /// \param libraryID The library to query.
478  /// \param featureSet The name of the feature set. If null, sets the style for all features sets.
479  /// If non-null and not found, this function emits a warning to the console and
480  /// returns false
481  /// \param featureType The name of the feature. If null or empty, it applies to the default
482  /// attributes for the feature set. If not found, it creates a new feature attribute
483  /// override entry.
484  /// \param color The RGBA color value for filling polygons.
485  /// \param boundaryColor The boundary color for the requested features.
486  /// \param drawBoundary Whether or not to draw the area boundary
487  /// \param boundaryWidth The line width
488  /// \param boundaryStipplePattern The stipple pattern for lines (see documentation of glLineStipple())
489  /// \param boundaryStippleMultiplier The multiplier for stippling (see documentation of glLineStipple())
490  /// \note This can be called multiple times, once with \a featureType == NULL to set the default
491  /// and then with \a featureType != NULL to change specific features.
492  /// \return true if the feature set was found.
494  LibraryID libraryID,
495  const char* featureSet,
496  const char* featureType,
497  const glsColor& color,
498  bool drawBoundary = false,
499  const glsColor& boundaryColor = glsColor( 0, 0, 0, 255 ),
500  float boundaryWidth = DEF_LINE_WIDTH,
501  uint16_t boundaryStipplePattern = DEF_LINE_STIPPLE_PATTERN,
502  int boundaryStippleMultiplier = 0 /* disabled */ );
503 
504  /////////////////////////////////////////////////////////////////////////////////////////////////////
505  /// Retrieves the current text style of the features in feature set.
506  /// \param libraryID The library to query.
507  /// \param featureSet The name of the feature set (often corresponds to a single .shp file).
508  /// If null or not found, it emits a warning to the console and returns false.
509  /// \param featureType The name of a type of feature within the feature set (e.g., in the
510  /// "natural" feature set, there might be "water" and "forest" among others).
511  /// If null or empty, it returns the default visibility for the feature set.
512  /// If not found, it emits a warning to the console and returns false.
513  /// \param[out] glsFont The instance of a font in this GL Studio project
514  /// \param[out] textColor The text color for the requested features.
515  /// \param[out] isVisible Whether the text is visible for the requested features.
516  /// \param[out] scale The scale of the text (default = 1.0)
517  /// \param[out] xOffset horizontal offset from the default text location (text starts at the center of its objects extents)
518  /// \param[out] yOffset vertical offset from the default text location (text starts at the center of its objects extents)
519  /// \note This function does not take ownership of the strings passed in.
520  /// \return true if the feature set and type (if not null/empty) were found. If false, the
521  /// output parameters are unchanged.
523  LibraryID libraryID,
524  const char* featureSet,
525  const char* featureType,
526  // Output params:
527  GlsFontBase*& glsFont,
528  glsColor& textColor,
529  double& scale,
530  double& xOffset,
531  double& yOffset,
532  bool& isVisible ) const;
533 
534  /// Sets the text style for a feature set.
535  /// \param libraryID The library to query.
536  /// \param featureSet The name of the feature set. If null, sets the style for all features sets.
537  /// If non-null and not found, this function emits a warning to the console and
538  /// returns false
539  /// \param featureType The name of the feature. If null or empty, it applies to the default
540  /// attributes for the feature set. If not found, it creates a new feature attribute
541  /// override entry.
542  /// \param glsFont The instance of a font in this GL Studio project
543  /// \param textColor Color of the text. (Defaults to black.)
544  /// \param isVisible Whether the text is visible for the requested features.
545  /// \param scale The scale of the text (default = 1.0)
546  /// \param xOffset horizontal offset from the default text location (text starts at the center of its objects extents)
547  /// \param yOffset vertical offset from the default text location (text starts at the center of its objects extents)
548  /// \note This can be called multiple times, once with \a featureType == NULL to set the default
549  /// and then with \a featureType != NULL to change specific features.
550  /// \note This function does not take ownership of the strings passed in.
551  /// \return true if the feature set was found.
553  LibraryID libraryID,
554  const char* featureSet,
555  const char* featureType,
556  GlsFontBase* glsFont,
557  const glsColor& textColor = glsColor( 0, 0, 0, 255 ),
558  double scale = 1.0,
559  double xOffset = 0.0f,
560  double yOffset = 0.0f,
561  bool isVisible = true );
562 
563  ///////////////////////////////////////////////////////////////////////////////////////////////
564  /// Sets the geographical size of the region to cache. Each library has its own cache region.
565  /// \param libraryID The library whose cache size to adjust.
566  /// \param degreesLongitude the width of cache size in degrees of longitude
567  /// \param degreesLatitude the height of cache size in degrees of latitude
568  /// \return true if the library was found.
569  bool SetCacheDimensions( LibraryID libraryID, double degreesLongitude, double degreesLatitude );
570 
571  ///////////////////////////////////////////////////////////////////////////////////////////////
572  // Thread priority control
573  ///////////////////////////////////////////////////////////////////////////////////////////////
574  bool LowerAsyncCellRenderPriority( bool belowNormal );
575 
576  ///////////////////////////////////////////////////////////////////////////////////////////////
577  // Implement base class interface
578  ///////////////////////////////////////////////////////////////////////////////////////////////
579  /// See base class
580  bool GetAvailableCoverage( GeoRect* dest ) DISTI_METHOD_OVERRIDE;
581 
582  /// See base class
583  /// \note: "Layer" here refers to internal resolution level, not Shapefile layer.
584  LayerID GetBestLayer( GlsMapView* view, GlsMapChart* chart ) const DISTI_METHOD_OVERRIDE;
585 
586  /// See base class
587  void GetCellList( const GeoRect& coverage, LayerID layerID, double viewLogicalHeight, double viewGeoHeight, MapChartCellList& viewList ) DISTI_METHOD_OVERRIDE;
588  ///////////////////////////////////////////////////////////////////////////////////////////////
589 
590  /// Attorney-client idiom for exposing rendering details only to those classes that need it.
591  /// \note For internal use only.
593  {
594  // Client list
595  friend class ShapefileMapChartCell;
596 
597  // Services
598  static Shapefile::ScopedLibraryRendererHolder GetLibraryRenderer( const ShapefileMapChartDataSource&, LibraryID );
599  };
600 
601 private:
602  ///////////////////////////////////////////////////////////////////////////////////////////////
603  // Pimpl idiom
604  ///////////////////////////////////////////////////////////////////////////////////////////////
605  class ShapefileMapChartDataSourceImpl;
607 
608  // Disable copying and moving
609  ShapefileMapChartDataSource( const ShapefileMapChartDataSource& ) DISTI_SPECIAL_MEM_FUN_DELETE;
610  void operator=( const ShapefileMapChartDataSource& ) DISTI_SPECIAL_MEM_FUN_DELETE;
611 };
612 /// @}
613 } // end namespace disti
614 
615 #endif // INCLUDED_GLS_MAP_SHAPEFILE_H
GlsColor glsColor
Alias for backwards compatibility.
Definition: gls_color.h:272
bool IsLibraryRenderingEnabled(LibraryID libraryID, bool &isEnabled) 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 GetFeatureSetFillStyle(LibraryID libraryID, const char *featureSet, const char *featureType, glsColor &color, bool &drawBoundary, glsColor &boundaryColor, float &boundaryWidth, uint16_t &boundaryStipplePattern, int &boundaryStippleMultiplier) const
void(* RenderLineFeatureCB)(void *const userData, const char *featureSet, const char *featureType, const DynamicArray< ShapePoint > &points, const GeoRect &region, const double logicalHeight)
Definition: gls_map_shapefile.h:160
Definition: dynamic_array.h:66
Definition: gls_map_chart_data_source.h:210
float y
Definition: gls_map_shapefile.h:147
bool GetFeatureSetVisibility(LibraryID libraryID, const char *featureSet, const char *featureType, bool &isVisible) const
bool GetFeatureSetPointStyle(LibraryID libraryID, const char *featureSet, const char *featureType, glsColor &color, RenderPointFeatureCB &renderCB, void *&userData, bool &useMapScale) const
Definition: gls_map_util.h:414
bool SetOrderedFeatureSetNames(LibraryID libraryID, const DynamicArray< const char * > &orderedFeatureSetNames)
bool GetFeatureSetTextStyle(LibraryID libraryID, const char *featureSet, const char *featureType, GlsFontBase *&glsFont, glsColor &textColor, double &scale, double &xOffset, double &yOffset, bool &isVisible) 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)
The GlsMapView is a special group that controls the map view parameters. It contains all of the objec...
Definition: gls_map_view.h:86
LayerID GetBestLayer(GlsMapView *view, GlsMapChart *chart) const DISTI_METHOD_OVERRIDE
bool SetCacheDimensions(LibraryID libraryID, double degreesLongitude, double degreesLatitude)
Map chart data source for loading Shapefiles.
Definition: gls_map_shapefile.h:100
A file for all GL Studio files to include.
void(* RenderPointFeatureCB)(void *const userData, const char *featureSet, const char *featureType, double longitude, double latitude, const glsColor &color, const GeoRect &region, const double logicalHeight)
Definition: gls_map_shapefile.h:120
Utilities for the shapefile data source for GlsMapToolkit.
bool GetAvailableCoverage(GeoRect *dest) DISTI_METHOD_OVERRIDE
See base class.
bool GetFeatureSetLineStyle(LibraryID libraryID, const char *featureSet, const char *featureType, glsColor &color, float &width, uint16_t &stipplePattern, int &stippleMultiplier) const
Cartesian coordinate used by the points that define the paths loaded from shapefiles.
Definition: gls_map_shapefile.h:132
~ShapefileMapChartDataSource()
Destructor - stops rendering and releases all libraries.
The disti::GlsMapChartDataSource class.
bool SetFeatureSetVisibility(LibraryID libraryID, const char *featureSet, const char *featureType, bool isVisible)
DynamicArray< const char * > GetOrderedFeatureSetNames(LibraryID libraryID) 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 EnableLibraryRendering(LibraryID libraryID, bool enable=true)
bool LoadLibraryAs(const char *shapefileRootPath, LibraryID libraryID)
void GetCellList(const GeoRect &coverage, LayerID layerID, double viewLogicalHeight, double viewGeoHeight, MapChartCellList &viewList) DISTI_METHOD_OVERRIDE
See base class.
Definition: gls_color.h:53
float x
Definition: gls_map_shapefile.h:146
The gls_auto_lib.
DynamicArray< const char * > GetFeatureTypes(LibraryID libraryID, const char *featureSet) 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)
A smart pointer with unique ownership – poor man's std::unique_ptr.
Definition: gls_map_chart.h:70
Definition: bmpimage.h:46
bool UnloadLibrary(LibraryID libraryID)
ShapefileMapChartDataSource()
Constructor.
DynamicArray< LibraryID > GetLoadedLibraries() const
Definition: gls_font_base.h:85