Skip to content

Commit

Permalink
release 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
wyq committed Aug 24, 2014
1 parent ef96938 commit 1d33f39
Show file tree
Hide file tree
Showing 60 changed files with 6,954 additions and 173 deletions.
419 changes: 419 additions & 0 deletions src/org/meteoinfo/chart/data/general/Series.java

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions src/org/meteoinfo/chart/data/general/SeriesChangeEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ----------------------
* SeriesChangeEvent.java
* ----------------------
* (C) Copyright 2001-2008, by Object Refinery Limited.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 15-Nov-2001 : Version 1 (DG);
* 18-Aug-2003 : Implemented Serializable (DG);
*
*/

package org.meteoinfo.chart.data.general;

import java.io.Serializable;
import java.util.EventObject;

/**
* An event with details of a change to a series.
*/
public class SeriesChangeEvent extends EventObject implements Serializable {

/** For serialization. */
private static final long serialVersionUID = 1593866085210089052L;

/**
* Constructs a new event.
*
* @param source the source of the change event.
*/
public SeriesChangeEvent(Object source) {
super(source);
}

}
59 changes: 59 additions & 0 deletions src/org/meteoinfo/chart/data/general/SeriesChangeListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -------------------------
* SeriesChangeListener.java
* -------------------------
* (C) Copyright 2001-2008, by Object Refinery Limited.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 15-Nov-2001 : Version 1 (DG);
* 26-Jun-2003 : Now extends EventListener so we can use the EventListenerList
* mechanism (DG);
*
*/

package org.meteoinfo.chart.data.general;

import java.util.EventListener;

