Skip to content

AcresRegionCropData.h#

Acres/Source/Acres/AcresRegionCropData.h Generated

FRegionCropRun#

struct FRegionCropRun

One run of adjacent crop patches on a lattice row: columns [Begin, End) of row Row, all in field Field.

FRegionCropChunk#

struct FRegionCropChunk

The runs of one ground chunk (Col, Row: first survey cell, as FRegionStreamingChunk).

FRegionCropData#

class FRegionCropData

Baked occupancy of the standing crops outside the original tile (DriveRegion/crops.bin, written by Tools/ACRE/Map/regional_crops.py). Engine-free; immutable after Load and Bind, so workers can read it.

Coordinates are world metres, X east, Y south. Patch (I, J) of the one global lattice has its centre at ((I + 0.5) * PitchX, (J + 0.5) * PitchY) and the footprint PitchX x PitchY (1.52 m x 1.0 m, a tile patch). A patch belongs to the ground chunk that holds its centre. The data holds no crush, harvest or growth state.

Each patch has a stable ordinal: its position in the file. The runs are in file order and the patches of a run are in column order, so the ordinal of patch I of a run is the number of patches in all earlier runs plus I - Begin. Per-patch state (the crushed samples) is kept by its user, sparsely, under this ordinal.

FRegionCropData::Load#

Parse and check crops.bin. A failed load leaves the object unchanged.

bool Load(const std::vector<unsigned char>& Bytes, std::string* Error = nullptr);

FRegionCropData::Bind#

Check that the chunk table is the streaming policy's chunk list, in its order, and that every patch centre lies in its chunk. Keeps the chunk rectangles for ForEachNear and the chunk grid for ChunkAt and ForEachInBox.

bool Bind(const std::vector<FRegionStreamingChunk>& Chunks, std::string* Error = nullptr);

FRegionCropData::FieldKinds#

Crop kind (AcresCrops: 0 corn, 1 soybean) of each field index.

const std::vector<uint8_t>& FieldKinds() const ;

FRegionCropData::RunFirstOrdinals#

Ordinal of the first patch of each run (see the class comment), in run order.

const std::vector<uint32_t>& RunFirstOrdinals() const ;

FRegionCropData::PatchAt#

The patch of an ordinal: its lattice position and field index. False for an ordinal the file does not have.

bool PatchAt(uint32_t Ordinal, int& OutI, int& OutJ, uint32_t& OutField) const;

FRegionCropData::ChunkAt#

Index of the chunk that holds a point, from the chunk grid in constant time. -1: no chunk there (the original tile, outside the region) or not bound.

int ChunkAt(double X, double Y) const ;

FRegionCropData::SourceSha1#

SHA-1 of the region.bin the bake used, upper-case hex (the identity ground_assets.json also carries).

const std::string& SourceSha1() const ;

FRegionCropData::PatchHash#

Position hash of a patch (SplitMix64 finaliser), for the choice of a mesh sample. The same patch gets the same value in every run and on every revisit.

static uint64_t PatchHash(int I, int J);

FRegionCropData::Mix#

One step of an order-dependent 64-bit digest (rotate, xor, multiply), for the expanded instances of a chunk.

static uint64_t Mix(uint64_t Hash, uint64_t Value);

FRegionCropData::ForEachInChunk#

Visit(I, J, Kind) for every patch of a chunk, in row then column order.

template <typename F> void ForEachInChunk(size_t Chunk, F&& Visit) const ;

FRegionCropData::ForEachNear#

Visit(I, J, Kind) for every patch whose centre is within RadiusM of (X, Y). Needs Bind.

template <typename F> void ForEachNear(double X, double Y, double RadiusM, F&& Visit) const ;

FRegionCropData::ForEachInBox#

Visit(Ordinal, I, J, Field) for every patch with I0 <= I <= I1 and J0 <= J <= J1 (Field: the field index of its run). Only the chunks the box touches are read, each with one search for its first row. Needs Bind.

template <typename F> void ForEachInBox(int I0, int J0, int I1, int J1, F&& Visit) const ;