'use strict'; // code generated by pbf v3.2.1

// Index ========================================

var Index = exports.Index = {};

Index.read = function (pbf, end) {
    return pbf.readFields(Index._readField, {header_size: 0, num_features: 0, offsets: [], fids: [], idxs: [], packed_rtree: null}, end);
};
Index._readField = function (tag, obj, pbf) {
    if (tag === 1) obj.header_size = pbf.readVarint();
    else if (tag === 2) obj.num_features = pbf.readVarint();
    else if (tag === 3) pbf.readPackedVarint(obj.offsets);
    else if (tag === 4) obj.fids.push(pbf.readString());
    else if (tag === 5) pbf.readPackedVarint(obj.idxs);
    else if (tag === 8) obj.packed_rtree = Index.PackedRTree.read(pbf, pbf.readVarint() + pbf.pos);
};
Index.write = function (obj, pbf) {
    if (obj.header_size) pbf.writeVarintField(1, obj.header_size);
    if (obj.num_features) pbf.writeVarintField(2, obj.num_features);
    if (obj.offsets) pbf.writePackedVarint(3, obj.offsets);
    if (obj.fids) for (var i = 0; i < obj.fids.length; i++) pbf.writeStringField(4, obj.fids[i]);
    if (obj.idxs) pbf.writePackedVarint(5, obj.idxs);
    if (obj.packed_rtree) pbf.writeMessage(8, Index.PackedRTree.write, obj.packed_rtree);
};

// Index.PackedRTree ========================================

Index.PackedRTree = {};

Index.PackedRTree.read = function (pbf, end) {
    return pbf.readFields(Index.PackedRTree._readField, {left: 0, bottom: 0, right: 0, top: 0, num_items: 0, num_nodes: 0, node_size: 0, serialized: null}, end);
};
Index.PackedRTree._readField = function (tag, obj, pbf) {
    if (tag === 1) obj.left = pbf.readDouble();
    else if (tag === 2) obj.bottom = pbf.readDouble();
    else if (tag === 3) obj.right = pbf.readDouble();
    else if (tag === 4) obj.top = pbf.readDouble();
    else if (tag === 5) obj.num_items = pbf.readVarint();
    else if (tag === 6) obj.num_nodes = pbf.readVarint();
    else if (tag === 7) obj.node_size = pbf.readVarint();
    else if (tag === 8) obj.serialized = pbf.readBytes();
};
Index.PackedRTree.write = function (obj, pbf) {
    if (obj.left) pbf.writeDoubleField(1, obj.left);
    if (obj.bottom) pbf.writeDoubleField(2, obj.bottom);
    if (obj.right) pbf.writeDoubleField(3, obj.right);
    if (obj.top) pbf.writeDoubleField(4, obj.top);
    if (obj.num_items) pbf.writeVarintField(5, obj.num_items);
    if (obj.num_nodes) pbf.writeVarintField(6, obj.num_nodes);
    if (obj.node_size) pbf.writeVarintField(7, obj.node_size);
    if (obj.serialized) pbf.writeBytesField(8, obj.serialized);
};