/**
* Methods for receiving notification of changes to a data series.
*/
public interface SeriesChangeListener extends EventListener {

/**
* Called when an observed series changes in some way.
*
* @param event information about the change.
*/
public void seriesChanged(SeriesChangeEvent event);

}
8 changes: 6 additions & 2 deletions src/org/meteoinfo/data/GridData.java
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,12 @@ public double toStation(double x, double y) {
*/
public StationData toStation(StationData stData) {
StationData nstData = new StationData(stData);
for (int i = 0; i < nstData.getStNum(); i++) {
nstData.setValue(i, this.toStation(nstData.getX(i), nstData.getY(i)));
if (this.projInfo.equals(stData.projInfo)){
for (int i = 0; i < nstData.getStNum(); i++) {
nstData.setValue(i, this.toStation(nstData.getX(i), nstData.getY(i)));
}
} else {
nstData = this.project(projInfo, stData.projInfo, stData, ResampleMethods.Bilinear);
}

return nstData;
Expand Down
10 changes: 9 additions & 1 deletion src/org/meteoinfo/data/StationData.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ public class StationData {
/// Undef data
/// </summary>
public double missingValue;
/**
* Projection information
*/
public ProjectionInfo projInfo = null;
// </editor-fold>
// <editor-fold desc="Constructor">

Expand All @@ -79,11 +83,12 @@ public StationData() {
* @param aStData Station data
*/
public StationData(StationData aStData) {
projInfo = aStData.projInfo;
stations = aStData.stations;
dataExtent = aStData.dataExtent;
missingValue = aStData.missingValue;
data = new double[aStData.data.length][aStData.data[0].length];
for (int i = 0; i < getStNum(); i++) {
for (int i = 0; i < aStData.getStNum(); i++) {
data[i][0] = aStData.data[i][0];
data[i][1] = aStData.data[i][1];
}
Expand Down Expand Up @@ -153,6 +158,7 @@ public StationData add(StationData bStData) {
}

StationData cStData = new StationData();
cStData.projInfo = bStData.projInfo;
String aStid;
int stIdx;
double x, y;
Expand Down Expand Up @@ -191,6 +197,7 @@ public StationData add(StationData bStData) {
*/
public StationData add(double value) {
StationData cStData = new StationData();
cStData.projInfo = this.projInfo;
String aStid;
double x, y;
for (int i = 0; i < stations.size(); i++) {
Expand Down Expand Up @@ -760,6 +767,7 @@ public void saveAsCSVFile(String fileName, String fieldName, boolean saveMissing
*/
public StationData maskout(PolygonShape polygonShape) {
StationData stData = new StationData();
stData.projInfo = this.projInfo;
stData.missingValue = this.missingValue;
for (int i = 0; i < this.getStNum(); i++) {
if (GeoComputation.pointInPolygon(polygonShape, new PointD(this.getX(i), this.getY(i)))) {
Expand Down
2 changes: 1 addition & 1 deletion src/org/meteoinfo/data/mapdata/AttributeTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ private DataRow readTableRowFromBytes(int currentRow) throws Exception {
dBuffer = Arrays.copyOfRange(cBuffer, 6, 8);
tempString = new String(dBuffer);
int day = Integer.parseInt(tempString);
Calendar cal = new GregorianCalendar(year, month, day);
Calendar cal = new GregorianCalendar(year, month - 1, day);
tempObject = cal.getTime();
break;
case 'F':
Expand Down
5 changes: 3 additions & 2 deletions src/org/meteoinfo/data/mapdata/MapDataManage.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import javax.imageio.ImageIO;
import javax.swing.JOptionPane;
import org.meteoinfo.data.meteodata.bandraster.BILDataInfo;
import org.meteoinfo.global.DataConvert;
import org.meteoinfo.global.table.DataColumn;
import org.meteoinfo.layer.RasterLayer;
import org.meteoinfo.legend.LegendScheme;
Expand Down Expand Up @@ -158,9 +159,9 @@ public static VectorLayer readMapFile_GrADS(String aFile) throws FileNotFoundExc
continue;
}
b = br.readByte(); // Line type: country, river ...
lType = b;
lType = (short) DataConvert.byte2Int(b);
b = br.readByte(); // Point number
N = b;
N = (short) DataConvert.byte2Int(b);
for (i = 0; i < N; i++) {
bytes = new byte[3];
br.read(bytes); //Longitude
Expand Down
79 changes: 79 additions & 0 deletions src/org/meteoinfo/data/mapdata/ShapeFileManage.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
import org.meteoinfo.projection.ProjectionInfo;
import org.meteoinfo.projection.proj4j.CRSFactory;
import org.meteoinfo.projection.proj4j.CoordinateReferenceSystem;
import org.meteoinfo.shape.PointM;
import org.meteoinfo.shape.PolygonMShape;

/**
* Shape file read and write
Expand Down Expand Up @@ -133,6 +135,9 @@ public static VectorLayer loadShapeFile(String shpfilepath) throws IOException,
case Polygon: //Polygon layer
aLayer = readPolygonShapes(br, shapeNum);
break;
case PolygonM:
aLayer = readPolygonMShapes(br, shapeNum);
break;
default:
return null;
}
Expand Down Expand Up @@ -422,6 +427,80 @@ private static VectorLayer readPolygonShapes(DataInputStream br, int shapeNum) t

return aLayer;
}

private static VectorLayer readPolygonMShapes(DataInputStream br, int shapeNum) throws IOException {
VectorLayer aLayer = new VectorLayer(ShapeTypes.Polygon);
int RecordNum, ContentLength, aShapeType;
double x, y;
byte[] bytes;
ByteBuffer buffer;

for (int i = 0; i < shapeNum; i++) {
//br.skipBytes(12);
bytes = new byte[8];
br.read(bytes);
buffer = ByteBuffer.wrap(bytes);
//br.skipBytes(12);
buffer.order(ByteOrder.BIG_ENDIAN);
RecordNum = buffer.getInt();
ContentLength = buffer.getInt();

bytes = new byte[ContentLength * 2];
br.read(bytes);
buffer = ByteBuffer.wrap(bytes);
buffer.order(ByteOrder.LITTLE_ENDIAN);
aShapeType = buffer.getInt();

PolygonMShape aSPG = new PolygonMShape();
Extent extent = new Extent();
extent.minX = buffer.getDouble();
extent.minY = buffer.getDouble();
extent.maxX = buffer.getDouble();
extent.maxY = buffer.getDouble();
aSPG.setExtent(extent);
aSPG.setPartNum(buffer.getInt());
int numPoints = buffer.getInt();
aSPG.parts = new int[aSPG.getPartNum()];
List<PointD> points = new ArrayList<PointD>();

//firstly read out parts begin pos in file
for (int j = 0; j < aSPG.getPartNum(); j++) {
aSPG.parts[j] = buffer.getInt();
}

//read out coordinates
for (int j = 0; j < numPoints; j++) {
x = buffer.getDouble();
y = buffer.getDouble();
PointD aPoint = new PointD();
aPoint.X = x;
aPoint.Y = y;
points.add(aPoint);
}

//Read measure
double mmin = buffer.getDouble();
double mmax = buffer.getDouble();
double[] mArray = new double[numPoints];
for (int j = 0; j < numPoints; j++) {
mArray[j] = buffer.getDouble();
}

//Get pointM list
List<PointM> pointMs = new ArrayList<PointM>();
for (int j = 0; j < numPoints; j++) {
pointMs.add(new PointM(points.get(j).X, points.get(j).Y, mArray[j]));
}

aSPG.setPoints(pointMs);
aLayer.addShape(aSPG);
}

//Create legend scheme
aLayer.setLegendScheme(LegendManage.createSingleSymbolLegendScheme(ShapeTypes.Polygon, new Color(255, 251, 195), 1.0F));

return aLayer;
}

private static void loadShxFile(File shxFile) throws FileNotFoundException, IOException {
DataInputStream bridx = new DataInputStream(new BufferedInputStream(new FileInputStream(shxFile)));
Expand Down
40 changes: 28 additions & 12 deletions src/org/meteoinfo/data/meteodata/MeteoDataInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -680,30 +680,44 @@ public GridData getGridData() {
return null;
}

GridData gdata = null;
switch (_dimensionSet) {
case Lat_Lon:
return ((IGridDataInfo) _dataInfo).getGridData_LonLat(_timeIdx, _varIdx, _levelIdx);
gdata = ((IGridDataInfo) _dataInfo).getGridData_LonLat(_timeIdx, _varIdx, _levelIdx);
break;
case Time_Lon:
return ((IGridDataInfo) _dataInfo).getGridData_TimeLon(_latIdx, _varIdx, _levelIdx);
gdata = ((IGridDataInfo) _dataInfo).getGridData_TimeLon(_latIdx, _varIdx, _levelIdx);
break;
case Time_Lat:
return ((IGridDataInfo) _dataInfo).getGridData_TimeLat(_lonIdx, _varIdx, _levelIdx);
gdata = ((IGridDataInfo) _dataInfo).getGridData_TimeLat(_lonIdx, _varIdx, _levelIdx);
break;
case Level_Lon:
return ((IGridDataInfo) _dataInfo).getGridData_LevelLon(_latIdx, _varIdx, _timeIdx);
gdata = ((IGridDataInfo) _dataInfo).getGridData_LevelLon(_latIdx, _varIdx, _timeIdx);
break;
case Level_Lat:
return ((IGridDataInfo) _dataInfo).getGridData_LevelLat(_lonIdx, _varIdx, _timeIdx);
gdata = ((IGridDataInfo) _dataInfo).getGridData_LevelLat(_lonIdx, _varIdx, _timeIdx);
break;
case Level_Time:
return ((IGridDataInfo) _dataInfo).getGridData_LevelTime(_latIdx, _varIdx, _lonIdx);
gdata = ((IGridDataInfo) _dataInfo).getGridData_LevelTime(_latIdx, _varIdx, _lonIdx);
break;
case Lat:
return ((IGridDataInfo) _dataInfo).getGridData_Lat(_timeIdx, _lonIdx, _varIdx, _levelIdx);
gdata = ((IGridDataInfo) _dataInfo).getGridData_Lat(_timeIdx, _lonIdx, _varIdx, _levelIdx);
break;
case Level:
return ((IGridDataInfo) _dataInfo).getGridData_Level(_lonIdx, _latIdx, _varIdx, _timeIdx);
gdata = ((IGridDataInfo) _dataInfo).getGridData_Level(_lonIdx, _latIdx, _varIdx, _timeIdx);
break;
case Lon:
return ((IGridDataInfo) _dataInfo).getGridData_Lon(_timeIdx, _latIdx, _varIdx, _levelIdx);
gdata = ((IGridDataInfo) _dataInfo).getGridData_Lon(_timeIdx, _latIdx, _varIdx, _levelIdx);
break;
case Time:
return ((IGridDataInfo) _dataInfo).getGridData_Time(_lonIdx, _latIdx, _varIdx, _levelIdx);
default:
return null;
gdata = ((IGridDataInfo) _dataInfo).getGridData_Time(_lonIdx, _latIdx, _varIdx, _levelIdx);
break;
}

if (gdata != null)
gdata.projInfo = this.getProjectionInfo();

return gdata;
}

/**
Expand All @@ -720,6 +734,7 @@ public StationData getStationData(String varName) {
MathParser mathParser = new MathParser(this);
try {
StationData stationData = (StationData) mathParser.evaluate(varName);
stationData.projInfo = this.getProjectionInfo();
return stationData;
} catch (ParseException ex) {
Logger.getLogger(MeteoDataInfo.class.getName()).log(Level.SEVERE, null, ex);
Expand All @@ -739,6 +754,7 @@ public StationData getStationData(String varName) {
public StationData getStationData() {
if (_varIdx >= 0) {
StationData stData = ((IStationDataInfo) _dataInfo).getStationData(_timeIdx, _varIdx, _levelIdx);
stData.projInfo = this.getProjectionInfo();
return stData;
} else {
return null;
Expand Down
Loading

0 comments on commit 1d33f39

Please sign in to comment.