Skip to content

Commit

Permalink
normal
Browse files Browse the repository at this point in the history
  • Loading branch information
wyq committed Sep 16, 2014
1 parent 1d33f39 commit b04eaef
Show file tree
Hide file tree
Showing 63 changed files with 1,593 additions and 93 deletions.
16 changes: 14 additions & 2 deletions src/org/meteoinfo/data/DataMath.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,13 @@ public static StationData div_1(double value, StationData stData) {

// </editor-fold>
// <editor-fold desc="Wind U/V">
private static double[] getUVFromDS(double windDir, double windSpeed) {
/**
* Get wind U/V from wind direction/speed
* @param windDir The wind direction
* @param windSpeed The wind speed
* @return Wind U/V
*/
public static double[] getUVFromDS(double windDir, double windSpeed) {
double dir = windDir + 180;
if (dir > 360) {
dir = dir - 360;
Expand Down Expand Up @@ -324,7 +330,13 @@ public static StationData[] getUVFromDS(StationData windDirData, StationData win
return new StationData[]{uData, vData};
}

private static double[] getDSFromUV(double U, double V) {
/**
* Get wind direction/speed from U/V
* @param U The U value
* @param V The V value
* @return Wind direction/speed array
*/
public static double[] getDSFromUV(double U, double V) {
double windSpeed = Math.sqrt(U * U + V * V);
double windDir;
if (windSpeed == 0) {
Expand Down
16 changes: 16 additions & 0 deletions src/org/meteoinfo/data/mapdata/Field.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,22 @@ public char getTypeCharacter() {
return 'C';
}
}

/**
* If the field is numeric
* @return Boolean
*/
public boolean isNumeric(){
switch (this.getDataType()){
case Integer:
case Float:
case Double:
case Decimal:
return true;
default:
return false;
}
}
// </editor-fold>
// <editor-fold desc="Methods">

Expand Down
3 changes: 3 additions & 0 deletions src/org/meteoinfo/data/meteodata/DrawMeteoData.java
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,7 @@ public static VectorLayer createSTPointLayer(StationData stationData, LegendSche
aLayer.setLayerName(LName);
aLS.setFieldName(fieldName);
aLayer.setLegendScheme((LegendScheme) aLS.clone());
aLayer.setAvoidCollision(true);
aLayer.setLayerDrawType(LayerDrawType.StationPoint);

return aLayer;
Expand Down Expand Up @@ -756,6 +757,7 @@ public static VectorLayer createSTInfoLayer(StationInfoData stInfoData, LegendSc

aLayer.setLayerName(layerName);
aLayer.setLegendScheme(aLS);
aLayer.setAvoidCollision(true);
aLayer.setLayerDrawType(LayerDrawType.StationPoint);

return aLayer;
Expand Down Expand Up @@ -1168,6 +1170,7 @@ public static VectorLayer createStationModelLayer(StationModelData stationModelD
aLayer.setLayerName(layerName);
aLS.setFieldName("");
aLayer.setLegendScheme(aLS);
aLayer.setAvoidCollision(true);
aLayer.setLayerDrawType(LayerDrawType.StationModel);

return aLayer;
Expand Down
5 changes: 5 additions & 0 deletions src/org/meteoinfo/data/meteodata/MeteoDataInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import org.meteoinfo.data.meteodata.micaps.MICAPS11DataInfo;
import org.meteoinfo.data.meteodata.micaps.MICAPS120DataInfo;
import org.meteoinfo.data.meteodata.micaps.MICAPS13DataInfo;
import org.meteoinfo.data.meteodata.micaps.MICAPS7DataInfo;
import org.meteoinfo.data.meteodata.mm5.MM5DataInfo;
Expand Down Expand Up @@ -341,6 +342,7 @@ public boolean isStationData() {
case MICAPS_1:
case MICAPS_2:
case MICAPS_3:
case MICAPS_120:
case LonLatStation:
case SYNOP:
case HYSPLIT_Particle:
Expand Down Expand Up @@ -626,6 +628,9 @@ public void openMICAPSData(String fileName) {
case MICAPS_13:
_dataInfo = new MICAPS13DataInfo();
break;
case MICAPS_120:
_dataInfo = new MICAPS120DataInfo();
break;
}
_dataInfo.readDataInfo(fileName);
_infoText = _dataInfo.generateInfoText();
Expand Down
23 changes: 22 additions & 1 deletion src/org/meteoinfo/data/meteodata/MeteoDataType.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public enum MeteoDataType {
/// MICAPS 13
/// </summary>
MICAPS_13,
MICAPS_120,
/// <summary>
/// HYSPLIT concentration
/// </summary>
Expand Down Expand Up @@ -120,5 +121,25 @@ public enum MeteoDataType {
HRIT,
MM5,
MM5IM,
BIL
BIL;

/**
* If is MICAPS data
* @return Is or not MICAPS data
*/
public boolean isMICAPS(){
switch (this){
case MICAPS_1:
case MICAPS_2:
case MICAPS_3:
case MICAPS_4:
case MICAPS_7:
case MICAPS_11:
case MICAPS_13:
case MICAPS_120:
return true;
default:
return false;
}
}
}
2 changes: 1 addition & 1 deletion src/org/meteoinfo/data/meteodata/Variable.java
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public void setYDimension(Dimension value) {
*
* @return Z dimension
*/
public Dimension getZDimension() {
public Dimension getZDimension() {
return getDimension(DimensionType.Z);
}

Expand Down
8 changes: 8 additions & 0 deletions src/org/meteoinfo/data/meteodata/grads/GrADSDataInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -2091,6 +2091,14 @@ public StationModelData getStationModelData(int timeIdx, int levelIdx) {
// </editor-fold>

// <editor-fold desc="Write data">
/**
* Add a time
* @param time The time
*/
public void addTime(Date time){
this.TDEF.times.add(time);
}

/**
* Write GrADS control file
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import org.meteoinfo.legend.LegendType;
import org.meteoinfo.shape.PointShape;
import org.meteoinfo.shape.PointZ;
import org.meteoinfo.shape.PolylineShape;
import org.meteoinfo.shape.PolylineZShape;
import org.meteoinfo.shape.ShapeTypes;

Expand Down Expand Up @@ -254,13 +253,15 @@ public String generateInfoText() {

@Override
public VectorLayer createTrajLineLayer() {
VectorLayer aLayer = new VectorLayer(ShapeTypes.Polyline);
VectorLayer aLayer = new VectorLayer(ShapeTypes.PolylineZ);
aLayer.editAddField(new Field("TrajID", DataTypes.Integer));
aLayer.editAddField(new Field("StartDate", DataTypes.String));
aLayer.editAddField(new Field("StartDate", DataTypes.Date));
aLayer.editAddField(new Field("StartHour", DataTypes.Integer));
aLayer.editAddField(new Field("StartLon", DataTypes.Double));
aLayer.editAddField(new Field("StartLat", DataTypes.Double));
aLayer.editAddField(new Field("StartHeight", DataTypes.Double));

Calendar cal = Calendar.getInstance();
int TrajNum = 0;
for (int t = 0; t < fileNames.size(); t++) {
try {
Expand Down Expand Up @@ -329,7 +330,7 @@ public VectorLayer createTrajLineLayer() {
PointList.get(TrajIdx).add(aPoint);
}

SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHH");
//SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHH");
for (i = 0; i < trajeoryNums.get(t); i++) {
PolylineZShape aPolyline = new PolylineZShape();
TrajNum += 1;
Expand All @@ -339,8 +340,10 @@ public VectorLayer createTrajLineLayer() {

int shapeNum = aLayer.getShapeNum();
if (aLayer.editInsertShape(aPolyline, shapeNum)) {
cal.setTime(trajInfos.get(t).get(i).startTime);
aLayer.editCellValue("TrajID", shapeNum, TrajNum);
aLayer.editCellValue("StartDate", shapeNum, format.format(trajInfos.get(t).get(i).startTime));
aLayer.editCellValue("StartDate", shapeNum, cal.getTime());
aLayer.editCellValue("StartHour", shapeNum, cal.get(Calendar.HOUR_OF_DAY));
aLayer.editCellValue("StartLat", shapeNum, trajInfos.get(t).get(i).startLat);
aLayer.editCellValue("StartLon", shapeNum, trajInfos.get(t).get(i).startLon);
aLayer.editCellValue("StartHeight", shapeNum, trajInfos.get(t).get(i).startHeight);
Expand Down
Loading

0 comments on commit b04eaef

Please sign in to comment.