void loadKoreanFiles(const char *id) { strcpy(_gameID, id); if(!strncasecmp2(_gameID, "monkeyega", 9)) strcpy(_gameID, "monkey"); if(!strncasecmp2(_gameID, "monkeyvga", 9)) strcpy(_gameID, "monkey"); if(!strncasecmp2(_gameID, "monkey1", 7)) strcpy(_gameID, "monkey"); if(!strncasecmp2(_gameID, "indy3ega", 8)) strcpy(_gameID, "indy3"); //loadEmergencyFont(); loadKoreanStrings(); }
double findunit(char *unit) { struct unitkey { char *name; double value; } unitkeytab[] = { "CM", 39.37, "CENTIMETER", 39.37, "CENTIMETERS", 39.37, /** # of inches * 100 in unit **/ "METER", 3937, "METERS", 3937, "KM", 3937000, "KILOMETER", 3937000, "KILOMETERS", 3937000, "INCH", 100, "INCHES", 100, "FEET", 1200, "FOOT", 1200, "YARD", 3600, "YARDS", 3600, "MILE", 6336000, "MILES", 6336000 }; double unitfactor=0; for (j = 0; j < NKEYS; j++) { if (strncasecmp2(unit, unitkeytab[j].name, 0) == 0) unitfactor=unitkeytab[j].value; } return(unitfactor); }
char *convertToKoreanValid(const char *buf, bool descFlag) { static int currentLine; char *tbuf, *sbuf; bool found = 0; sbuf = tbuf = _parseBuffer; if(buf[0] == 0x07 && descFlag) *buf++; /* if (buf[0] == 'Y' && buf[1] == 'e' && buf[2] == 's') { printf("convertToKoreanValid buf = <%s>\n", buf); } */ int i; for(i = currentLine; i < _numKLines; i += 2) { if(!strncasecmp2(buf, _KBuffer[i], strlen(_KBuffer[i])) && strlen(_KBuffer[i]) == strlen(buf)) { strcpy(tbuf, _KBuffer[i + 1]); currentLine = i; found = 1; break; } } if(found == 0) { for(i = 0; i < currentLine/*_numKLines*/; i += 2) { //한번 더 찾아 줌 if(!strncasecmp2(buf, _KBuffer[i], strlen(_KBuffer[i])) && strlen(_KBuffer[i]) == strlen(buf)) { strcpy(tbuf, _KBuffer[i + 1]); currentLine = i; found = 1; break; } } } // 못 찾으면 null return if (found == 0) return 0; return sbuf; }
void findselect() { /* Find the select field name */ iselectitem = -1; for( i = 0; i < ti && iselectitem < 0; i++ ) { iType = DBFGetFieldInfo( hDBF, i, iszTitle, &iWidth, &iDecimals ); if (strncasecmp2(iszTitle, selectitem, 0) == 0) iselectitem = i; } if (iselectitem == -1) { printf("Warning: Item not found for selection (%s)\n",selectitem); iselect = FALSE; iall = FALSE; showitems(); printf("Continued... (Selecting entire file)\n"); } /* Extract all of the select values (by field type) */ }
char *convertToKorean(const char *buf, bool descFlag) { static int currentLine; char *tbuf, *sbuf; bool found = 0; sbuf = tbuf = _parseBuffer; /* bool mFlg; mFlg = 0; for(int mi = 0; mi < xxi; mi++) { if(!strncasecmp(buf, strBuf[mi], strlen(buf))){ mFlg = 1; break; } } if(!mFlg) { strcpy(strBuf[xxi], buf); xxi++; fprintf(korOutput, "%s\n", buf); } // 임시 파일에 저장 */ if(buf[0] == 0x07 && descFlag) *buf++; /* if (buf[0] == 'Y' && buf[1] == 'e' && buf[2] == 's') { printf("convertToKoreanValid buf = <%s>\n", buf); } */ int i; for(i = currentLine; i < _numKLines; i += 2) { if(!strncasecmp2(buf, _KBuffer[i], strlen(_KBuffer[i])) && strlen(_KBuffer[i]) == strlen(buf)) { strcpy(tbuf, _KBuffer[i + 1]); currentLine = i; found = 1; break; } } if(found == 0) { for(i = 0; i < currentLine; i += 2) { // 한번 더 찾아줌 if(!strncasecmp2(buf, _KBuffer[i], strlen(_KBuffer[i])) && strlen(_KBuffer[i]) == strlen(buf)) { strcpy(tbuf, _KBuffer[i + 1]); currentLine = i; found = 1; break; } } } if(found == 0 && descFlag) { if(_highRes) strcpy(tbuf, buf); else *tbuf = 0; } else if(found == 0) if(_koreanOnly) { strcpy(tbuf, buf); // 못 찾으면 영어 문장으로 대체 while(*tbuf){ if(!strncasecmp2(tbuf, "<1>", strlen("<1>"))) { *tbuf = '\\'; *(tbuf + 1) = '\\'; *(tbuf + 2) = 'n'; } if(!strncasecmp2(buf, "<3>", strlen("<3>"))) { *tbuf = '\\'; *(tbuf + 1) = '\\'; *(tbuf + 2) = 'n'; } if(!strncasecmp2(tbuf, "<c>", strlen("<c>"))) { *tbuf = '\\'; *(tbuf +1) = '\\'; *(tbuf +2) = 'c'; } tbuf++; } tbuf = sbuf; } else *tbuf = 0; // 영어 문장 안나올 때만 대체 return sbuf; }
void showitems() { char stmp[40],slow[40],shigh[40]; double dtmp,dlow,dhigh,dsum,mean; long int itmp,ilow,ihigh,isum; long int maxrec; char *pt; printf("Available Items: (%d)",ti); maxrec = DBFGetRecordCount(hDBF); if (maxrec > 5000 && ! iall) { maxrec=5000; printf(" ** ESTIMATED RANGES (MEAN) For more records use \"All\""); } else { printf(" RANGES (MEAN)"); } for( i = 0; i < ti; i++ ) { switch( DBFGetFieldInfo( hDBF, i, iszTitle, &iWidth, &iDecimals ) ) { case FTString: case FTLogical: strcpy(slow, "~"); strcpy(shigh,"\0"); printf("\n String %3d %-16s",iWidth,iszTitle); for( iRecord = 0; iRecord < maxrec; iRecord++ ) { strncpy(stmp,DBFReadStringAttribute( hDBF, iRecord, i ),39); if (strcmp(stmp,"!!") > 0) { if (strncasecmp2(stmp,slow,0) < 0) strncpy(slow, stmp,39); if (strncasecmp2(stmp,shigh,0) > 0) strncpy(shigh,stmp,39); } } pt=slow+strlen(slow)-1; while(*pt == ' ') { *pt='\0'; pt--; } pt=shigh+strlen(shigh)-1; while(*pt == ' ') { *pt='\0'; pt--; } if (strncasecmp2(slow,shigh,0) < 0) printf("%s to %s",slow,shigh); else if (strncasecmp2(slow,shigh,0) == 0) printf("= %s",slow); else printf("No Values"); break; case FTInteger: printf("\n Integer %3d %-16s",iWidth,iszTitle); ilow = 1999999999; ihigh= -1999999999; isum = 0; for( iRecord = 0; iRecord < maxrec; iRecord++ ) { itmp = DBFReadIntegerAttribute( hDBF, iRecord, i ); if (ilow > itmp) ilow = itmp; if (ihigh < itmp) ihigh = itmp; isum = isum + itmp; } mean=isum/maxrec; if (ilow < ihigh) printf("%ld to %ld \t(%.1f)",ilow,ihigh,mean); else if (ilow == ihigh) printf("= %ld",ilow); else printf("No Values"); break; case FTDouble: printf("\n Real %3d,%d %-16s",iWidth,iDecimals,iszTitle); dlow = 999999999999999.0; dhigh= -999999999999999.0; dsum = 0; for( iRecord = 0; iRecord < maxrec; iRecord++ ) { dtmp = DBFReadDoubleAttribute( hDBF, iRecord, i ); if (dlow > dtmp) dlow = dtmp; if (dhigh < dtmp) dhigh = dtmp; dsum = dsum + dtmp; } mean=dsum/maxrec; sprintf(stmp,"%%.%df to %%.%df \t(%%.%df)",iDecimals,iDecimals,iDecimals); if (dlow < dhigh) printf(stmp,dlow,dhigh,mean); else if (dlow == dhigh) { sprintf(stmp,"= %%.%df",iDecimals); printf(stmp,dlow); } else printf("No Values"); break; case FTInvalid: break; } } printf("\n"); }
int main( int argc, char ** argv ) { /* -------------------------------------------------------------------- */ /* Check command line usage. */ /* -------------------------------------------------------------------- */ if( argc < 2 ) error(); strcpy(infile, argv[1]); if (argc > 2) { strcpy(outfile,argv[2]); if (strncasecmp2(outfile, "LIST",0) == 0) { ilist = TRUE; } if (strncasecmp2(outfile, "ALL",0) == 0) { iall = TRUE; } } if (ilist || iall || argc == 2 ) { setext(infile, "shp"); printf("DESCRIBE: %s\n",infile); strcpy(outfile,""); } /* -------------------------------------------------------------------- */ /* Look for other functions on the command line. (SELECT, UNIT) */ /* -------------------------------------------------------------------- */ for (i = 3; i < argc; i++) { if ((strncasecmp2(argv[i], "SEL",3) == 0) || (strncasecmp2(argv[i], "UNSEL",5) == 0)) { if (strncasecmp2(argv[i], "UNSEL",5) == 0) iunselect=TRUE; i++; if (i >= argc) error(); strcpy(selectitem,argv[i]); i++; if (i >= argc) error(); selcount=0; strcpy(temp,argv[i]); cpt=temp; tj = atoi(cpt); ti = 0; while (tj>0) { selectvalues[selcount] = tj; while( *cpt >= '0' && *cpt <= '9') cpt++; while( *cpt > '\0' && (*cpt < '0' || *cpt > '9') ) cpt++; tj=atoi(cpt); selcount++; } iselect=TRUE; } /*** End SEL & UNSEL ***/ else if ((strncasecmp2(argv[i], "CLIP",4) == 0) || (strncasecmp2(argv[i], "ERASE",5) == 0)) { if (strncasecmp2(argv[i], "ERASE",5) == 0) ierase=TRUE; i++; if (i >= argc) error(); strcpy(clipfile,argv[i]); sscanf(argv[i],"%lf",&cxmin); i++; if (i >= argc) error(); if (strncasecmp2(argv[i], "BOUND",5) == 0) { setext(clipfile, "shp"); hSHP = SHPOpen( clipfile, "rb" ); if( hSHP == NULL ) { printf( "ERROR: Unable to open the clip shape file:%s\n", clipfile ); exit( 1 ); } SHPGetInfo( hSHPappend, NULL, NULL, adfBoundsMin, adfBoundsMax ); cxmin = adfBoundsMin[0]; cymin = adfBoundsMin[1]; cxmax = adfBoundsMax[0]; cymax = adfBoundsMax[1]; printf("Theme Clip Boundary: (%lf,%lf) - (%lf,%lf)\n", cxmin, cymin, cxmax, cymax); ibound=TRUE; } else { /*** xmin,ymin,xmax,ymax ***/ sscanf(argv[i],"%lf",&cymin); i++; if (i >= argc) error(); sscanf(argv[i],"%lf",&cxmax); i++; if (i >= argc) error(); sscanf(argv[i],"%lf",&cymax); printf("Clip Box: (%lf,%lf) - (%lf,%lf)\n",cxmin, cymin, cxmax, cymax); } i++; if (i >= argc) error(); if (strncasecmp2(argv[i], "CUT",3) == 0) icut=TRUE; else if (strncasecmp2(argv[i], "TOUCH",5) == 0) itouch=TRUE; else if (strncasecmp2(argv[i], "INSIDE",6) == 0) iinside=TRUE; else error(); iclip=TRUE; } /*** End CLIP & ERASE ***/ else if (strncasecmp2(argv[i], "FACTOR",0) == 0) { i++; if (i >= argc) error(); infactor=findunit(argv[i]); if (infactor == 0) error(); iunit=TRUE; i++; if (i >= argc) error(); outfactor=findunit(argv[i]); if (outfactor == 0) { sscanf(argv[i],"%lf",&factor); if (factor == 0) error(); } if (factor == 0) { if (infactor ==0) { puts("ERROR: Input unit must be defined before output unit"); exit(1); } factor=infactor/outfactor; } printf("Output file coordinate values will be factored by %lg\n",factor); ifactor=(factor != 1); /* True if a valid factor */ } /*** End FACTOR ***/ else if (strncasecmp2(argv[i],"SHIFT",5) == 0) { i++; if (i >= argc) error(); sscanf(argv[i],"%lf",&xshift); i++; if (i >= argc) error(); sscanf(argv[i],"%lf",&yshift); iunit=TRUE; printf("X Shift: %lg Y Shift: %lg\n",xshift,yshift); } /*** End SHIFT ***/ else { printf("ERROR: Unknown function %s\n",argv[i]); error(); } } /* -------------------------------------------------------------------- */ /* If there is no data in this file let the user know. */ /* -------------------------------------------------------------------- */ openfiles(); /* Open the infile and the outfile for shape and dbf. */ if( DBFGetFieldCount(hDBF) == 0 ) { puts( "There are no fields in this table!" ); exit( 1 ); } /* -------------------------------------------------------------------- */ /* Print out the file bounds. */ /* -------------------------------------------------------------------- */ iRecord = DBFGetRecordCount( hDBF ); SHPGetInfo( hSHP, NULL, NULL, adfBoundsMin, adfBoundsMax ); printf( "Input Bounds: (%lg,%lg) - (%lg,%lg) Entities: %d DBF: %d\n", adfBoundsMin[0], adfBoundsMin[1], adfBoundsMax[0], adfBoundsMax[1], nEntities, iRecord ); if (strcmp(outfile,"") == 0) /* Describe the shapefile; No other functions */ { ti = DBFGetFieldCount( hDBF ); showitems(); exit(0); } if (iclip) check_theme_bnd(); jRecord = DBFGetRecordCount( hDBFappend ); SHPGetInfo( hSHPappend, NULL, NULL, adfBoundsMin, adfBoundsMax ); if (nEntitiesAppend == 0) puts("New Output File\n"); else printf( "Append Bounds: (%lg,%lg)-(%lg,%lg) Entities: %d DBF: %d\n", adfBoundsMin[0], adfBoundsMin[1], adfBoundsMax[0], adfBoundsMax[1], nEntitiesAppend, jRecord ); /* -------------------------------------------------------------------- */ /* Find matching fields in the append file or add new items. */ /* -------------------------------------------------------------------- */ mergefields(); /* -------------------------------------------------------------------- */ /* Find selection field if needed. */ /* -------------------------------------------------------------------- */ if (iselect) findselect(); /* -------------------------------------------------------------------- */ /* Read all the records */ /* -------------------------------------------------------------------- */ jRecord = DBFGetRecordCount( hDBFappend ); for( iRecord = 0; iRecord < nEntities; iRecord++) /** DBFGetRecordCount(hDBF) **/ { /* -------------------------------------------------------------------- */ /* SELECT for values if needed. (Can the record be skipped.) */ /* -------------------------------------------------------------------- */ if (iselect) if (selectrec() == 0) goto SKIP_RECORD; /** SKIP RECORD **/ /* -------------------------------------------------------------------- */ /* Read a Shape record */ /* -------------------------------------------------------------------- */ psCShape = SHPReadObject( hSHP, iRecord ); /* -------------------------------------------------------------------- */ /* Clip coordinates of shapes if needed. */ /* -------------------------------------------------------------------- */ if (iclip) if (clip_boundary() == 0) goto SKIP_RECORD; /** SKIP RECORD **/ /* -------------------------------------------------------------------- */ /* Read a DBF record and copy each field. */ /* -------------------------------------------------------------------- */ for( i = 0; i < DBFGetFieldCount(hDBF); i++ ) { /* -------------------------------------------------------------------- */ /* Store the record according to the type and formatting */ /* information implicit in the DBF field description. */ /* -------------------------------------------------------------------- */ if (pt[i] > -1) /* if the current field exists in output file */ { switch( DBFGetFieldInfo( hDBF, i, NULL, &iWidth, &iDecimals ) ) { case FTString: case FTLogical: DBFWriteStringAttribute(hDBFappend, jRecord, pt[i], (DBFReadStringAttribute( hDBF, iRecord, i )) ); break; case FTInteger: DBFWriteIntegerAttribute(hDBFappend, jRecord, pt[i], (DBFReadIntegerAttribute( hDBF, iRecord, i )) ); break; case FTDouble: DBFWriteDoubleAttribute(hDBFappend, jRecord, pt[i], (DBFReadDoubleAttribute( hDBF, iRecord, i )) ); break; case FTInvalid: break; } } } jRecord++; /* -------------------------------------------------------------------- */ /* Change FACTOR and SHIFT coordinates of shapes if needed. */ /* -------------------------------------------------------------------- */ if (iunit) { for( j = 0; j < psCShape->nVertices; j++ ) { psCShape->padfX[j] = psCShape->padfX[j] * factor + xshift; psCShape->padfY[j] = psCShape->padfY[j] * factor + yshift; } } /* -------------------------------------------------------------------- */ /* Write the Shape record after recomputing current extents. */ /* -------------------------------------------------------------------- */ SHPComputeExtents( psCShape ); SHPWriteObject( hSHPappend, -1, psCShape ); SKIP_RECORD: SHPDestroyObject( psCShape ); psCShape = NULL; j=0; } /* -------------------------------------------------------------------- */ /* Print out the # of Entities and the file bounds. */ /* -------------------------------------------------------------------- */ jRecord = DBFGetRecordCount( hDBFappend ); SHPGetInfo( hSHPappend, &nEntitiesAppend, &nShapeTypeAppend, adfBoundsMin, adfBoundsMax ); printf( "Output Bounds: (%lg,%lg) - (%lg,%lg) Entities: %d DBF: %d\n\n", adfBoundsMin[0], adfBoundsMin[1], adfBoundsMax[0], adfBoundsMax[1], nEntitiesAppend, jRecord ); /* -------------------------------------------------------------------- */ /* Close the both shapefiles. */ /* -------------------------------------------------------------------- */ SHPClose( hSHP ); SHPClose( hSHPappend ); DBFClose( hDBF ); DBFClose( hDBFappend ); if (nEntitiesAppend == 0) { puts("Remove the output files."); setext(outfile, "dbf"); remove(outfile); setext(outfile, "shp"); remove(outfile); setext(outfile, "shx"); remove(outfile); } return( 0 ); }