Skip to content

Commit

Permalink
update shape read function for optional measure data of PolylineZShape
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaqiang committed Jun 1, 2023
1 parent 62ff9c0 commit 81c824e
Show file tree
Hide file tree
Showing 28 changed files with 128 additions and 46 deletions.
2 changes: 1 addition & 1 deletion meteoinfo-chart/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>MeteoInfo</artifactId>
<groupId>org.meteothink</groupId>
<version>3.6-SNAPSHOT</version>
<version>3.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1726,6 +1726,68 @@ public static GraphicCollection3D createPolygons3D(Array xa, Array ya, Array za,
return graphics;
}

/**
* Create 3D polygons
*
* @param xa X coordinate array
* @param ya Y coordinate array
* @param za Z coordinate array
* @param pgbs PolygonBreak list
* @return Graphics
*/
public static GraphicCollection3D createPolygons3D(Array xa, Array ya, Array za, List<PolygonBreak> pgbs) {
xa = xa.copyIfView();
ya = ya.copyIfView();
za = za.copyIfView();

GraphicCollection3D graphics = new GraphicCollection3D();
double x, y, z;
int n = (int) xa.getSize();
PolygonZShape pgs;
PointZ p;
List<PointZ> points = new ArrayList<>();
if (xa.getRank() == 1) {
IndexIterator xIter = xa.getIndexIterator();
IndexIterator yIter = ya.getIndexIterator();
IndexIterator zIter = za.getIndexIterator();
int ii = 0;
while (xIter.hasNext()) {
x = xIter.getDoubleNext();
y = yIter.getDoubleNext();
z = zIter.getDoubleNext();
points.add(new PointZ(x, y, z));
}
if (points.size() > 2) {
points.add((PointZ) points.get(0).clone());
pgs = new PolygonZShape();
pgs.setPoints(points);
Graphic aGraphic = new Graphic(pgs, pgbs.get(ii));
graphics.add(aGraphic);
ii++;
}
} else {
int[] shape = xa.getShape();
int nRow = shape[0];
int nCol = shape[1];
int idx;
for (int i = 0; i < nCol; i++) {
points = new ArrayList<>();
for (int j = 0; j < nRow; j++) {
idx = j * nCol + i;
x = xa.getDouble(idx);
y = ya.getDouble(idx);
z = za.getDouble(idx);
points.add(new PointZ(x, y, z));
}
points.add((PointZ) points.get(0).clone());
pgs = new PolygonZShape();
pgs.setPoints(points);
graphics.add(new Graphic(pgs, pgbs.get(i)));
}
}
return graphics;
}

