clear() PopupMessage(" Welcome to topo50k program ver1.0!! \n\nYou must put a kanri*.prn file in your work directory. \n ex.D:/topo50k/. \n\nAnd, Please set a CD-ROM of Digital Map 50000(Map Image). ") rFile$ = GetInputFileName("", "Please, Select a kanri*.prn file. ex. kanriShikokuH12.prn ", "prn") printf("File Name is %s \n\n",rFile$) dir$ = GetDirectory("","Please, Select a Work Directory. ex.topo50k/") + "/" printf("Work Directory Name is %s \n\n",dir$) kanriname$ = FileNameGetName(rFile$) #printf("kanriname = %s \n",kanriname$) nagasa = strlen(kanriname$) #printf("nagasa = %d \n",nagasa) mapRegion$ = mid$( kanriname$ , 6 , nagasa - 5 ) #printf("mapRegion = %s \n",mapRegion$) prompt01$="Please, Input CD-ROM Drive name. ex.Q: " dirCD$ = PopupString(prompt01$,"Q:") # CD-ROM Drive print ("CD-ROM Drive is ", dirCD$) oFile$ = dir$ + "topo50k_"+mapRegion$+".rvc"; oFileDesc$ = "Topomap 1:50k, " + mapRegion$ numGCP = 4 array lonX[numGCP], latY[numGCP] array utmX[numGCP], utmY[numGCP], utmZ[numGCP] array imageL[numGCP], imageC[numGCP], mapZ[numGCP] class MieTIFF tiffHandle gll0 = GeorefAlloc(); gutm0 = GeorefAlloc() # Set Map Projection geonum1 = GeorefAlloc() class MAPPROJ projection; projection.System = "Latitude / Longitude"; projection.Datum = "Tokyo - Japan"; GeorefSetProjection(geonum1,projection) gll = GeorefGetParms(geonum1) #print("Specify 'Lat/Lon' w/ Tokyo") #gll = GeorefGetParms(gll0) #clear() # Set Map Projection geonum2 = GeorefAlloc() class MAPPROJ projection; projection.System = "Universal Transverse Mercator"; projection.Zone = "54 (E 138 to E 144)" projection.Datum = "Tokyo - Japan"; GeorefSetProjection(geonum2,projection) gutm = GeorefGetParms(geonum2) #print("Specify 'UTM 5x' w/ Tokyo") #gutm = GeorefGetParms(gutm0) clear() PopupMessage(" Ready? ") if(!fexists(oFile$)) CreateProjectFile(oFile$,oFileDesc$) rf = fopen(rFile$) buf$ = fgetline$(rf) k = 0 while(!feof(rf)) { k = k + 1 buf$ = fgetline$(rf) iObj0$ = mid$(buf$,1,6); mapNo$ = left$(iObj0$,4) + "/" iFile$ = dirCD$ + "/Data/" + mapNo$ + iObj0$ + ".tif"; oObj$ = "_" + iObj0$ oDesc$ = mid$(buf$,48,30) oMeta$ = mid$(buf$,78,48) lat = StrToNum(mid$(buf$,126,8)); lon = StrToNum(mid$(buf$,134,8)) GeorefTrans(gll,lon,lat,gutm,utmx,utmy) lonX[1] = lon; latY[1] = lat utmX[1] = utmx; utmY[1] = utmy lat = StrToNum(mid$(buf$,142,8)); lon = StrToNum(mid$(buf$,150,8)) GeorefTrans(gll,lon,lat,gutm,utmx,utmy) lonX[2] = lon; latY[2] = lat utmX[2] = utmx; utmY[2] = utmy lat = StrToNum(mid$(buf$,158,8)); lon = StrToNum(mid$(buf$,166,8)) GeorefTrans(gll,lon,lat,gutm,utmx,utmy) lonX[3] = lon; latY[3] = lat utmX[3] = utmx; utmY[3] = utmy lat = StrToNum(mid$(buf$,174,8)); lon = StrToNum(mid$(buf$,182,8)) GeorefTrans(gll,lon,lat,gutm,utmx,utmy) lonX[4] = lon; latY[4] = lat utmX[4] = utmx; utmY[4] = utmy imageC[1] = StrToNum(mid$(buf$,190,5)) imageL[1] = StrToNum(mid$(buf$,195,5)) imageC[2] = StrToNum(mid$(buf$,200,5)) imageL[2] = StrToNum(mid$(buf$,205,5)) imageC[3] = StrToNum(mid$(buf$,210,5)) imageL[3] = StrToNum(mid$(buf$,215,5)) imageC[4] = StrToNum(mid$(buf$,220,5)) imageL[4] = StrToNum(mid$(buf$,225,5)) mgnNW = StrToNum(mid$(buf$,232,1)) mgnN = StrToNum(mid$(buf$,233,1)) mgnNE = StrToNum(mid$(buf$,234,1)) mgnE = StrToNum(mid$(buf$,235,1)) mgnSE = StrToNum(mid$(buf$,236,1)) mgnS = StrToNum(mid$(buf$,237,1)) mgnSW = StrToNum(mid$(buf$,238,1)) mgnW = StrToNum(mid$(buf$,239,1)) print(k, oObj$, oDesc$) if(fexists(iFile$)) { ImportRaster(tiffHandle, iFile$, oFile$, oObj$, oDesc$) OpenRaster(O,oFile$,oObj$) CreateControlPointGeorefFromGeoref(O,gutm,numGCP,imageC,imageL,mapZ,utmX,utmY,utmZ) WriteMetaData(O,oMeta$) imageN1L = imageL[1] - 20; imageN2L = imageL[1] + 10 imageS1L = imageL[2] + 10; imageS2L = imageL[2] - 20 lon = (3*lonX[1]+lonX[4])/4; lat = latY[1] MapToObject(gll,lon,lat,O,x,y) imageC1 = x; imageL1 = y lon = (lonX[1]+lonX[4])/2; lat = latY[1] MapToObject(gll,lon,lat,O,x,y) imageC14 = x imageL14 = y lon = (lonX[1]+3*lonX[4])/4; lat = latY[1] MapToObject(gll,lon,lat,O,x,y) imageC4 = x imageL4 = y lon = (3*lonX[2]+lonX[3])/4; lat = latY[2] MapToObject(gll,lon,lat,O,x,y) imageC2 = x; imageL2 = y lon = (lonX[2]+lonX[3])/2; lat = latY[2] MapToObject(gll,lon,lat,O,x,y) imageC23 = x; imageL23 = y lon = (lonX[2]+3*lonX[3])/4; lat = latY[2] MapToObject(gll,lon,lat,O,x,y) imageC3 = x; imageL3 = y pW = (imageC[2]-imageC[1])/(imageL[2]-imageL[1]); qW = imageC[1] - pW*imageL[1] pE = (imageC[4]-imageC[3])/(imageL[4]-imageL[3]); qE = imageC[3] - pE*imageL[3] pNA = (imageL[1]-imageL1)/(imageC[1]-imageC1); qNA = imageL1 - pNA*imageC1 pNB = (imageL14-imageL1)/(imageC14-imageC1); qNB = imageL1 - pNB*imageC1 pNC = (imageL4-imageL14)/(imageC4-imageC14); qNC = imageL14 - pNC*imageC14 pND = (imageL4-imageL[4])/(imageC4-imageC[4]); qND = imageL[4] - pND*imageC[4] pSA = (imageL[2]-imageL2)/(imageC[2]-imageC2); qSA = imageL2 - pSA*imageC2 pSB = (imageL2-imageL23)/(imageC2-imageC23); qSB = imageL23 - pSB*imageC23 pSC = (imageL23-imageL3)/(imageC23-imageC3); qSC = imageL3 - pSC*imageC3 pSD = (imageL3-imageL[3])/(imageC3-imageC[3]); qSD = imageL[3] - pSD*imageC[3] for each O[y,x] { if(x < pW*y + qW) { if(y < pNA*x + qNA) {if(!mgnNW) O[y,x] = 0} else if(y <= pSA*x + qSA) {if(!mgnW) O[y,x] = 0} else {if(!mgnSW) O[y,x] = 0} } else if(x <= pE*y + qE) { if(y < imageN1L) {if(!mgnN) O[y,x] = 0} else if(y < imageN2L) { if(!mgnN) { if(x < imageC14) { if(x < imageC1) {if(y < pNA*x + qNA) O[y,x] = 0} else {if(y < pNB*x + qNB) O[y,x] = 0} } else { if(x < imageC4) {if(y < pNC*x + qNC) O[y,x] = 0} else {if(y < pND*x + qND) O[y,x] = 0} } } } else if(y > imageS1L) {if(!mgnS) O[y,x] = 0} else if(y > imageS2L) { if(!mgnS) { if(x < imageC23) { if(x < imageC2) {if(y > pSA*x + qSA) O[y,x] = 0} else {if(y > pSB*x + qSB) O[y,x] = 0} } else { if(x < imageC3) {if(y > pSC*x + qSC) O[y,x] = 0} else {if(y > pSD*x + qSD) O[y,x] = 0} } } } } else { if(y < pND*x + qND) {if(!mgnNE) O[y,x] = 0} else if(y <= pSD*x + qSD) {if(!mgnE) O[y,x] = 0} else {if(!mgnSE) O[y,x] = 0} } } SetNull(O,0) CreateHistogram(O) DeletePyramid(O) CreatePyramid(O) CloseRaster(O) } else { print(" ",iFile$," not exists!") } } fclose(rf) PopupMessage(" Finished!! ")