zoukankan      html  css  js  c++  java
  • Kettle 使用Json输入

     import java.math.BigDecimal;
     private static final String JD="jd";
     private static final String WD="wd";
    
     public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException{
            if(first) {
                first = false;
            }
            Object[] r = getRow();
            if (r == null) {
                setOutputDone();
                return false;
            }
    
            //维度
            String wdstr = get(Fields.In, WD).getString(r);
            //经度
            String jdstr = get(Fields.In, JD).getString(r);
            if(!isArray(wdstr)||!isArray(jdstr)){
               return true;
            }
            get(Fields.Out, WD).setValue(r, getCovNewVlaue(wdstr));
            get(Fields.Out, JD).setValue(r, getCovNewVlaue(jdstr));
    
            putRow(data.outputRowMeta, r);
            return true;
      }
    
     private double getCovNewVlaue(String dustr) {
            String replace =  dustr.replace("N", "").replace("E", "");
            String[] duArray = replace.split(" ");
            double duValue = Double.parseDouble(duArray[0]);
            double minuteValue = Double.parseDouble(duArray[1]);
            double secondValue = Double.parseDouble(duArray[2]);
    
            BigDecimal minute = BigDecimal.valueOf(minuteValue).divide(BigDecimal.valueOf(60), 10,
                    BigDecimal.ROUND_HALF_DOWN);
            BigDecimal second = BigDecimal.valueOf(secondValue).divide(BigDecimal.valueOf(3600), 10,
                    BigDecimal.ROUND_HALF_DOWN);
            BigDecimal newVlaue = BigDecimal.valueOf(duValue).add(minute).add(second);
            return newVlaue.doubleValue();
        }
    
     private boolean isArray(String dustr){
            return dustr.split(" ").length==1?false:true;
     }

  • 相关阅读:
    List装form
    《Java设计模式》之调停者模式(Mediator)
    android 4.0 禁用系统home键
    最大权二分匹配
    hdu 3667 /2010哈尔滨赛区H题 费用与流量为非线性关系/费用流
    【python】filter()
    【python】linux将python改为默认3.4版本
    【linux】VMware12.0安装
    【python】lxml-The E-factory
    【xml】python的lxml库使用
  • 原文地址:https://www.cnblogs.com/justuntil/p/8349628.html
Copyright © 2011-2022 走看看