Advertisement
kijato

OpenJump, BeanShell, DAT

May 31st, 2019
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.33 KB | None | 0 0
  1. Dat() {
  2.   filename = "";
  3.   header = "";
  4.   t_pont = new HashMap();
  5.   geometria = new HashMap();
  6.   /*geometria.put("point",new ArrayList());
  7.   geometria.put("linestring",null);
  8.   geometria.put("polgon",null);*/
  9.   try_it() {
  10.      print("The '"+this.geometria+"' is here!");
  11.   }
  12.   open(filename) {
  13.     // https://techknowstudy.wordpress.com/2015/03/10/reading-a-file-through-bean-shell/
  14.         fileReader=new FileReader(filename);
  15.     bufferReader= new BufferedReader(fileReader);
  16.     linenumber=0;
  17.         do {
  18.         line=bufferReader.readLine();
  19.         if (line!=null){
  20.             line  = line.trim().replaceAll("\\*$","");
  21.             if ( ++linenumber == 1 ) {
  22.                header = line;
  23.                continue;
  24.             }
  25.             if(line.startsWith("T_")) {
  26.                 table = line;
  27.                 geometria.put(table,new ArrayList());
  28.                 continue;
  29.             } else {/*
  30.                 String[] words = line.split("\\*");
  31.                 for(i=0;i<words.length;i++){
  32.                     print(words[i]+"\t");
  33.                 }*/
  34.                 geometria{table}.add(line);
  35.             }
  36.         }
  37.     } while(line!=null);
  38.     fileReader.close();
  39.     bufferReader.close();
  40.   }
  41.  
  42.   return this;
  43.  
  44. }
  45.  
  46.  
  47. {
  48.  
  49. dat = Dat();
  50. dat.open("q:\\OpenJUMP\\beanshell\\ck_proba.dat");
  51. print ( dat.header );
  52. for ( t : dat.geometria.keySet() ) {
  53.   print(t+": "+dat.geometria{t}.size());
  54.   for ( s : dat.geometria{t} ){
  55.      print("\t"+s);
  56.   }
  57. }
  58. print ("dump:\n"+dat.geometria );
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement