| | |
| | | package com.moral.util; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | u1 = 0; |
| | | v1 = wind_speed*1; |
| | | }else if (0<wind_direction&&wind_direction<90){ |
| | | u1 = wind_speed*Math.sin(wind_direction); |
| | | v1 = wind_speed*Math.cos(wind_direction); |
| | | u1 = wind_speed*Math.sin(Math.toRadians(wind_direction)); |
| | | v1 = wind_speed*Math.cos(Math.toRadians(wind_direction)); |
| | | }else if (wind_direction == 90){ |
| | | u1 = wind_speed*1; |
| | | v1 = 0; |
| | | }else if (90<wind_direction&&wind_direction<180){ |
| | | u1 = wind_speed*Math.sin(180-wind_direction); |
| | | v1 = -1*wind_speed*Math.cos(180-wind_direction); |
| | | u1 = wind_speed*Math.sin(Math.toRadians(180-wind_direction)); |
| | | v1 = -1*wind_speed*Math.cos(Math.toRadians(180-wind_direction)); |
| | | }else if (wind_direction == 180){ |
| | | u1 = 0; |
| | | v1 = wind_speed*-1; |
| | | }else if (180<wind_direction&&wind_direction<270){ |
| | | u1 = -1*wind_speed*Math.sin(wind_direction-180); |
| | | v1 = -1*wind_speed*Math.cos(wind_direction-180); |
| | | u1 = -1*wind_speed*Math.sin(Math.toRadians(wind_direction-180)); |
| | | v1 = -1*wind_speed*Math.cos(Math.toRadians(wind_direction-180)); |
| | | }else if (wind_direction == 270){ |
| | | u1 = wind_speed*-1; |
| | | v1 = 0; |
| | | }else if (270<wind_direction&&wind_direction<360){ |
| | | u1 = wind_speed*Math.sin(360-wind_direction); |
| | | v1 = -1*wind_speed*Math.cos(360-wind_direction); |
| | | u1 = wind_speed*Math.sin(Math.toRadians(360-wind_direction)); |
| | | v1 = -1*wind_speed*Math.cos(Math.toRadians(360-wind_direction)); |
| | | } |
| | | u = u+u1; |
| | | v = v+v1; |
| | |
| | | windDirectionSpeedMap.put("wind_speed",0.0); |
| | | }else if (u==0&&v>0){ |
| | | windDirectionSpeedMap.put("wind_direction",0.0); |
| | | windDirectionSpeedMap.put("wind_speed",v); |
| | | windDirectionSpeedMap.put("wind_speed",v/list.size()); |
| | | }else if (u>0&&v>0){ |
| | | windDirectionSpeedMap.put("wind_direction",Math.atan2(u,v)); |
| | | windDirectionSpeedMap.put("wind_speed",Math.sqrt(u*u+v*v)); |
| | | windDirectionSpeedMap.put("wind_direction",Math.toDegrees(Math.atan2(u,v))); |
| | | windDirectionSpeedMap.put("wind_speed",Math.sqrt(u*u+v*v)/list.size()); |
| | | }else if (u>0&&v==0){ |
| | | windDirectionSpeedMap.put("wind_direction",90.0); |
| | | windDirectionSpeedMap.put("wind_speed",u); |
| | | windDirectionSpeedMap.put("wind_speed",u/list.size()); |
| | | }else if (u>0&&v<0){ |
| | | windDirectionSpeedMap.put("wind_direction",Math.atan2(-v,u)+90); |
| | | windDirectionSpeedMap.put("wind_speed",Math.sqrt(u*u+v*v)); |
| | | windDirectionSpeedMap.put("wind_direction",Math.toDegrees(Math.atan2(-v,u))+90); |
| | | windDirectionSpeedMap.put("wind_speed",Math.sqrt(u*u+v*v)/list.size()); |
| | | }else if (u==0&&v<0){ |
| | | windDirectionSpeedMap.put("wind_direction",180.0); |
| | | windDirectionSpeedMap.put("wind_speed",-v); |
| | | windDirectionSpeedMap.put("wind_speed",Math.abs(v)/list.size()); |
| | | }else if (u<0&&v<0){ |
| | | windDirectionSpeedMap.put("wind_direction",Math.atan2(-u,-v)+180); |
| | | windDirectionSpeedMap.put("wind_speed",Math.sqrt(u*u+v*v)); |
| | | windDirectionSpeedMap.put("wind_direction",Math.toDegrees(Math.atan2(-u,-v))+180); |
| | | windDirectionSpeedMap.put("wind_speed",Math.sqrt(u*u+v*v)/list.size()); |
| | | }else if (u<0&&v==0){ |
| | | windDirectionSpeedMap.put("wind_direction",270.0); |
| | | windDirectionSpeedMap.put("wind_speed",-u); |
| | | windDirectionSpeedMap.put("wind_speed",Math.abs(u)/list.size()); |
| | | }else if (u<0&&v>0){ |
| | | windDirectionSpeedMap.put("wind_direction",Math.atan2(v,-u)+270); |
| | | windDirectionSpeedMap.put("wind_speed",Math.sqrt(u*u+v*v)); |
| | | windDirectionSpeedMap.put("wind_direction",Math.toDegrees(Math.atan2(v,-u))+270); |
| | | windDirectionSpeedMap.put("wind_speed",Math.sqrt(u*u+v*v)/list.size()); |
| | | } |
| | | return windDirectionSpeedMap; |
| | | } |
| | | |
| | | /*public static void main(String[] args) { |
| | | List list = new ArrayList(); |
| | | Map map = new HashMap(); |
| | | Map map2 = new HashMap(); |
| | | map.put("wind_direction",45); |
| | | map.put("wind_speed",1); |
| | | map2.put("wind_direction",45); |
| | | map2.put("wind_speed",1); |
| | | list.add(map); |
| | | list.add(map2); |
| | | Map<String, Double> re = getWind_direction_speed(list); |
| | | System.out.println(re); |
| | | System.out.println(Math.toRadians(45)); |
| | | System.out.println(Math.sin(Math.toRadians(45))); |
| | | System.out.println(Math.cos(Math.toRadians(45))); |
| | | }*/ |
| | | |
| | | } |