RDX2
X
shp2kml source $function(dfobject,dfparam,dflegend){ +#input filename & fieldname& document label +FileName<-dfobject["FileName"]#set filename .FieldName<-dfobject["FieldName"]#use fieldname 3FieldLabel<-dfobject["FieldLabel"]#Documenttag name LegendCmt<-dflegend["Legendcmt"] 5FieldLabelutf8<-iconv(FieldLabel,"shift-jis","utf-8") 9FieldLabelsjis<-iconv(FieldLabelutf8,"utf-8","shift-jis") HostIp<-dfobject["HostIp"] "UniqueCode<-dfobject["uniquecode"] 1UniqueFileName<-paste(UniqueCode,"result",sep="") #filename :dFileName<-paste(FileName,"DATA",sep="")#set datafile name -cFileName<-"Legend16" #legend table file name BlFileName<-paste(uniquecode,"legend",sep="")#legend imagefile name #path 3Ipath<-"c:/Program Files/R/rwww/geroot/shapefiles/" ,Opath<-"c:/Program Files/R/rwww/geroot/kml/" -Dpath<-"c:/Program Files/R/rwww/geroot/data/" 3Cpath<-"c:/Program Files/R/rwww/geroot/etc/legend/" 3Lpath<-"c:/Program Files/R/rwww/geroot/etc/legend/" AL2path<-paste("http://",HostIp,"/rwww/geroot/etc/legend/",sep="") =inpFileName<-paste(Ipath,FileName,"/",FileName,".shp",sep="") 6outFileName<-paste(Opath,UniqueFileName,".kml",sep="") 1datFileName<-paste(Dpath,dFileName,".csv",sep="") 1colFileName<-paste(Cpath,cFileName,".csv",sep="") 1LegFileName<-paste(Lpath,lFileName,".jpg",sep="") 3LegFileName2<-paste(L2path,lFileName,".jpg",sep="") #default param ?PolygonColor<-dfparam["PolygonColor"]#polygon color( aabbggrr ) .LineColor<-dfparam["LineColor"]#polyline color (fill<-dfparam["fill"]#polygon fill param 1outline<-dfparam["outline"]#polygon outline param *Latitude<-dfparam["Latitude"]#LookAt param ,Longitude<-dfparam["Longitude"]#LookAt param $Range<-dfparam["Range"]#LookAt param 7Altitude<-dfparam["Altitude"]#coordinates param(height) PRelativeToGround<-dfparam["RelativeToGround"]#AltitudeMode aram relativeToGround DAltitudeMode<-c("",RelativeToGround,"") ,tessellate<-"1"#??? #load fillcolor table options(digits=10) !ColorTable<-read.csv(colFileName) cols1<-ColorTable$LEGCOL ,cols2<-paste("#",as.character(cols1),sep="") Ncls1text<-paste("cls1<-sprintf('%5.1f',ColorTable$CLS1_",FieldName,")",sep="") eval(parse(text=cls1text)) Ncls2text<-paste("cls2<-sprintf('%5.1f',ColorTable$CLS2_",FieldName,")",sep="") eval(parse(text=cls2text)) :cls3text<-paste("cls3<-ColorTable$CLS3_",FieldName,sep="") eval(parse(text=cls3text)) )clsname<-paste(cls1,"-",cls2,cls3,sep="") colsno<-length(cols2) >jpeg(LegFileName,width=160,height=350,bg="black",pointsize=10) par(mai=c(0,0,0,0)) plot(1:5,0:4,ann=F,type='n') Xlegend(1,4,clsname,fill=cols2,title=FieldLabelsjis,bg="black",text.col="white",cex=1.3,) &text(3,0,labels=LegendCmt,col="white") #load fillcolor table "#ColorTable<-read.csv(colFileName) 5CT<-paste("cols<-ColorTable$PGCLR_",FieldName,sep="") eval(parse(text=CT)) "cols<-rev(cols)#Invert ColorVector colsno<-length(cols) #make kmltag #XML&KML parse 5xml.version<-"" :kml.xmlns<-"" ","",FieldLabelutf8,"") DPrefectureH<-c("","",FileName," Prefecture","") 3FolderH<-c("","","Polygon","") #screen overlay Legend<-"Legend" #ScreenOverlay kScreenOverlay<-c("","",Legend,"","","",Legend,"","","",LegFileName2,"","","","","","","") #KML header&footer