/**
* Add wireframe polylines
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2162,18 +2162,19 @@ protected void drawZAxis(GL2 gl, PointF loc) {
skip = getLabelGap(this.zAxis.getTickLabelFont(), tlabs, axisLen);
float x1 = x;
float y1 = y;
float tickLen = this.zAxis.getTickLength() * this.lenScale * transform.getYLength() / 2;
float yTickLen = this.zAxis.getTickLength() * this.lenScale * transform.getYLength() / 2;
float xTickLen = this.zAxis.getTickLength() * this.lenScale * transform.getXLength() / 2;
if (x < center.x) {
if (y > center.y) {
y1 += tickLen;
y1 += yTickLen;
} else {
x1 -= tickLen;
x1 -= xTickLen;
}
} else {
if (y > center.y) {
x1 += tickLen;
x1 += xTickLen;
} else {
y1 -= tickLen;
y1 -= yTickLen;
}
}
xAlign = XAlign.RIGHT;
Expand Down
2 changes: 1 addition & 1 deletion meteoinfo-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>MeteoInfo</artifactId>
<groupId>org.meteothink</groupId>
<version>3.6-SNAPSHOT</version>
<version>3.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class GlobalUtil {
public static String getVersion(){
String version = GlobalUtil.class.getPackage().getImplementationVersion();
if (version == null || version.equals("")) {
version = "3.6.0-beta1";
version = "3.6.0";
}
return version;
}
Expand Down
2 changes: 1 addition & 1 deletion meteoinfo-console/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>MeteoInfo</artifactId>
<groupId>org.meteothink</groupId>
<version>3.6-SNAPSHOT</version>
<version>3.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion meteoinfo-data/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>MeteoInfo</artifactId>
<groupId>org.meteothink</groupId>
<version>3.6-SNAPSHOT</version>
<version>3.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion meteoinfo-dataframe/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>MeteoInfo</artifactId>
<groupId>org.meteothink</groupId>
<version>3.6-SNAPSHOT</version>
<version>3.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion meteoinfo-geo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>MeteoInfo</artifactId>
<groupId>org.meteothink</groupId>
<version>3.6-SNAPSHOT</version>
<version>3.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
Expand Down Expand Up @@ -106,7 +107,7 @@ public static VectorLayer loadShapeFile(String shpfilepath, String encoding) thr
loadShxFile(shxFile);

//Open shp file
DataInputStream br = new DataInputStream(new BufferedInputStream(new FileInputStream(shpFile)));
DataInputStream br = new DataInputStream(new BufferedInputStream(Files.newInputStream(shpFile.toPath())));
VectorLayer aLayer;
//byte[] arr = new byte[(int)shpFile.length()];
byte[] arr = new byte[100];
Expand Down Expand Up @@ -394,11 +395,13 @@ private static VectorLayer readPolylineZShapes(DataInputStream br, int shapeNum)
}

//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();
if (buffer.position() < buffer.capacity()) {
double mmin = buffer.getDouble();
double mmax = buffer.getDouble();
for (int j = 0; j < numPoints; j++) {
mArray[j] = buffer.getDouble();
}
}

//Get pointZ list
Expand Down
2 changes: 1 addition & 1 deletion meteoinfo-geometry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>MeteoInfo</artifactId>
<groupId>org.meteothink</groupId>
<version>3.6-SNAPSHOT</version>
<version>3.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion meteoinfo-image/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>MeteoInfo</artifactId>
<groupId>org.meteothink</groupId>
<version>3.6-SNAPSHOT</version>
<version>3.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
20 changes: 10 additions & 10 deletions meteoinfo-lab/milconfig.xml
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<MeteoInfo File="milconfig.xml" Type="configurefile">
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\mesh">
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\patch"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite"/>
<Path OpenPath="D:\Working\MIScript\Jython\mis\map">
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite\FY"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\funny"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\awx"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\contour"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\grib"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\contour"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\mesh"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\contour"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\fill"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
</Path>
<File>
<OpenedFiles>
<OpenedFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\_reload.py"/>
<OpenedFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\mainGUI.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf\surfc_1.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\mesh\mesh_2.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\mesh\meshc_peaks.py"/>
<OpenedFile File="D:\Working\MIScript\Jython\mis\map\test_shaperead-2.py"/>
</OpenedFiles>
<RecentFiles>
<RecentFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\_reload.py"/>
<RecentFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\mainGUI.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf\surfc_1.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\mesh\mesh_2.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\mesh\meshc_peaks.py"/>
<RecentFile File="D:\Working\MIScript\Jython\mis\map\test_shaperead-2.py"/>
</RecentFiles>
</File>
<Font>
<TextFont FontName="YaHei Consolas Hybrid" FontSize="14"/>
</Font>
<LookFeel DockWindowDecorated="true" LafDecorated="true" Name="FlatDarkLaf"/>
<Figure DoubleBuffering="true"/>
<Startup MainFormLocation="-7,0" MainFormSize="1429,860"/>
<Startup MainFormLocation="-7,-7" MainFormSize="1293,685"/>
</MeteoInfo>
2 changes: 1 addition & 1 deletion meteoinfo-lab/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.meteothink</groupId>
<artifactId>MeteoInfo</artifactId>
<version>3.6-SNAPSHOT</version>
<version>3.6.0</version>
</parent>
<artifactId>meteoinfo-lab</artifactId>
<packaging>jar</packaging>
Expand Down
Binary file modified meteoinfo-lab/pylib/mipylib/plotlib/_axes3dgl$py.class
Binary file not shown.
22 changes: 17 additions & 5 deletions meteoinfo-lab/pylib/mipylib/plotlib/_axes3dgl.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,14 +368,26 @@ def fill(self, x, y, z, color=None, **kwargs):
:return: Filled 3D patches.
"""
if color is not None:
kwargs['facecolor'] = color
lbreak, isunique = plotutil.getlegendbreak('polygon', **kwargs)

x = plotutil.getplotdata(x)
y = plotutil.getplotdata(y)
z = plotutil.getplotdata(z)
graphics = GraphicFactory.createPolygons3D(x, y, z, lbreak)

lb, isunique = plotutil.getlegendbreak('polygon', **kwargs)
if color is None:
graphics = GraphicFactory.createPolygons3D(x, y, z, lb)
else:
alpha = kwargs.pop('alpha', None)
colors = plotutil.getcolors(color, alpha)
if len(colors) == 1:
lb.setColor(colors[0])
graphics = GraphicFactory.createPolygons3D(x, y, z, lb)
else:
lbs = []
for c in colors:
nlb = lb.clone()
nlb.setColor(c)
lbs.append(nlb)
graphics = GraphicFactory.createPolygons3D(x, y, z, lbs)

self.add_graphic(graphics)
return graphics
Expand Down
Binary file modified meteoinfo-lab/pylib/mipylib/plotlib/_glfigure$py.class
Binary file not shown.
4 changes: 4 additions & 0 deletions meteoinfo-lab/pylib/mipylib/plotlib/_glfigure.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,10 @@ def _add_axes(self, ax):
self.axes.append(ax)
self.getChart().addPlot(ax._axes)
self.getChart().setCurrentPlot(self.getChart().getPlots().size())
if isinstance(ax, Axes3DGL):
self.set_mousemode("rotate")
else:
self.set_mousemode("pan")

def remove_axes(self, ax=None):
"""
Expand Down
Binary file modified meteoinfo-lab/pylib/mipylib/plotlib/miplot$py.class
Binary file not shown.
6 changes: 3 additions & 3 deletions meteoinfo-lab/pylib/mipylib/plotlib/miplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1162,9 +1162,9 @@ def clf():
if g_figure is None:
return

if isinstance(g_figure, GLFigure):
delfig()
return
# if isinstance(g_figure, GLFigure):
# delfig()
# return

if g_figure.getChart() is None:
return
Expand Down
2 changes: 1 addition & 1 deletion meteoinfo-map/config.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<MeteoInfo File="config.xml" Type="configurefile">
<Path OpenPath="D:\Temp\nc"/>
<Path OpenPath="D:\Temp\test"/>
<Font>
<TextFont FontName="YaHei Consolas Hybrid" FontSize="14"/>
<LegendFont FontName="宋体" FontSize="12"/>
Expand Down
2 changes: 1 addition & 1 deletion meteoinfo-map/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.meteothink</groupId>
<artifactId>MeteoInfo</artifactId>
<version>3.6-SNAPSHOT</version>
<version>3.6.0</version>
</parent>
<artifactId>meteoinfo-map</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion meteoinfo-math/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>MeteoInfo</artifactId>
<groupId>org.meteothink</groupId>
<version>3.6-SNAPSHOT</version>
<version>3.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion meteoinfo-ndarray/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.meteothink</groupId>
<artifactId>MeteoInfo</artifactId>
<version>3.6-SNAPSHOT</version>
<version>3.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion meteoinfo-projection/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>MeteoInfo</artifactId>
<groupId>org.meteothink</groupId>
<version>3.6-SNAPSHOT</version>
<version>3.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion meteoinfo-table/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>MeteoInfo</artifactId>
<groupId>org.meteothink</groupId>
<version>3.6-SNAPSHOT</version>
<version>3.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion meteoinfo-ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>MeteoInfo</artifactId>
<groupId>org.meteothink</groupId>
<version>3.6-SNAPSHOT</version>
<version>3.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.meteothink</groupId>
<artifactId>MeteoInfo</artifactId>
<version>3.6-SNAPSHOT</version>
<version>3.6.0</version>
<packaging>pom</packaging>

<parent>
Expand Down

0 comments on commit 81c824e

Please sign in to comment.