Geodot Plugin
Loading...
Searching...
No Matches
NativeLayer.h
1#include "Feature.h"
2#include "LineFeature.h"
3#include "gdal-includes.h"
4#include "util.h"
5#include <list>
6#include <mutex>
7
9 public:
10 NativeLayer(OGRLayer *new_layer);
11
12 ~NativeLayer() = default;
13
14 bool is_valid() const;
15
16 void write_feature_cache_to_ram_layer();
17
18 void save_override();
19
20 void save_modified_layer(std::string path);
21
22 ExtentData get_extent();
23
27 std::shared_ptr<Feature> create_feature();
28
29 void add_field(std::string name);
30
31 void remove_field(std::string name);
32
33 bool field_exists(std::string name);
34
35 std::list<std::string> get_field_names();
36
37 // TODO: Add something like `forget_feature(Feature)` so that the cache can be cleared (and the
38 // memory freed) by the user
39
43 std::list<std::shared_ptr<Feature> > get_features();
44
50 std::list<std::shared_ptr<Feature> > get_features_near_position(double pos_x, double pos_y, double radius,
51 int max_amount);
52
58 std::list<std::shared_ptr<Feature> > get_features_in_square(double top_left_x,
59 double top_left_y, double size_meters,
60 int max_amount);
61
66 std::list<std::shared_ptr<Feature> > get_feature_for_ogrfeature(OGRFeature *feature);
67
69 std::list<std::shared_ptr<Feature> > get_feature_by_id(int id);
70
72 std::list<std::shared_ptr<Feature> > get_features_by_attribute_filter(std::string filter);
73
77
78 bool is_feature_deleted(OGRFeature *feature);
79
80 OGRLayer *layer;
81 OGRLayer *ram_layer;
82
91 std::map<GUIntBig, std::list<std::shared_ptr<Feature> >> feature_cache;
92
93 int disk_feature_count;
94 int ram_feature_count;
95
96 private:
97 std::list<std::shared_ptr<Feature> > get_features_inside_geometry(OGRGeometry *geometry, int max_amount);
98
99 std::mutex layer_mutex;
100};
Definition: NativeLayer.h:8
std::list< std::shared_ptr< Feature > > get_features_near_position(double pos_x, double pos_y, double radius, int max_amount)
Definition: NativeLayer.cpp:459
std::list< std::shared_ptr< Feature > > get_features_in_square(double top_left_x, double top_left_y, double size_meters, int max_amount)
Definition: NativeLayer.cpp:473
std::list< std::shared_ptr< Feature > > get_features()
Definition: NativeLayer.cpp:370
std::shared_ptr< Feature > create_feature()
Definition: NativeLayer.cpp:147
void clear_feature_cache()
Definition: NativeLayer.cpp:309
std::list< std::shared_ptr< Feature > > get_feature_by_id(int id)
Returns the feature corresponding to the given ID.
Definition: NativeLayer.cpp:318
std::map< GUIntBig, std::list< std::shared_ptr< Feature > > > feature_cache
Definition: NativeLayer.h:91
std::list< std::shared_ptr< Feature > > get_features_by_attribute_filter(std::string filter)
Filter the features of the layer by a given SQL-like query, e.g. "attributename < 1000".
Definition: NativeLayer.cpp:329
std::list< std::shared_ptr< Feature > > get_feature_for_ogrfeature(OGRFeature *feature)
Definition: NativeLayer.cpp:216
Definition: util.h:3