예제 #1
0
NOAAStore::iterator
NOAAStore::AddStation(const TCHAR *code)
{
    assert(IsValidCode(code));

    WideToUTF8Converter code2(code);
    assert(code2.IsValid());
    return AddStation(code2);
}
예제 #2
0
NOAAStore::iterator
NOAAStore::AddStation(const TCHAR *code)
{
#ifndef NDEBUG
  assert(_tcslen(code) == 4);
  for (unsigned i = 0; i < 4; i++)
    assert(code[i] >= _T('A') && code[i] <= _T('Z'));
#endif

  size_t len = _tcslen(code);
  char code2[len * 4 + 1];
  ::WideCharToMultiByte(CP_UTF8, 0, code, len, code2, sizeof(code2), NULL, NULL);
  code2[4] = 0;

  return AddStation(code2);
}
예제 #3
0
bool
NOAAStore::LoadFromString(const char *string)
{
  const char *s = string;
  while (s != NULL && *s) {
    const char *next = strchr(s, _T(','));
    if ((next != NULL && next - s == 4) || (next == NULL && strlen(s) == 4)) {
      char code[5];
      std::copy_n(s, 4, code);
      code[4] = '\0';
      if (IsValidCode(code))
        AddStation(code);
    }
    s = (next == NULL) ? NULL : next + 1;
  }
  return true;
}
예제 #4
0
bool
NOAAStore::LoadFromString(const TCHAR *string)
{
  const TCHAR *s = string;
  while (s != NULL && *s) {
    const TCHAR *next = _tcschr(s, _T(','));
    if ((next != NULL && next - s == 4) || (next == NULL && _tcslen(s) == 4)) {
      TCHAR code[5];
      std::copy(s, s+4, code);
      code[4] = '\0';
      if (IsValidCode(code))
        AddStation(code);
    }
    s = (next == NULL) ? NULL : next + 1;
  }
  return true;
}
예제 #5
0
    // ns    number of stations
    // geom  model geometry
    // names station names
    // len   max nr chars in station names
StationTexture::StationTexture( int ns, Geometry * geom, const char ** names, unsigned int len )
  : length( len + 1 )
  , texData( NULL )
  , nStation( ns )
  , modelGeometry( geom )
  , vertex( NULL )
  , index( NULL )
  , geometry( GL_TRIANGLES, "stations", FLAG_STATIONS )
{
  bpp = BPP;
  // LOGI("Station Texture cstr: max name length %d, stations %d, BPP %d", length, nStation, bpp );
  name_width = length * (WIDTH+2);
  rows = (nStation + COLS-1) / COLS;
  width  = name_width * COLS;
  height = rows  * HEIGHT;
  table_stride = width * bpp;
  name_stride  = name_width * bpp;

  if ( nStation > 0 ) {
    texData = new unsigned char[ table_stride * height ];
    memset( texData, 0, table_stride * height ); 
    vertex = new float[ 4 * 5 * nStation ];      // 4 vertices/label, 5 float/vertex, nStation labels
    index  = new unsigned short[ 6 * nStation ]; // 6 int/label 
  }
  SetTexture( width, height, bpp, texData );
  geometry.SetNVertex( 4 * nStation );
  geometry.SetNIndex( 6 * nStation );
  geometry.SetVertex( (void *)vertex );
  geometry.SetIndex( (void *)index );
  geometry.SetNPos( 3 );  // nr. vertex position elements
  geometry.SetNCol( 1 );  // not used
  geometry.SetNTex( 2 );  // nr. texture coord elements
  geometry.SetVertexStride( sizeof(float) * 5 );
  LOGI("Station Texture nr. stations %d", nStation );
  for ( int k=0; k<nStation; ++k ) {
    if ( names[k] == NULL ) {
      LOGW("WARNING station %d / %d has NULL name", k, nStation );
      break;
    }
    AddStation( k, names[k] );
  }
}