Geodot Plugin
Loading...
Searching...
No Matches
geodata.h
1#ifndef __GEODATA_H__
2#define __GEODATA_H__
3
4#include "RasterTileExtractor.h"
5#include "VectorExtractor.h"
6#include "defines.h"
7#include "geofeatures.h"
8#include "geoimage.h"
9#include "godot_cpp/variant/dictionary.hpp"
10#include "godot_cpp/variant/variant.hpp"
11
12namespace godot {
13
14// Forward decaration
15class EXPORT GeoDataset;
16
22class EXPORT GeoFeatureLayer : public Resource {
23 GDCLASS(GeoFeatureLayer, Resource)
24
25 protected:
26 static void _bind_methods();
27
28 public:
29 GeoFeatureLayer() = default;
30 ~GeoFeatureLayer() = default; // No need to delete anything here - OGRLayers are part of
31 // the dataset and deleted with it.
32
34 bool is_valid();
35
39 Dictionary get_file_info();
40
42 Ref<GeoDataset> get_dataset();
43
45 int get_epsg_code();
46
49 Vector3 get_center();
50
52 Ref<GeoFeature> get_feature_by_id(int id);
53
55 Array get_all_features();
56
59 Ref<GeoFeature> create_feature();
60
63 void remove_feature(Ref<GeoFeature> feature);
64
67 void clear_cache();
68
71 void save_override();
72
75 void save_new(String file_path);
76
79 Array get_features_near_position(double pos_x, double pos_y, double radius, int max_features);
80
82 Array get_features_in_square(double top_left_x, double top_left_y, double size_meters,
83 int max_features);
84
86 Array get_attribute_names();
87
89 bool has_attribute(String attribute_name);
90
93 Array get_features_by_attribute_filter(String filter);
94
96 Ref<GeoFeature> get_specialized_feature(std::shared_ptr<Feature> raw_feature);
97
101 void set_native_layer(std::shared_ptr<NativeLayer> new_layer);
102
105 void set_origin_dataset(Ref<GeoDataset> dataset);
106
107 String name;
108
109 private:
110 std::shared_ptr<NativeLayer> layer;
111 std::map<std::shared_ptr<Feature>, Ref<GeoFeature>> feature_cache;
112 Ref<GeoDataset> origin_dataset;
113 ExtentData extent_data;
114};
115
120class EXPORT GeoRasterLayer : public Resource {
121 GDCLASS(GeoRasterLayer, Resource)
122
123 protected:
124 static void _bind_methods();
125
126 public:
127 GeoRasterLayer() : origin_dataset(nullptr) {}
128 ~GeoRasterLayer() = default;
129
131 bool is_valid();
132
134 bool has_write_access();
135
140 Dictionary get_file_info();
141
143 int get_epsg_code();
144
146 Image::Format get_format();
147
151 int get_band_count();
152
154 Array get_band_descriptions();
155
158 Ref<GeoDataset> get_dataset();
159
163 Ref<GeoRasterLayer> clone();
164
168 Ref<GeoImage> get_image(double top_left_x, double top_left_y, double size_meters, int img_size,
169 GeoImage::INTERPOLATION interpolation_type);
170
173 Ref<GeoImage> get_band_image(double top_left_x, double top_left_y, double size_meters, int img_size,
174 GeoImage::INTERPOLATION interpolation_type, int band_index);
175
179 float get_value_at_position(double pos_x, double pos_y);
180
185 float get_value_at_position_with_resolution(double pos_x, double pos_y,
186 double pixel_size_meters);
187
192 void set_value_at_position(double pos_x, double pos_y, Variant value);
193
197 void smooth_add_value_at_position(double pos_x, double pos_y, double summand, double radius);
198
204 void overlay_image_at_position(double pos_x, double pos_y, Ref<Image> image, double scale);
205
207 Rect2 get_extent();
208
211 Vector3 get_center();
212
215 float get_min();
216
219 float get_max();
220
222 float get_pixel_size();
223
225 void load_from_file(String file_path, bool write_access);
226
230 void set_native_dataset(std::shared_ptr<NativeDataset> new_dataset);
231
234 void set_origin_dataset(Ref<GeoDataset> dataset);
235
236 bool write_access;
237
238 String name;
239
240 private:
241 Ref<GeoDataset> origin_dataset;
242 std::shared_ptr<NativeDataset> dataset;
243 ExtentData extent_data;
244};
245
248class EXPORT GeoDataset : public Resource {
249 GDCLASS(GeoDataset, Resource)
250
251 protected:
252 static void _bind_methods();
253
254 public:
255 GeoDataset() = default;
256 ~GeoDataset();
257
259 bool is_valid();
260
262 Dictionary get_file_info();
263
265 bool has_write_access();
266
268 Array get_raster_layers();
269
271 Array get_feature_layers();
272
276 Ref<GeoRasterLayer> get_raster_layer(String name);
277
281 Ref<GeoFeatureLayer> get_feature_layer(String name);
282
286 Ref<GeoFeatureLayer> get_sql_feature_layer(String query);
287
290 void load_from_file(String file_path, bool write_access);
291
295 void set_native_dataset(std::shared_ptr<NativeDataset> new_dataset);
296
297 bool write_access;
298
299 std::shared_ptr<NativeDataset> dataset;
300
301 String name;
302};
303
304} // namespace godot
305
306#endif // __GEODATA_H__
Definition: geodata.h:248
Definition: geodata.h:22
Definition: geodata.h:120
Definition: util.h:3