Exemplo n.º 1
0
void fb_table::store(uint16_t field, const void *data, size_t length)
{
	if (elements[field].column->row > row) {
		/* this row already written */
		MSG_WARNING(MSG_MODULE, "not writing element #%d of template %d, element already written", field, template_id);
		return;
	}

	switch (elements[field].type) {
		/* Numeric types */
	case IPFIX_TYPE_unsigned8:
	case IPFIX_TYPE_signed8:
	case IPFIX_TYPE_unsigned16:
	case IPFIX_TYPE_signed16:
	case IPFIX_TYPE_unsigned32:
	case IPFIX_TYPE_dateTimeSeconds:
	case IPFIX_TYPE_ipv4Address:
	case IPFIX_TYPE_signed32:
	case IPFIX_TYPE_float32:
	case IPFIX_TYPE_unsigned64:
	case IPFIX_TYPE_dateTimeMilliseconds:
	case IPFIX_TYPE_dateTimeMicroseconds:
	case IPFIX_TYPE_dateTimeNanoseconds:
	case IPFIX_TYPE_signed64:
	case IPFIX_TYPE_float64:
	case IPFIX_TYPE_boolean:
	case IPFIX_TYPE_macAddress:
		store_numeric(elements[field].column, data, length);
		break;

	case IPFIX_TYPE_ipv6Address:
		store_numeric(elements[field].column, &((char *) data)[0], 8);
		store_numeric(elements[field].column+1, &((char *) data)[8], 8);
		break;
	case IPFIX_TYPE_octetArray:
		store_blob(elements[field].column, data, length);
		break;
	case IPFIX_TYPE_string:
		elements[field].column->data.append(length, data);
		elements[field].column->data.append(1, "\0");
		elements[field].column->row++;
		break;
	
	case IPFIX_TYPE_basicList:
	case IPFIX_TYPE_subTemplateList:
	case IPFIX_TYPE_subTemplateMultiList:
		store_blob(elements[field].column, data, length);
		break;

	default:
		break;
	}

}
Exemplo n.º 2
0
 /**
  * store the current pbf_header_block into a Blob and clear this struct afterwards.
  */
 void store_header_block() {
     if (Osmium::debug()) {
         std::cerr << "storing header block" << std::endl;
     }
     store_blob("OSMHeader", pbf_header_block);
     pbf_header_block.Clear();
 }
Exemplo n.º 3
0
Arquivo: pbf.hpp Projeto: Rub21/osmium
 /**
  * store the current pbf_header_block into a Blob and clear this struct afterwards.
  */
 void store_header_block() {
     if (debug && has_debug_level(1)) {
         std::cerr << "storing header block" << std::endl;
     }
     store_blob("OSMHeader", pbf_header_block);
     pbf_header_block.Clear();
 }
Exemplo n.º 4
0
            /**
             * store the interim StringTable to the current pbf_primitive_block, map all interim string ids
             * to real StringTable ids and then store the current pbf_primitive_block into a Blob and clear
             * this struct and all related pointers and maps afterwards.
             */
            void store_primitive_block() {
                if (Osmium::debug()) {
                    std::cerr << "storing primitive block with " << primitive_block_contents << " items" << std::endl;
                }

                // store the interim StringTable into the protobuf object
                string_table.store_stringtable(pbf_primitive_block.mutable_stringtable());

                // map all interim string ids to real ids
                map_string_ids();

                // store the Blob
                store_blob("OSMData", pbf_primitive_block);

                // clear the PrimitiveBlock struct
                pbf_primitive_block.Clear();

                // add empty StringTable entry at index 0
                // StringTable index 0 is rserved as delimiter in the densenodes key/value list
                // this line also ensures that there's always a valid StringTable
                pbf_primitive_block.mutable_stringtable()->add_s("");

                // set the granularity
                pbf_primitive_block.set_granularity(location_granularity());
                pbf_primitive_block.set_date_granularity(date_granularity());

                // clear the interim StringTable and its id map
                string_table.clear();

                // reset the delta variables
                m_delta_id.clear();
                m_delta_lat.clear();
                m_delta_lon.clear();
                m_delta_timestamp.clear();
                m_delta_changeset.clear();
                m_delta_uid.clear();
                m_delta_user_sid.clear();

                // reset the contents-counter to zero
                primitive_block_contents = 0;

                // reset the node/way/relation pointers to NULL
                pbf_nodes = NULL;
                pbf_ways = NULL;
                pbf_relations = NULL;
            }
