コード例 #1
0
ファイル: string.c プロジェクト: aidarbiktimirov/shell
void replace_string_part(struct string *dest, struct string *s, struct string *replace, size_t start, size_t end)
{
	struct string result, tmp;
	if (start > strlen(s->str))
	{
		start = strlen(s->str);
	}
	if (end > strlen(s->str))
	{
		end = strlen(s->str);
	}
	if (start > end)
	{
		return;
	}
	make_string(&result);
	make_string(&tmp);
	sub_string(&result, s, 0, start);
	append_string(&result, replace);
	sub_string(&tmp, s, end, strlen(s->str));
	append_string(&result, &tmp);
	copy_string(dest, &result);
	free_string(&tmp);
	free_string(&result);
	
}
コード例 #2
0
ファイル: utils.c プロジェクト: pombredanne/tdl
/******************************************************************************
* string_replace()
* Replace a string
*
* Parameters
* ---------
* - a text string
* - fstr: string to search for
* - rstr: replacement string
* - numrep: count on how many times the string was replaced
*
* Returns
* -------
* - a new string
*
* Notes
* -----
* This replaces all instances of fstr with rstr in str.
* Note this Frees str!!!!
*
******************************************************************************/
char *string_replace(char *str, char *fstr,
                     char *rstr,int *num_rep)
{
    char *tmp1, *tmp2, *tmp3;
    int  p1=0, len, ok = TRUE;
    if ((str == NULL)||(fstr == NULL) ||(rstr == NULL)){
        return(NULL);
    }
    if (strcmp(fstr,rstr)==0) return(str);
    len = string_len(fstr);
    *num_rep = 0;
    while (ok){
        p1 = find_string(str,fstr,0);
        if (p1 < 0) {
            ok = FALSE;
        } else if (p1 > 0){
            tmp1 = sub_string(str,0,p1-1);
            tmp2 = str + p1 + len;
        } else {
            tmp1 = NULL;
            tmp2 = str + len;
        }
        if(ok){
            tmp3 = concat_3(tmp1,rstr,tmp2);
            free(tmp1);
            free(str);
            str = tmp3;
            *num_rep = *num_rep +1;
        }
    }
    return(str);
}
コード例 #3
0
ファイル: real.c プロジェクト: mRasey/C
int real() {
    char input[20];
    scanf("%s", input);
    char now = input[0];
    if(now == '+' || now == '-') {
        if(!judge(sub_string(input, 1, strlen(input)))) {
            printf("Wrong!");
            return 0;
        }
        if(number_of(input, 'E'))
            printf("Format2");
        else
            printf("Format1");
        return 0;
    }
    else if(isdigit(now)) {
        if(!judge(input)) {
            printf("Wrong!");
            return 0;
        }
        if(number_of(input, 'E'))
            printf("Format2");
        else
            printf("Format1");
        return 0;
    }
    else {
        printf("Wrong!");
        return 0;
    }
}
コード例 #4
0
bool yl_data_point::key_from_string(const String &str)
{
	if (str.length() == 0)
	{
		return true;
	}

	key_ = sub_string(str, 0, "\"timestamp\":\"", "\",");
	return key_.length();
}
コード例 #5
0
ファイル: zk_hashtable.c プロジェクト: jacksonicson/twospot
static void do_foreach_watcher(watcher_object_t* wo,zhandle_t* zh,
        const char* path,int type,int state)
{
    char *client_path = sub_string(zh, path);
    while(wo!=0){
        wo->watcher(zh,type,state,client_path,wo->context);
        wo=wo->next;
    }    
    free_duplicate_path(client_path, path);
}
コード例 #6
0
bool yl_generic_data_point::key_from_string(const String &str)
{
	if (str.length() == 0)
	{
		return false;
	}

	key_ = sub_string(str, 0, "\"key\":\"", "\",");
	return key_.length();
}
コード例 #7
0
bool yl_value_data_point::value_from_string(const String &str)
{
	if (str.length() == 0)
	{
		return false;
	}

	String value = sub_string(str, 0, "\"value\":", "}");
	value_ = atof(&value[0]);
	return true;
}
コード例 #8
0
ファイル: string.c プロジェクト: aidarbiktimirov/shell
void replace_string(struct string *dest, struct string *_s, struct string *replace, struct string *subject)
{
	size_t i, j, break_flag;
	struct string temp, s;
	make_string(&s);
	copy_string(&s, _s);
	for (i = 0; i <= strlen(s.str) - strlen(replace->str); ++i)
	{
		break_flag = 0;
		for (j = 0; j < strlen(replace->str); ++j)
		{
			if (s.str[i + j] != replace->str[j])
			{
				break_flag = 1;
				break;
			}
		}
		if (break_flag == 0)
		{
			break;
		}
	}
	if (break_flag == 1)
	{
		free_string(&s);
		return;
	}
	clear_string(dest);
	make_string(&temp);
	sub_string(&temp, &s, 0, i);
	append_string(dest, &temp);
	if (subject != NULL)
	{
		append_string(dest, subject);
	}
	sub_string(&temp, &s, i + strlen(replace->str), s.size);
	append_string(dest, &temp);
	free_string(&temp);
	normalize_string_length(dest);
	free_string(&s);
}
コード例 #9
0
int main(int argc, char *argv[]){

  char str1[] = "defghikkkk";
  char str2[] ="efg";

  if(sub_string(str1, str2))
    printf("has\n");
  else
    printf("not has\n");

  return 0;
}
コード例 #10
0
ファイル: zk_hashtable.c プロジェクト: FUNCATE/visuwall
static void do_foreach_watcher(watcher_object_t* wo,zhandle_t* zh,
        const char* path,int type,int state)
{
    // session event's don't have paths
    const char *client_path =
        (type != ZOO_SESSION_EVENT ? sub_string(zh, path) : path);
    while(wo!=0){
        wo->watcher(zh,type,state,client_path,wo->context);
        wo=wo->next;
    }    
    free_duplicate_path(client_path, path);
}
コード例 #11
0
ファイル: mcstring.c プロジェクト: timofurrer/mcstring
mcstring *rtrim_string(mcstring *string, const char *chars) {
  size_t x, y;
  unsigned char found = 1;
  size_t found_counter = 0;
  for(y = string->size; y > 0 && found; y--) {
    mcchar c = string->data[y];
    for(x = 0; chars[x] != 0; x++) {
      if(c == chars[x]) {
        found_counter++;
      }
    }
  }
  return sub_string(string, 0, string->size - found_counter);
}
コード例 #12
0
ファイル: substring.c プロジェクト: n24/Advanced_C_and_Unix
int main ( int argc, char ** argv ) {
	char str[LENGTH], * sub_str;
	FILE * fp;

	if ( argc < 2 ) {
		fprintf ( stderr, "Error: Invalid number of arguments\n" );
		fprintf ( stderr, "Usage: ./a.out <sub_string> [<file1> ...... <filen>]\n" );
		exit ( 1 );
	}
	
	sub_str = argv[1];

	if ( argc == 2 ) {
		while ( fgets ( str, LENGTH, stdin ) ) {
			if ( sub_string ( str, sub_str ) )
				printf ( "stdin: %s", str );
		}
		exit ( 0 );
	}

	++argv;
	while ( *++argv ) {
		if ( !strcmp ( *argv, "-" ) )
			fp = stdin;
		else if ( (fp = fopen ( *argv, "r" )) == NULL ) {
			perror ( *argv );
			continue;
		}
		while ( fgets ( str, LENGTH, fp ) ) {
			if ( sub_string ( str, sub_str ) )
				printf ( "%s: %s", *argv, str );
		}
		fclose ( fp );
	}
	
	return 0;
}
コード例 #13
0
static void do_foreach_watcher(watcher_object_t* wo,zhandle_t* zh,
                               const char* path,int type,int state)
{
    char *client_path = sub_string(zh, path);
    while(wo!=0) {
#ifdef HAVE_LIBRUBY
        if (getenv("RUBY_MRI_VERSION") != NULL)
            ruby_watcher_wrapper(wo->watcher,zh,type,state,client_path,wo->context);
        else
#endif
            wo->watcher(zh,type,state,client_path,wo->context);
        wo=wo->next;
    }
    free_duplicate_path(client_path, path);
}
コード例 #14
0
ファイル: main.c プロジェクト: gnuvse/sls
int main() {
	char str[] = "chatterbox";
	char substr[SIZE];

	printf("position = %i\n", find_string(str, "ter"));

	remove_string(str, 2, 4);

	printf("%s\n", str);

	sub_string(str, 2, 29, substr);

	printf("%s\n", substr);


	return 0;
}
コード例 #15
0
ファイル: utils.c プロジェクト: pombredanne/tdl
/******************************************************************************
* get_word_from_string
* Get a specific word from a srting
*
* Parameters
* ---------
* - a string
* - which word
*
* Returns
* -------
* - a new string
*
* Notes
* -----
* Get the "which" word from a string, where the words are space
* delimited.  note this starts with 1, ie which = 1 is the first word
* in the string, the returned string should have NO whitespace
* Note this rets a new string.
******************************************************************************/
char *get_word_from_string(char *str, int which)
{
    int num_words = 0;
    int num=0;
    int j=0;
    int idx_l, idx_h;
    int cont;
    int len;

    if (str == NULL) return(NULL);
    len = string_len(str);
    num_words = num_words_in_string(str);
    /* if the last word is only a single char then it
    misses that in the count ??*/

    if (which > num_words) return NULL;

    /* skip through leading whitespace */
    while( is_white_space(str[j]) ) j++;
    if (str[j] == '\0') return NULL;

    /* apparently we are at a word */
    cont = TRUE;
    while (cont) {
        idx_l = j;
        while( !is_white_space(str[j]) && (j<len) ) j++;
        num++;
        idx_h = j-1;
        if (num == which){
            cont = FALSE;
        } else {
            while (is_white_space(str[j]) && (j < len)) j++;
            if( (str[j] == '\n') || (str[j] == '\0')  || ((j+1)>len) ) cont=FALSE;
            // this last line seems wrong but it works?????
        }
    }
    return (sub_string(str,idx_l,idx_h));
}
コード例 #16
0
int read_envi_header
(
    char *data_type,       /* I: input data type        */
    char *scene_name,      /* I: scene name             */
    Input_meta_t *meta     /* O: saved header file info */
)
{
    char  buffer[MAX_STR_LEN] = "\0"; /* for retrieving fields        */
    char  *label = NULL;              /* for retrieving string tokens */
    char  *tokenptr = NULL;           /* for retrieving string tokens */
    char  *tokenptr2 = NULL;          /* for retrieving string tokens */
    char  *seperator = "=";           /* for retrieving string tokens */
    char  *seperator2 = ",";          /* for retrieving string tokens */
    FILE *in;                         /* file ptr to input hdr file   */
    int ib;                           /* loop index                   */
    char map_info[10][MAX_STR_LEN];   /* projection information fields*/
    char FUNC_NAME[] = "read_envi_header"; /* function name           */
    char filename[MAX_STR_LEN];       /* scene name                   */
    int len;                          /* for strlen                   */
    char short_scene[MAX_STR_LEN];    /* char string for text manipulation */
    char directory[MAX_STR_LEN];      /* for constucting path/file names */
    char tmpstr[MAX_STR_LEN];         /* char string for text manipulation */
    char scene_list_name[MAX_STR_LEN];/* char string for text manipulation */
    int landsat_number;               /* mission number defines file name */


    /******************************************************************/
    /*                                                                */
    /* Determine the file name.                                       */
    /*                                                                */
    /******************************************************************/

    if (strcmp(data_type, "tifs") == 0)
    {
        len = strlen(scene_name);
        landsat_number = atoi(sub_string(scene_name,(len-19),1));
        if (landsat_number == 8)
            sprintf(filename, "%s_sr_band2.hdr", scene_name);
        else
            sprintf(filename, "%s_sr_band1.hdr", scene_name);
    }
    else if (strcmp(data_type, "bip") == 0)
    {
        len = strlen(scene_name);
        strncpy(short_scene, scene_name, len-5);
        split_directory_scenename(scene_name, directory, scene_list_name);
        if (strncmp(short_scene, ".", 1) == 0)
        {
            strncpy(tmpstr, short_scene + 2, len - 2);
            sprintf(filename, "%s/%s_MTLstack.hdr", tmpstr, scene_list_name);
        }
        else
            sprintf(filename, "%s/%s_MTLstack.hdr", short_scene, scene_list_name);
    }

    in=fopen(filename, "r");
    if (in == NULL)
    {
        RETURN_ERROR ("opening header file", FUNC_NAME, FAILURE);
    }

    /* process line by line */
    while(fgets(buffer, MAX_STR_LEN, in) != NULL) 
    {

        char *s;
        s = strchr(buffer, '=');
        if (s != NULL)
        {
            /* get string token */
            tokenptr = strtok(buffer, seperator);
            label=trimwhitespace(tokenptr);

            if (strcmp(label,"lines") == 0)
            {
                tokenptr = trimwhitespace(strtok(NULL, seperator));
                meta->lines = atoi(tokenptr);
            }

            if (strcmp(label,"data type") == 0)
            {
                tokenptr = trimwhitespace(strtok(NULL, seperator));
                meta->data_type = atoi(tokenptr);
            }

            if (strcmp(label,"byte order") == 0)
            {
                tokenptr = trimwhitespace(strtok(NULL, seperator));
                meta->byte_order = atoi(tokenptr);
            }

            if (strcmp(label,"samples") == 0)
            {
                tokenptr = trimwhitespace(strtok(NULL, seperator));
                meta->samples = atoi(tokenptr);
            }

            if (strcmp(label,"interleave") == 0)
            {
                tokenptr = trimwhitespace(strtok(NULL, seperator));
                strcpy(meta->interleave, tokenptr);
            }

            if (strcmp(label,"UPPER_LEFT_CORNER") == 0)
            {
                tokenptr = trimwhitespace(strtok(NULL, seperator));
            }

            if (strcmp(label,"map info") == 0)
            {
                tokenptr = trimwhitespace(strtok(NULL, seperator));
            }

            if (strcmp(label,"map info") == 0)
            {
                tokenptr2 = strtok(tokenptr, seperator2);
                ib = 0;
                while(tokenptr2 != NULL)
                {
                    strcpy(map_info[ib], tokenptr2);
                    if (ib == 3)
                        meta->upper_left_x = atoi(map_info[ib]);
                    if (ib == 4)
                        meta->upper_left_y = atoi(map_info[ib]);
                    if (ib == 5)
                        meta->pixel_size = atoi(map_info[ib]);
                    if(ib == 7)
                        meta->utm_zone = atoi(map_info[ib]);
                    tokenptr2 = strtok(NULL, seperator2);
                    ib++;
                }
            }
        }
    }
    fclose(in);

    return (SUCCESS);
}
コード例 #17
0
int read_tifs
(
    char *sceneID_name,  /* I:   current file name in list of sceneIDs  */
    FILE ***fp_tifs,     /* I/O: file pointer array for band file names */
    int  curr_scene_num, /* I:   current num. in list of scenes to read */
    int  row,            /* I:   the row (Y) location within img/grid   */
    int  col,            /* I:   the col (X) location within img/grid   */
    int  num_samples,    /* I:   number of image samples (X width)      */
    bool debug,          /* I:   flag for printing debug messages       */
    int  **image_buf     /* O:   pointer to 2-D image band values array */
)

