aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/reverse_geocoder/core/part.h
blob: 9b24fee96f7765ebe4b1511916e2f2b7886480e2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#pragma once

#include "common.h"
#include "edge.h"
#include "point.h"

namespace NReverseGeocoder {
    // TPart contains version of persistent scanline. Parts lying in geofraphical data parts array,
    // ordered by Coordinate for each polygon. Variable EdgeRefsOffset refers on EdgeRefs array for
    // this part. For optimal usage of memory, part does not contain "EdgeRefsNumber" variable, because
    // it's can be computed as parts[i + 1].EdgeRefsOffset - parts[i].EdgeRefsOffset for every part
    // in geographical data. Especially for this, added fake part into IGeoData with correct
    // EdgeRefsOffset. Refs in EdgeRefs are in increasing order for each part. It is necessary to
    // quickly determine how many edges is under the point. See generator/ for details.
    struct Y_PACKED TPart {
        TCoordinate Coordinate;
        TNumber EdgeRefsOffset;

        // Checks point lying under odd numbers of edges or on edge.
        bool Contains(const TPoint& point, TNumber edgeRefsNumber, const TRef* edgeRefs,
                      const TEdge* edges, const TPoint* points) const;
    };

    static_assert(sizeof(TPart) == 8, "NReverseGeocoder::TPart size mismatch");

}