1 /******************************************************************************
2 * $Id$
3 *
4 * Project: MapServer
5 * Purpose: MapCache tile caching support file: Mapserver Mapfile datasource
6 * Author: Thomas Bonfort and the MapServer team.
7 *
8 ******************************************************************************
9 * Copyright (c) 1996-2011 Regents of the University of Minnesota.
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included in
19 * all copies of this Software or works derived from this Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 * DEALINGS IN THE SOFTWARE.
28 *****************************************************************************/
29
30
31 #include "mapcache.h"
32 #include "ezxml.h"
33 #include <apr_tables.h>
34 #include <apr_strings.h>
35
36 typedef struct mapcache_source_dummy mapcache_source_dummy;
37 struct mapcache_source_dummy {
38 mapcache_source source;
39 char *mapfile;
40 void *mapobj;
41 };
42
43 /**
44 * \private \memberof mapcache_source_dummy
45 * \sa mapcache_source::render_map()
46 */
_mapcache_source_dummy_render_map(mapcache_context * ctx,mapcache_source * psource,mapcache_map * map)47 void _mapcache_source_dummy_render_map(mapcache_context *ctx, mapcache_source *psource, mapcache_map *map)
48 {
49 map->raw_image = mapcache_image_create(ctx);
50 map->raw_image->w = map->width;
51 map->raw_image->h = map->height;
52 map->raw_image->stride = 4 * map->width;
53 map->raw_image->data = malloc(map->width*map->height*4);
54 memset(map->raw_image->data,255,map->width*map->height*4);
55 apr_pool_cleanup_register(ctx->pool, map->raw_image->data,(void*)free, apr_pool_cleanup_null);
56 }
57
_mapcache_source_dummy_query(mapcache_context * ctx,mapcache_source * psource,mapcache_feature_info * fi)58 void _mapcache_source_dummy_query(mapcache_context *ctx, mapcache_source *psource, mapcache_feature_info *fi)
59 {
60 ctx->set_error(ctx,500,"dummy source does not support queries");
61 }
62
63 /**
64 * \private \memberof mapcache_source_dummy
65 * \sa mapcache_source::configuration_parse()
66 */
_mapcache_source_dummy_configuration_parse_xml(mapcache_context * ctx,ezxml_t node,mapcache_source * source,mapcache_cfg * config)67 void _mapcache_source_dummy_configuration_parse_xml(mapcache_context *ctx, ezxml_t node, mapcache_source *source, mapcache_cfg *config)
68 {
69 }
70
71 /**
72 * \private \memberof mapcache_source_dummy
73 * \sa mapcache_source::configuration_check()
74 */
_mapcache_source_dummy_configuration_check(mapcache_context * ctx,mapcache_cfg * cfg,mapcache_source * source)75 void _mapcache_source_dummy_configuration_check(mapcache_context *ctx, mapcache_cfg *cfg,
76 mapcache_source *source)
77 {
78 }
79
mapcache_source_dummy_create(mapcache_context * ctx)80 mapcache_source* mapcache_source_dummy_create(mapcache_context *ctx)
81 {
82 mapcache_source_dummy *source = apr_pcalloc(ctx->pool, sizeof(mapcache_source_dummy));
83 if(!source) {
84 ctx->set_error(ctx, 500, "failed to allocate dummy source");
85 return NULL;
86 }
87 mapcache_source_init(ctx, &(source->source));
88 source->source.type = MAPCACHE_SOURCE_DUMMY;
89 source->source._render_map = _mapcache_source_dummy_render_map;
90 source->source.configuration_check = _mapcache_source_dummy_configuration_check;
91 source->source.configuration_parse_xml = _mapcache_source_dummy_configuration_parse_xml;
92 source->source._query_info = _mapcache_source_dummy_query;
93 return (mapcache_source*)source;
94 }
95
96
97 /* vim: ts=2 sts=2 et sw=2
98 */
99