{
    int  k;                     /* band loop counter.                   */
    int  len;                   /* for string length call.              */
    int  landsat_number;        /* numeric mission number to make names */
    char filename[MAX_STR_LEN]; /* file name constructed from sceneID   */
    int  status;                /* return status of system call(s)      */


    /******************************************************************/
    /*                                                                */
    /* Read the image bands for this scene. using the                 */
    /*                                                                */
    /******************************************************************/

    for (k = 0; k < TOTAL_IMAGE_BANDS; k++)
    {
        len = strlen(sceneID_name);
        landsat_number = atoi(sub_string(sceneID_name,(len-19),1));
        if (landsat_number != 8)
        {
            if (k == 5)
                sprintf(filename, "%s_sr_band%d.img", sceneID_name, k+2);
            else if (k == 6)
                sprintf(filename, "%s_toa_band6.img", sceneID_name);
            else
                sprintf(filename, "%s_sr_band%d.img", sceneID_name, k+1);
        }
        else
        {
            if (k == 6)
                sprintf(filename, "%s_toa_band10.img", sceneID_name);
            else 
                sprintf(filename, "%s_sr_band%d.img",  sceneID_name, k+2);
        }

        fp_tifs[k][curr_scene_num] = open_raw_binary(filename,"rb");
        if (fp_tifs[k][curr_scene_num] == NULL)
            printf("error open %d scene, %d bands files\n",curr_scene_num, k+1);

        status = fseek(fp_tifs[k][curr_scene_num], ((row * num_samples) + col) * sizeof(short int), SEEK_SET);
        if (status != 0)
            printf("error seeking %d scene, %d bands\n", curr_scene_num, (k + 1));

        if (read_raw_binary(fp_tifs[k][curr_scene_num], 1, 1, sizeof(short int), &image_buf[k][curr_scene_num]) != 0)
            printf("error reading %d scene, %d bands\n", curr_scene_num, (k + 1));
    
        close_raw_binary(fp_tifs[k][curr_scene_num]);

        if (debug)
        {
            printf("%d ", (short int)image_buf[k][curr_scene_num]);
        }

    }

    return (SUCCESS);
}
コード例 #18
0
ファイル: string.hpp プロジェクト: akivajp/seraf
 unistr *sub_string1(size_t from) const { return sub_string(from, -1); }
