예제 #1
0
static void not_a_vpf_table( char *path )
{
   char *buf,*filename,*tempstr,ch;

   buf = (char *)vpfmalloc(255);
   filename = (char *)vpfmalloc(255);

   /* Not a VPF table - try to determine what type of file it is */
   if (strstr(path,"\\asi") ||
       strstr(path,"\\lsi") ||
       strstr(path,"\\nsi") ||
       strstr(path,"\\csi") ||
       strstr(path,"\\tsi")) {
      sprintf(filename,"%s is a spatial index file.",path);
      displaymessage(filename,
	   "It is not a VPF table and cannot be viewed directly",
	   NULL);
   } else if (strstr(path,".ati") ||
	      strstr(path,".lti") ||
	      strstr(path,".pti") ||
	      strstr(path,".tti")) {
      sprintf(filename,"%s is a thematic index file.",path);
      displaymessage(filename,
	       "It is not a VPF table and cannot be viewed directly",
	       NULL);
   } else if (path[strlen(path)-1] == 'x') {
      /* Need to determine what file it is the index for */
      sprintf(buf,"%s is a variable-length index file",path);
      strcpy(filename,path);
      for (ch='a';ch <= 'z';ch++) {
	 if (ch=='x') continue;
	 filename[strlen(path)-1] = ch;
	 if (access(filename,0) == 0) {
	    tempstr = strdup(filename);
	    sprintf(filename,"for %s.",tempstr);
	    free(tempstr);
	    break;
	 }
      }
      if (strcmp(path,filename)==0) {
	 displaymessage(buf,
	       "It is not a VPF table and cannot be viewed directly.",
	       NULL);
      } else {
	    displaymessage(buf, filename,
	       "It is not a VPF table and cannot be viewed directly.",
	       NULL);
      }
   } else {
      /* Not a VPF type of file */
      sprintf(filename,"%s: Not a VPF table",path);
      display_message(filename);
   }

   free(filename);
   free(buf);
}
예제 #2
0
/**************************************************************************
 *
 *N  select_feature_class_relate
 *
 *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Purpose:
 *P
 *    Set up the relationships between features and primitives or between
 *    primitives and features (one way only) for a specified feature class.
 *E
 *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   History:
 *H
 *    Barry Michaels  DOS Turbo C
 *E
 *************************************************************************/
fcrel_type select_feature_class_relate( int fcnum,
					library_type *library,
					char *start_table,
					char *end_table )
{
   int storage, cov;
   vpf_table_type fcs;
   long int i;
   char path[255], covpath[255];
   position_type p;
   vpf_relate_struct rcell;
   fcrel_type fcrel;

   fcrel.nchain = 0;
   fcrel.table = NULL;
   fcrel.relate_list = NULL;

   cov = library->fc[fcnum].coverage;
   strcpy(covpath,library->cover[cov].path);
   rightjust(covpath);
   sprintf( path, "%sfcs", covpath );

   /* Feature Class Schema table */
   fcs = vpf_open_table( path, disk, "rb", NULL );

   fcrel.relate_list = fcs_relate_list( library->fc[fcnum].name,
					start_table,end_table,
					fcs );

   if (ll_empty(fcrel.relate_list)) {
      ll_reset(fcrel.relate_list);
      displaymessage("ERROR in feature class relationship!",
		     start_table,end_table,NULL);
      return fcrel;
   }

   /* Find the number of tables in the relate chain */
   p = ll_first(fcrel.relate_list);
   fcrel.nchain = 0;
   while (!ll_end(p)) {
      fcrel.nchain++;
      p = ll_next(p);
   }
   /* Allow for last table2 */
   fcrel.nchain++;

   fcrel.table = (vpf_table_type *)
		  vpfmalloc((fcrel.nchain+1)*
			     sizeof(vpf_table_type));

   for (i=0;i<fcrel.nchain+1;i++)
      vpf_nullify_table( &(fcrel.table[i]) );


   p = ll_first(fcrel.relate_list);
   for (i=0;i<fcrel.nchain-1;i++) {

      ll_element(p,&rcell);

      /** Can't open primitive table - may be several under tile **/
      /** directories.  Open all others **/
      if (!is_primitive(rcell.table1)) {

	 sprintf(path,"%s%s",covpath,rcell.table1);
	 if (is_join(rcell.table1))
	    storage = ram;
	 else
	    storage = disk;

	 fcrel.table[i] = vpf_open_table(path,(storage_type)storage,"rb",NULL);

      }

      if (!ll_end(p)) p = ll_next(p);
   }

   /* End of relate chain */
   i = fcrel.nchain-1;
   if (!is_primitive(rcell.table2)) {

      sprintf(path,"%s%s",covpath,rcell.table2);
      storage = disk;

      fcrel.table[i] = vpf_open_table(path,(storage_type)storage,"rb",NULL);

   }


   vpf_close_table( &fcs );

   return fcrel;
}