~ubuntu-branches/ubuntu/trusty/mapcache/trusty

« back to all changes in this revision

Viewing changes to lib/source_dummy.c

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2013-09-11 19:16:06 UTC
  • Revision ID: package-import@ubuntu.com-20130911191606-9aydo919w4dgjx9v
Tags: upstream-1.2.0
ImportĀ upstreamĀ versionĀ 1.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
/**
 
37
 * \private \memberof mapcache_source_dummy
 
38
 * \sa mapcache_source::render_map()
 
39
 */
 
40
void _mapcache_source_dummy_render_map(mapcache_context *ctx, mapcache_map *map)
 
41
{
 
42
  map->raw_image = mapcache_image_create(ctx);
 
43
  map->raw_image->w = map->width;
 
44
  map->raw_image->h = map->height;
 
45
  map->raw_image->stride = 4 * map->width;
 
46
  map->raw_image->data = malloc(map->width*map->height*4);
 
47
  memset(map->raw_image->data,255,map->width*map->height*4);
 
48
  apr_pool_cleanup_register(ctx->pool, map->raw_image->data,(void*)free, apr_pool_cleanup_null);
 
49
}
 
50
 
 
51
void _mapcache_source_dummy_query(mapcache_context *ctx, mapcache_feature_info *fi)
 
52
{
 
53
  ctx->set_error(ctx,500,"dummy source does not support queries");
 
54
}
 
55
 
 
56
/**
 
57
 * \private \memberof mapcache_source_dummy
 
58
 * \sa mapcache_source::configuration_parse()
 
59
 */
 
60
void _mapcache_source_dummy_configuration_parse_xml(mapcache_context *ctx, ezxml_t node, mapcache_source *source)
 
61
{
 
62
}
 
63
 
 
64
/**
 
65
 * \private \memberof mapcache_source_dummy
 
66
 * \sa mapcache_source::configuration_check()
 
67
 */
 
68
void _mapcache_source_dummy_configuration_check(mapcache_context *ctx, mapcache_cfg *cfg,
 
69
    mapcache_source *source)
 
70
{
 
71
}
 
72
 
 
73
mapcache_source* mapcache_source_dummy_create(mapcache_context *ctx)
 
74
{
 
75
  mapcache_source_dummy *source = apr_pcalloc(ctx->pool, sizeof(mapcache_source_dummy));
 
76
  if(!source) {
 
77
    ctx->set_error(ctx, 500, "failed to allocate dummy source");
 
78
    return NULL;
 
79
  }
 
80
  mapcache_source_init(ctx, &(source->source));
 
81
  source->source.type = MAPCACHE_SOURCE_DUMMY;
 
82
  source->source.render_map = _mapcache_source_dummy_render_map;
 
83
  source->source.configuration_check = _mapcache_source_dummy_configuration_check;
 
84
  source->source.configuration_parse_xml = _mapcache_source_dummy_configuration_parse_xml;
 
85
  source->source.query_info = _mapcache_source_dummy_query;
 
86
  return (mapcache_source*)source;
 
87
}
 
88
 
 
89
 
 
90
/* vim: ts=2 sts=2 et sw=2
 
91
*/