Exemplo n.º 5
0
Arquivo: pbf.hpp Projeto: Rub21/osmium
            /**
             * store the interim StringTable to the current pbf_primitive_block, map all interim string ids
             * to real StringTable ids and then store the current pbf_primitive_block into a Blob and clear
             * this struct and all related pointers and maps afterwards.
             */
            void store_primitive_block() {
                if (debug && has_debug_level(1)) {
                    std::cerr << "storing primitive block with " << primitive_block_contents << " items" << std::endl;
                }

                // set the granularity
                pbf_primitive_block.set_granularity(location_granularity());
                pbf_primitive_block.set_date_granularity(date_granularity());

                // store the interim StringTable into the protobuf object
                string_table.store_stringtable(pbf_primitive_block.mutable_stringtable());

                // map all interim string ids to real ids
                map_string_ids();

                // store the Blob
                store_blob("OSMData", pbf_primitive_block);

                // clear the PrimitiveBlock struct
                pbf_primitive_block.Clear();

                // clear the interim StringTable and its id map
                string_table.clear();

                // reset the delta variables
                m_delta_id.clear();
                m_delta_lat.clear();
                m_delta_lon.clear();
                m_delta_timestamp.clear();
                m_delta_changeset.clear();
                m_delta_uid.clear();
                m_delta_user_sid.clear();

                // reset the contents-counter to zero
                primitive_block_contents = 0;
                primitive_block_size = 0;

                // reset the node/way/relation pointers to NULL
                pbf_nodes = NULL;
                pbf_ways = NULL;
                pbf_relations = NULL;
            }
Exemplo n.º 6
0
/*
 * Collects contiguous ranges of pixels with values larger than a threshold of
 * 0x9f in a given scanline and stores them in extents. Processing stops after
 * num_extents.
 * Extents are marked with the same index as overlapping extents of the previous
 * scanline, and properties of the formed blobs are accumulated.
 *
 * Returns the number of extents found.
 */
static int process_scanline(uint8_t *line, int width, int height, int y,
			    struct extent_line *el, struct extent_line *prev_el,
			    int index, struct blobservation *ob)
{
	struct extent *le_end = prev_el->extents;
	struct extent *le = prev_el->extents;
	struct extent *extent = el->extents;
	struct blob *blobs = ob->blobs;
	int num_extents = MAX_EXTENTS_PER_LINE;
	int num_blobs = MAX_BLOBS_PER_FRAME;
	int center;
	int x, e = 0;

	if (prev_el)
		le_end += prev_el->num;

	for (x = 0; x < width; x++) {
		int start, end;

		/* Loop until pixel value exceeds threshold */
		if (line[x] <= THRESHOLD)
			continue;

		start = x++;

		/* Loop until pixel value falls below threshold */
		while (x < width && line[x] > THRESHOLD)
			x++;

		end = x - 1;
		/* Filter out single pixel and two-pixel extents */
		if (end < start + 2)
			continue;

		center = (start + end) / 2;

		extent->start = start;
		extent->end = end;
		extent->index = index;
		extent->area = x - start;

		if (prev_el && index < num_blobs) {
			/*
			 * Previous extents without significant overlap are the
			 * bottom of finished blobs. Store them into an array.
			 */
			while (le < le_end && le->end < center &&
			       le->index < num_blobs)
				store_blob(le++, y, blobs);

			/*
			 * A previous extent with significant overlap is
			 * considered to be part of the same blob.
			 */
			if (le < le_end &&
			    le->start <= center && le->end > center) {
				extent->top = le->top;
				extent->left = min(extent->start, le->left);
				extent->right = max(extent->end, le->right);
				extent->area += le->area;
				extent->index = le->index;
				le++;
			}
		}

		/*
		 * If this extent is not part of a previous blob, increment the
		 * blob index.
		 */
		if (extent->index == index) {
			extent->top = y;
			extent->left = extent->start;
			extent->right = extent->end;
			index++;
		}

		if (++e == num_extents)
			break;
		extent++;
	}

	if (prev_el) {
		/*
		 * If there are no more extents on this line, all remaining
		 * extents in the previous line are finished blobs. Store them.
		 */
		while (le < le_end && le->index < num_blobs)
			store_blob(le++, y, blobs);
	}

	el->num = e;

	if (y == height - 1) {
		/* All extents of the last line are finished blobs, too. */
		for (extent = el->extents; extent < el->extents + el->num;
		     extent++) {
			if (extent->index < num_blobs)
				store_blob(extent, y, blobs);
		}
	}

	return index;
}
Exemplo n.º 7
0
void command_add_single_entry(char* object_hash, char* filename) {
    store_blob(object_hash, filename);
}