コード例 #19
0
ファイル: string.hpp プロジェクト: akivajp/lev
 boost::shared_ptr<ustring> sub_string1(size_t from) const { return sub_string(from); }
コード例 #20
0
int read_cfmask
(
    int  curr_scene_num, /* I:   current num. in list of scenes to read       */
    char *data_type,     /* I:   type of flies, tifs or single BIP            */
    char **scene_list,   /* I:   current scene name in list of sceneIDs       */
    int  row,            /* I:   the row (Y) location within img/grid         */
    int  col,            /* I:   the col (X) location within img/grid         */
    int  num_samples,    /* I:   number of image samples (X width)            */
    FILE ***fp_tifs,     /* I/O: file ptr array for tif band file names       */
    FILE **fp_bip,       /* I/O: file pointer array for BIP file names        */
    unsigned char *fmask_buf,/* O:   pointer to cfmask band values            */
                         /* I/O: Worldwide Reference System path and row for  */
                         /* I/O: the current swath, this group of variables   */
                         /* I/O: is for filtering out swath overlap, and      */
    int *prev_wrs_path,  /* I/O: using the first of two scenes in a swath,    */
    int *prev_wrs_row,   /* I/O: , because it is recommended to use the meta  */
    int *prev_year,      /* I/O: data from the first for things like sun      */
    int *prev_jday,      /* I/O: angle, etc. However, always removing a       */
    unsigned char *prev_fmask_buf,/* I/O: redundant x/y location specified    */
    int *valid_scene_count,/* I/O: x/y is not always valid for gridded data,  */
    int *swath_overlap_count,/* I/O: it may/may not be in swap overlap area.  */
    char **valid_scene_list,/* I/O: 2-D array for list of filtered            */
    int *clear_sum,      /* I/O: Total number of clear cfmask pixels          */
    int *water_sum,      /* I/O: counter for cfmask water pixels.             */
    int *shadow_sum,     /* I/O: counter for cfmask shadow pixels.            */
    int *sn_sum,         /* I/O: Total number of snow cfmask pixels           */
    int *cloud_sum,      /* I/O: counter for cfmask cloud pixels.             */
    int *fill_sum,       /* I/O: counter for cfmask fill pixels.              */
    int *all_sum,        /* I/O: Total of all cfmask pixels                   */
    unsigned char *updated_fmask_buf, /* I/O: new entry in valid fmask values */
    int *updated_sdate_array, /* I/O: new buf of valid date values            */
    int *sdate,          /* I:   Original array of julian date values         */
    int *valid_num_scenes/* I/O: number of valid scenes after reading cfmask  */
)

