]> Pileus Git - grits/blob - src/gis/wms.h
Lots of work on libGIS
[grits] / src / gis / wms.h
1 /*
2  * Copyright (C) 2009 Andy Spencer <spenceal@rose-hulman.edu>
3  * 
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 #ifndef __WMS_H__
19 #define __WMS_H__
20
21 #include <math.h>
22 #include <time.h>
23 #include <libsoup/soup.h>
24
25 typedef struct _WmsCacheNode WmsCacheNode;
26 typedef struct _WmsInfo WmsInfo;
27
28 typedef void (*WmsChunkCallback)(gsize cur, gsize total, gpointer user_data);
29 typedef void (*WmsDoneCallback)(WmsCacheNode *node, gpointer user_data);
30 typedef void (*WmsLoader)(WmsCacheNode *node, const gchar *path, gint width, gint height);
31 typedef void (*WmsFreeer)(WmsCacheNode *node);
32
33 /****************
34  * WmsCacheNode *
35  ****************/
36 struct _WmsCacheNode {
37         gpointer data;
38         gdouble latlon[4]; // xmin,ymin,xmax,ymax
39         gboolean caching;
40         time_t atime;
41         WmsCacheNode *children[4][4];
42 };
43
44 WmsCacheNode *wms_cache_node_new(gdouble xmin, gdouble ymin, gdouble xmax, gdouble ymax);
45
46 void wms_cache_node_free(WmsCacheNode *node, WmsFreeer freeer);
47
48 /***********
49  * WmsInfo *
50  ***********/
51 struct _WmsInfo {
52         WmsLoader loader;
53         WmsFreeer freeer;
54         gchar *uri_prefix;
55         gchar *uri_layer;
56         gchar *uri_format;
57         gchar *cache_prefix;
58         gchar *cache_ext;
59         gint   resolution;  // m/px
60         gint   width;
61         gint   height;
62
63         guint  max_age;
64         guint  gc_source;
65         time_t atime;
66         WmsCacheNode *cache_root;
67         SoupSession *soup;
68 };
69
70 WmsInfo *wms_info_new(WmsLoader loader, WmsFreeer freeer,
71                 gchar *uri_prefix, gchar *uri_layer, gchar *uri_format,
72                 gchar *cache_prefix, gchar *cache_ext,
73                 gint   resolution, gint   width, gint   height);
74
75 void wms_info_cache(WmsInfo *info, gdouble resolution, gdouble lat, gdouble lon,
76                 WmsChunkCallback chunk_callback, WmsDoneCallback done_callback,
77                 gpointer user_data);
78
79 WmsCacheNode *wms_info_fetch(WmsInfo *info, gdouble resolution, gdouble lat, gdouble lon,
80                 gboolean *correct);
81
82 WmsCacheNode *wms_info_fetch_cache(WmsInfo *info, gdouble resolution, gdouble lat, gdouble lon,
83                 WmsChunkCallback chunk_callback, WmsDoneCallback done_callback,
84                 gpointer user_data);
85
86 gboolean wms_info_gc(WmsInfo *self);
87
88 void wms_info_free(WmsInfo *info);
89
90
91 /********************************
92  * Specific things (bmng, srtm) *
93  ********************************/
94 typedef struct _WmsBil WmsBil;
95 struct _WmsBil {
96         gint16 *data;
97         gint width;
98         gint height;
99 };
100
101 void bmng_opengl_loader(WmsCacheNode *node, const gchar *path, gint width, gint height);
102 void bmng_opengl_freeer(WmsCacheNode *node);
103
104 void bmng_pixbuf_loader(WmsCacheNode *node, const gchar *path, gint width, gint height);
105 void bmng_pixbuf_freeer(WmsCacheNode *node);
106
107 WmsInfo *wms_info_new_for_bmng(WmsLoader loader, WmsFreeer freeer);
108
109 void srtm_bil_loader(WmsCacheNode *node, const gchar *path, gint width, gint height);
110 void srtm_bil_freeer(WmsCacheNode *node);
111
112 void srtm_pixbuf_loader(WmsCacheNode *node, const gchar *path, gint width, gint height);
113 void srtm_pixbuf_freeer(WmsCacheNode *node);
114
115 WmsInfo *wms_info_new_for_srtm(WmsLoader loader, WmsFreeer freeer);
116
117 #endif