@@ -105,6 +105,8 @@ typedef struct mapcache_image mapcache_image;
105105typedef struct mapcache_grid mapcache_grid ;
106106typedef struct mapcache_grid_level mapcache_grid_level ;
107107typedef struct mapcache_grid_link mapcache_grid_link ;
108+ typedef struct mapcache_rule mapcache_rule ;
109+ typedef struct mapcache_ruleset mapcache_ruleset ;
108110typedef struct mapcache_context mapcache_context ;
109111typedef struct mapcache_dimension mapcache_dimension ;
110112typedef struct mapcache_requested_dimension mapcache_requested_dimension ;
@@ -839,6 +841,11 @@ struct mapcache_cfg {
839841 */
840842 apr_hash_t * grids ;
841843
844+ /**
845+ * hashtable containing (pre)defined rulesets
846+ */
847+ apr_hash_t * rulesets ;
848+
842849 /**
843850 * the format to use for some miscelaneaous operations:
844851 * - creating an empty image
@@ -899,9 +906,11 @@ MS_DLL_EXPORT mapcache_cache* mapcache_configuration_get_cache(mapcache_cfg *con
899906mapcache_grid * mapcache_configuration_get_grid (mapcache_cfg * config , const char * key );
900907MS_DLL_EXPORT mapcache_tileset * mapcache_configuration_get_tileset (mapcache_cfg * config , const char * key );
901908mapcache_image_format * mapcache_configuration_get_image_format (mapcache_cfg * config , const char * key );
909+ mapcache_ruleset * mapcache_configuration_get_ruleset (mapcache_cfg * config , const char * key );
902910void mapcache_configuration_add_image_format (mapcache_cfg * config , mapcache_image_format * format , const char * key );
903911void mapcache_configuration_add_source (mapcache_cfg * config , mapcache_source * source , const char * key );
904912void mapcache_configuration_add_grid (mapcache_cfg * config , mapcache_grid * grid , const char * key );
913+ void mapcache_configuration_add_ruleset (mapcache_cfg * config , mapcache_ruleset * ruleset , const char * key );
905914void mapcache_configuration_add_tileset (mapcache_cfg * config , mapcache_tileset * tileset , const char * key );
906915void mapcache_configuration_add_cache (mapcache_cfg * config , mapcache_cache * cache , const char * key );
907916
@@ -1063,6 +1072,12 @@ struct mapcache_grid_link {
10631072 mapcache_extent_i * grid_limits ;
10641073 int minz ,maxz ;
10651074
1075+ /**
1076+ * rules (mapcache_rule) for each zoom level
1077+ * index in array = zoom level
1078+ */
1079+ apr_array_header_t * rules ;
1080+
10661081 /**
10671082 * tiles above this zoom level will not be stored to the cache, but will be
10681083 * dynamically generated (either by reconstructing from lower level tiles, or
@@ -1075,6 +1090,46 @@ struct mapcache_grid_link {
10751090 apr_array_header_t * intermediate_grids ;
10761091};
10771092
1093+ /**\class mapcache_rule
1094+ * \brief a zoom level rule
1095+ */
1096+ struct mapcache_rule {
1097+ /**
1098+ * rule for zoom level
1099+ */
1100+ int zoom_level ;
1101+ /**
1102+ * color of tiles when outside visible extent, ARGB
1103+ */
1104+ unsigned int hidden_color ;
1105+ /**
1106+ * tile to return when outside visible extent
1107+ */
1108+ mapcache_buffer * hidden_tile ;
1109+ /**
1110+ * visible extents, array of mapcache_extent
1111+ */
1112+ apr_array_header_t * visible_extents ;
1113+ /**
1114+ * visible limits, array of mapcache_extent_i
1115+ */
1116+ apr_array_header_t * visible_limits ;
1117+ };
1118+
1119+ /**\class mapcache_ruleset
1120+ * \brief a set of rules
1121+ */
1122+ struct mapcache_ruleset {
1123+ /**
1124+ * the name of this ruleset
1125+ */
1126+ char * name ;
1127+ /**
1128+ * rules (mapcache_rule)
1129+ */
1130+ apr_array_header_t * rules ;
1131+ };
1132+
10781133/**\class mapcache_tileset
10791134 * \brief a set of tiles that can be requested by a client, created from a mapcache_source
10801135 * stored by a mapcache_cache in a mapcache_format
@@ -1291,6 +1346,49 @@ MS_DLL_EXPORT mapcache_http_response* mapcache_core_proxy_request(mapcache_conte
12911346MS_DLL_EXPORT mapcache_http_response * mapcache_core_respond_to_error (mapcache_context * ctx );
12921347
12931348
1349+ /* in ruleset.c */
1350+
1351+ /**
1352+ * \brief allocate and initialize a new ruleset
1353+ * @param pool
1354+ */
1355+ mapcache_ruleset * mapcache_ruleset_create (apr_pool_t * pool );
1356+
1357+ /**
1358+ * \brief allocate and initialize a new rule
1359+ * @param pool
1360+ */
1361+ mapcache_rule * mapcache_ruleset_rule_create (apr_pool_t * pool );
1362+
1363+ /**
1364+ * \brief clone a rule
1365+ * @param pool
1366+ * @param rule
1367+ */
1368+ mapcache_rule * mapcache_ruleset_rule_clone (apr_pool_t * pool , mapcache_rule * rule );
1369+
1370+ /**
1371+ * \brief get rule for zoom level, or NULL if none exist
1372+ * @param ruleset
1373+ * @param zoom_level
1374+ */
1375+ mapcache_rule * mapcache_ruleset_rule_find (apr_array_header_t * rules , int zoom_level );
1376+
1377+ /**
1378+ * \brief get rule at index, or NULL if none exist
1379+ * @param rules
1380+ * @param idx
1381+ */
1382+ mapcache_rule * mapcache_ruleset_rule_get (apr_array_header_t * rules , int idx );
1383+
1384+ /**
1385+ * \brief check if tile is within visible extent
1386+ * @param rule
1387+ * @param tile
1388+ */
1389+ int mapcache_ruleset_is_visible_tile (mapcache_rule * rule , mapcache_tile * tile );
1390+
1391+
12941392/* in grid.c */
12951393mapcache_grid * mapcache_grid_create (apr_pool_t * pool );
12961394
@@ -1333,6 +1431,7 @@ int mapcache_grid_get_level(mapcache_context *ctx, mapcache_grid *grid, double *
13331431 * \param tolerance the number of tiles around the given extent that can be requested without returning an error.
13341432 */
13351433MS_DLL_EXPORT void mapcache_grid_compute_limits (const mapcache_grid * grid , const mapcache_extent * extent , mapcache_extent_i * limits , int tolerance );
1434+ void mapcache_grid_compute_limits_at_level (const mapcache_grid * grid , const mapcache_extent * extent , mapcache_extent_i * limits_ptr , int tolerance , int zoom_level );
13361435
13371436/* in util.c */
13381437MS_DLL_EXPORT int mapcache_util_extract_int_list (mapcache_context * ctx , const char * args , const char * sep , int * * numbers ,
0 commit comments