18#include <geos/export.h>
19#include <geos/geom/Geometry.h>
36class GEOS_DLL HilbertEncoder {
40 HilbertEncoder(uint32_t p_level, geom::Envelope& extent);
41 uint32_t encode(
const geom::Envelope* env);
42 static void sort(std::vector<geom::Geometry*>& geoms);
45 static geom::Envelope getEnvelope(T begin, T end) {
46 geom::Envelope extent;
47 for (
auto it = begin; it != end; ++it) {
50 extent = *(g->getEnvelopeInternal());
52 extent.expandToInclude(*(g->getEnvelopeInternal()));
59 static void sort(T begin, T end) {
60 auto extent = getEnvelope(begin, end);
61 HilbertEncoder encoder(12, extent);
62 HilbertComparator hilbertCompare(encoder);
63 std::sort(begin, end, hilbertCompare);
74 struct HilbertComparator {
78 HilbertComparator(HilbertEncoder& e)
82 operator()(
const geom::Geometry* a,
const geom::Geometry* b)
84 return enc.encode(a->getEnvelopeInternal()) > enc.encode(b->getEnvelopeInternal());
Basic namespace for all GEOS functionalities.
Definition geos.h:39