Example #1
0
void
way::mark_diff(const vector<id_t> &lcs, tiler &t, osm::io::Database &d) const {
  // the LCS had better be less than or equal to the length of way nodes
  // or something has gone spectacularly wrong.
  assert(lcs.size() <= way_nodes.size());

  // find the sections of way_nodes which *don't* match the LCS
  size_t last_match = 0;
  bool match = false;
  vector<id_t>::const_iterator lcs_itr = lcs.begin();
  // it is possible that the LCS has no elements in it, meaning the entire
  // way should be marked.
  if (lcs.size() > 0) {
    for (size_t i = 0; i < way_nodes.size(); ++i) {
      if (*lcs_itr == way_nodes[i]) {
        if (!match) {
          // mark from last_match to i
          mark_segment(last_match, i, t, d);
          match = true;
        }

        last_match = i;
        ++lcs_itr;

      } else {
        match = false;
      }
    }
  }
  if (!match) {
    mark_segment(last_match, way_nodes.size() - 1, t, d);
  }
}
void assimilate_sample_segment(char *line)
{
long start,end;
if(segments==NULL){
	fprintf(stderr,"** SAMPLE_SEGMENTS *must* follow DURATION and SAMPLES_PER_SECOND commands\n");
	exit(-1);
	}
sscanf(line,"%ld %ld", &start, &end);
mark_segment(start, end);
}
void assimilate_subsecond_segment(char *line)
{
double start,end;
if(segments==NULL){
	fprintf(stderr,"** SUBSECOND_SEGMENTS *must* follow DURATION and SAMPLES_PER_SECOND commands\n");
	exit(-1);
	}
sscanf(line,"%lg %lg", &start, &end);
mark_segment(lrint((start-gps_start)*samples_per_second), lrint((end-gps_start)*samples_per_second));
}
void assimilate_segment(char *line)
{
INT64 start,end;
if(segments==NULL){
	fprintf(stderr,"** SEGMENTS *must* follow DURATION and SAMPLES_PER_SECOND commands\n");
	exit(-1);
	}
sscanf(line,"%lld %lld", &start, &end);
mark_segment((start-gps_start)*samples_per_second, (end-gps_start)*samples_per_second);
}