{

    int len;             /* for strlen call                             */
    int landsat_number;  /* mission number for determining file names   */
    char scene_name[MAX_STR_LEN]; /* current scene id name              */
    char filename[MAX_STR_LEN];   /* temp for constructing file name    */
    int wrs_path;        /* Worldwide Reference System path             */
    int wrs_row = 0;     /* WRS row                                     */
    int year;            /* Year of acquisition date of current scene   */
    int jday;            /* Julian day since 0 of current scene date    */
    bool debug = 1;      /* for debug printing                          */
    int status;          /* for return status of function calls         */
    char short_scene[MAX_STR_LEN]; /* for parsing file names            */
    char directory[MAX_STR_LEN]; /* for parsing file names              */
    char tmpstr[MAX_STR_LEN]; /* for parsing file names                 */
    char errmsg[MAX_STR_LEN]; /* for printing errors before log/quit    */
    char FUNC_NAME[] = "read_cfmask"; /* for printing errors messages   */
    int int_buf;         /* for reading cfmask value then type cast     */

    if (strcmp(data_type, "tifs") == 0)
    {

        /**************************************************************/
        /*                                                            */
        /* Determine the cfmask file name to read.                    */
        /*                                                            */
        /**************************************************************/
    
        len = strlen(scene_list[curr_scene_num]);
        landsat_number = atoi(sub_string(scene_list[curr_scene_num],(len-19),1));
        wrs_path = atoi(sub_string(scene_list[curr_scene_num],(len-18),3));
        wrs_row =  atoi(sub_string(scene_list[curr_scene_num],(len-15),3));
        year = atoi(sub_string(scene_list[curr_scene_num],(len-12),4));
        jday = atoi(sub_string(scene_list[curr_scene_num],(len- 8),3));
        sprintf(filename, "%s_cfmask.img", scene_list[curr_scene_num]);
    
        /**************************************************************/
        /*                                                            */
        /* Open the cfmask file, fseek and read.                      */
        /* if the path, year, and jdate of adjacent sorted scenes are */
        /* the same, and the rows are different by 1, and both fmask  */
        /* values are NOT fill, then this is a case of swath (pixel)  */
        /* overlap, so use the lesser row number of the two, and      */
        /* throw away the grerater row of the two, and update the     */
        /* valid scene list accordingly.   If only one of the two     */
        /* fmask values are FILL, then we are not in an area of swath */
        /* overlap, and the later check for fill will elinimate the   */
        /* uneccesary scene pixels.                                   */
        /*                                                            */
        /**************************************************************/
    
        fp_tifs[CFMASK_BAND][curr_scene_num] = open_raw_binary(filename,"rb");
        if (fp_tifs[CFMASK_BAND][curr_scene_num] == NULL)
            printf("error open %d scene, %d bands files\n", curr_scene_num, CFMASK_BAND+1);
    
        fseek(fp_tifs[CFMASK_BAND][curr_scene_num], (row * num_samples + col)*sizeof(unsigned char), 
            SEEK_SET);
    
        if (read_raw_binary(fp_tifs[CFMASK_BAND][curr_scene_num], 1, 1,
            sizeof(unsigned char), &fmask_buf[curr_scene_num]) != 0)
            printf("error reading %d scene, %d bands\n", curr_scene_num, CFMASK_BAND+1);

        close_raw_binary(fp_tifs[CFMASK_BAND][curr_scene_num]);
    }

    else if (strcmp(data_type, "bip") == 0)

    {

        len = strlen(scene_list[curr_scene_num]);
        strncpy(short_scene, scene_list[curr_scene_num], len-5);
        split_directory_scenename(scene_list[curr_scene_num], directory, scene_name);
        if (strncmp(short_scene, ".", 1) == 0)
        {
            strncpy(tmpstr, short_scene + 2, len - 2);
            sprintf(filename, "%s/%s_MTLstack", tmpstr, scene_name);
        }
        else
            sprintf(filename, "%s/%s_MTLstack", short_scene, scene_name);
        fp_bip[curr_scene_num] = open_raw_binary(filename,"rb");
        if (fp_bip[curr_scene_num] == NULL)
        {
            sprintf(errmsg, "Opening %d scene files\n", curr_scene_num);
            RETURN_ERROR (errmsg, FUNC_NAME, ERROR);
        }
        fseek(fp_bip[curr_scene_num], ((row - 1)* num_samples + col - 1) *
              TOTAL_BANDS * sizeof(short int) + (TOTAL_IMAGE_BANDS * sizeof(short int)), SEEK_SET);

        if (read_raw_binary(fp_bip[curr_scene_num], 1, 1,
                sizeof(short int), &int_buf) != 0)
        {
            sprintf(errmsg, "error reading %d scene, %d bands\n",curr_scene_num, CFMASK_BAND+1);
            RETURN_ERROR(errmsg, FUNC_NAME, FAILURE);
        }

        fmask_buf[curr_scene_num] = (unsigned char)int_buf;

        close_raw_binary(fp_bip[curr_scene_num]);

    }

    /******************************************************************/
    /*                                                                */
    /* Check for swath overlap pixels.  If consecutive temporal       */
    /* are in the same path, and in adjacent rows, are not fill, and  */
    /* have the same acquisition date, then they are essentially the  */
    /* same pixel, so use the first, because the metadata such as     */
    /* sun angle, etc. are more closely associated with the first.    */
    /*                                                                */
    /******************************************************************/

    if ((wrs_path == *prev_wrs_path) && (wrs_row == (*prev_wrs_row - 1)) &&
        (year == *prev_year) && (jday == *prev_jday) &&
        (fmask_buf[curr_scene_num] != CFMASK_FILL) && (*prev_fmask_buf != CFMASK_FILL))

    {
        (*swath_overlap_count)++;
        strcpy(valid_scene_list[(*valid_scene_count) - 1], scene_list[curr_scene_num]);
        if (debug)
        {
            printf("i = %d swath overlap %s\n", curr_scene_num, scene_list[curr_scene_num -1]);
        }
    }

    else

    {
        strcpy(valid_scene_list[*valid_scene_count], scene_list[curr_scene_num]);

        /**************************************************************/
        /*                                                            */
        /* Call the function with the case statement for totalling    */
        /* cfmask values, because it is used for all input type       */
        /* options, and we put it in a function so we did not have to */
        /* make multiple updates if something changed.                */
        /*                                                            */
        /**************************************************************/

        status = assign_cfmask_values (fmask_buf[curr_scene_num], clear_sum,
                                       water_sum, shadow_sum, sn_sum,
                                       cloud_sum, fill_sum, all_sum);
        if (status != SUCCESS)
        {
            RETURN_ERROR ("Calling assign_cfmask_values", 
                          "read_cfmask", FAILURE);
        }

        /**************************************************************/
        /*                                                            */
        /* After succesfully reading the cfmask data, update the list */
        /* of valid julian dates.                                     */
        /*                                                            */
        /**************************************************************/

        if (fmask_buf[curr_scene_num] < CFMASK_FILL)
        {
            updated_fmask_buf[*valid_scene_count] = fmask_buf[curr_scene_num];
            updated_sdate_array[*valid_scene_count] = sdate[curr_scene_num];
            (*valid_scene_count)++;
            (*valid_num_scenes)++;
        }
    }

    *prev_wrs_path = wrs_path;
    *prev_wrs_row  = wrs_row;
    *prev_year = year;
    *prev_jday = jday;
    *prev_fmask_buf = fmask_buf[curr_scene_num];

    return(SUCCESS);

}
コード例 #21
0
ファイル: string.hpp プロジェクト: akivajp/seraf
 unistr* index_str(size_t pos) const { return sub_string(pos, 1); }
コード例 #22
0
ファイル: string.hpp プロジェクト: akivajp/lev
 boost::shared_ptr<ustring> index_str(size_t pos) const { return sub_string(pos, 1); }