mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
support long math operators
This commit is contained in:
parent
c3f4e3b526
commit
570f28d5e2
@ -25,6 +25,7 @@ import org.meteoinfo.chart.shape.TextureShape;
|
||||
import org.meteoinfo.common.*;
|
||||
import org.meteoinfo.common.colors.ColorMap;
|
||||
import org.meteoinfo.data.Dataset;
|
||||
import org.meteoinfo.projection.GeoTransform;
|
||||
import org.meteoinfo.render.java2d.Draw;
|
||||
import org.meteoinfo.render.java2d.StringType;
|
||||
import org.meteoinfo.geometry.colors.BoundaryNorm;
|
||||
@ -1126,6 +1127,12 @@ public class GLPlot extends Plot {
|
||||
* @param graphic Graphic
|
||||
*/
|
||||
public void addGraphic(Graphic graphic) {
|
||||
org.meteoinfo.geometry.graphic.Transform transform = graphic.getTransform();
|
||||
if (transform != null && transform.isValid()) {
|
||||
GeoTransform geoTransform = (GeoTransform) transform;
|
||||
GraphicProjectionUtil.projectClipGraphic(graphic, geoTransform.getSourceProj(),
|
||||
geoTransform.getTargetProj());
|
||||
}
|
||||
this.graphics.add(graphic);
|
||||
Extent ex = this.graphics.getExtent();
|
||||
if (!ex.is3D()) {
|
||||
@ -1146,6 +1153,12 @@ public class GLPlot extends Plot {
|
||||
* @param graphic Graphic
|
||||
*/
|
||||
public void addGraphic(int index, Graphic graphic) {
|
||||
org.meteoinfo.geometry.graphic.Transform transform = graphic.getTransform();
|
||||
if (transform != null && transform.isValid()) {
|
||||
GeoTransform geoTransform = (GeoTransform) transform;
|
||||
GraphicProjectionUtil.projectClipGraphic(graphic, geoTransform.getSourceProj(),
|
||||
geoTransform.getTargetProj());
|
||||
}
|
||||
this.graphics.add(index, graphic);
|
||||
Extent ex = this.graphics.getExtent();
|
||||
if (!ex.is3D()) {
|
||||
|
||||
@ -289,14 +289,13 @@ package org.meteoinfo.geometry.graphic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get graphic list
|
||||
* @return Graphic list
|
||||
*//*
|
||||
public List<Graphic> getGraphics() {
|
||||
List<Graphic> gs = new ArrayList<>();
|
||||
gs.add(this);
|
||||
return gs;
|
||||
}*/
|
||||
* Transform the graphic
|
||||
*/
|
||||
public void doTransform() {
|
||||
if (this.transform != null && this.transform.isValid()) {
|
||||
this.transform.transform(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateResizeAbility() {
|
||||
if (shape != null && legend != null) {
|
||||
|
||||
@ -9,4 +9,6 @@ public abstract class Transform {
|
||||
public abstract PointD transform(double x, double y);
|
||||
|
||||
public abstract Transform inverted();
|
||||
|
||||
public abstract Graphic transform(Graphic graphic);
|
||||
}
|
||||
|
||||
@ -1,32 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\pcolor">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\arrow"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\matlab"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo\calc"/>
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\io\netcdf">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\interpolate"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\scatter"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map\geoshow"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\wind"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\contour"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\pcolor"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\geoshow"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\netcdf"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\scatter\scatterm_2.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\scatter\scatter_map_proj.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\contour\contourf_hatch.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\netcdf\test_sub.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\scatter\scatterm_2.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\scatter\scatter_map_proj.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\contour\contourf_hatch.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\netcdf\test_sub.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
|
||||
Binary file not shown.
@ -17,6 +17,7 @@ from org.meteoinfo.chart.jogl import GLPlot, GLForm, JOGLUtil, EarthGLPlot, MapG
|
||||
from org.meteoinfo.math.interpolate import InterpolationMethod
|
||||
from org.meteoinfo.image import ImageUtil
|
||||
from org.meteoinfo.common import Extent3D
|
||||
from org.meteoinfo.projection import GeoTransform
|
||||
from javax.swing import WindowConstants
|
||||
from java.awt import Font, Color
|
||||
from java.awt.image import BufferedImage
|
||||
@ -960,8 +961,11 @@ class Axes3DGL(Axes3D):
|
||||
|
||||
visible = kwargs.pop('visible', True)
|
||||
if visible:
|
||||
projection = kwargs.pop('projection', layer.getProjInfo())
|
||||
self.add_graphic(graphics, projection)
|
||||
data_proj = kwargs.pop('transform', layer.getProjInfo())
|
||||
transform = GeoTransform(data_proj, self.projection)
|
||||
graphics.transform = transform
|
||||
self.add_graphic(graphics)
|
||||
|
||||
return graphics
|
||||
|
||||
def plot_layer(self, layer, **kwargs):
|
||||
|
||||
@ -278,6 +278,9 @@ public class ArrayMath {
|
||||
case UINT:
|
||||
case BOOLEAN:
|
||||
return ArrayMath.addInt(a, b);
|
||||
case LONG:
|
||||
case ULONG:
|
||||
return ArrayMath.addLong(a, b);
|
||||
case FLOAT:
|
||||
return ArrayMath.addFloat(a, b);
|
||||
case DOUBLE:
|
||||
@ -305,6 +308,9 @@ public class ArrayMath {
|
||||
case UINT:
|
||||
case BOOLEAN:
|
||||
return ArrayMath.addInt(a, b.intValue());
|
||||
case LONG:
|
||||
case ULONG:
|
||||
return ArrayMath.addLong(a, b.longValue());
|
||||
case FLOAT:
|
||||
return ArrayMath.addFloat(a, b.floatValue());
|
||||
case DOUBLE:
|
||||
@ -412,6 +418,87 @@ public class ArrayMath {
|
||||
return r;
|
||||
}
|
||||
|
||||
private static Array addLong(Array a, Array b) {
|
||||
int broadcast = broadcastCheck(a, b);
|
||||
switch (broadcast) {
|
||||
case 0:
|
||||
Array r = Array.factory(DataType.LONG, a.getShape());
|
||||
if (a.getIndexPrivate().isFastIterator() && b.getIndexPrivate().isFastIterator()) {
|
||||
long va, vb;
|
||||
for (int i = 0; i < r.getSize(); i++) {
|
||||
va = a.getLong(i);
|
||||
vb = b.getLong(i);
|
||||
if (va == Long.MIN_VALUE || vb == Long.MIN_VALUE) {
|
||||
r.setLong(i, Long.MIN_VALUE);
|
||||
} else {
|
||||
r.setLong(i, va + vb);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
IndexIterator iterR = r.getIndexIterator();
|
||||
IndexIterator iterA = a.getIndexIterator();
|
||||
IndexIterator iterB = b.getIndexIterator();
|
||||
long va, vb;
|
||||
while (iterA.hasNext()) {
|
||||
va = iterA.getLongNext();
|
||||
vb = iterB.getLongNext();
|
||||
if (va == Long.MIN_VALUE || vb == Long.MIN_VALUE) {
|
||||
iterR.setLongNext(Long.MIN_VALUE);
|
||||
} else {
|
||||
iterR.setLongNext(va + vb);
|
||||
}
|
||||
}
|
||||
}
|
||||
return r;
|
||||
case 1:
|
||||
int[] shape = broadcast(a, b);
|
||||
r = Array.factory(DataType.LONG, shape);
|
||||
Index index = r.getIndex();
|
||||
Index aindex = a.getIndex();
|
||||
Index bindex = b.getIndex();
|
||||
int n = r.getRank();
|
||||
int na = a.getRank();
|
||||
int nb = b.getRank();
|
||||
int[] current;
|
||||
for (int i = 0; i < r.getSize(); i++) {
|
||||
current = index.getCurrentCounter();
|
||||
setIndex(aindex, bindex, current, n, na, nb);
|
||||
if (a.getLong(aindex) == Long.MIN_VALUE || b.getLong(bindex) == Long.MIN_VALUE) {
|
||||
r.setLong(i, Long.MIN_VALUE);
|
||||
} else {
|
||||
r.setLong(i, a.getLong(aindex) + b.getLong(bindex));
|
||||
}
|
||||
index.incr();
|
||||
}
|
||||
return r;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Array addLong(Array a, long b) {
|
||||
Array r = Array.factory(DataType.LONG, a.getShape());
|
||||
if (a.getIndexPrivate().isFastIterator()) {
|
||||
for (int i = 0; i < r.getSize(); i++) {
|
||||
r.setLong(i, a.getInt(i) + b);
|
||||
}
|
||||
} else {
|
||||
IndexIterator iterR = r.getIndexIterator();
|
||||
IndexIterator iterA = a.getIndexIterator();
|
||||
long v;
|
||||
while (iterA.hasNext()) {
|
||||
v = iterA.getLongNext();
|
||||
if (v == Long.MIN_VALUE) {
|
||||
iterR.setLongNext(Long.MIN_VALUE);
|
||||
} else {
|
||||
iterR.setLongNext(v + b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
private static Array addFloat(Array a, Array b) {
|
||||
int broadcast = broadcastCheck(a, b);
|
||||
switch (broadcast) {
|
||||
@ -668,6 +755,9 @@ public class ArrayMath {
|
||||
case UINT:
|
||||
case BOOLEAN:
|
||||
return ArrayMath.subInt(a, b);
|
||||
case LONG:
|
||||
case ULONG:
|
||||
return ArrayMath.subLong(a, b);
|
||||
case FLOAT:
|
||||
return ArrayMath.subFloat(a, b);
|
||||
case DOUBLE:
|
||||
@ -698,6 +788,9 @@ public class ArrayMath {
|
||||
case UINT:
|
||||
case BOOLEAN:
|
||||
return ArrayMath.subInt(a, b.intValue());
|
||||
case LONG:
|
||||
case ULONG:
|
||||
return ArrayMath.subLong(a, b.longValue());
|
||||
case FLOAT:
|
||||
return ArrayMath.subFloat(a, b.floatValue());
|
||||
case DOUBLE:
|
||||
@ -739,6 +832,9 @@ public class ArrayMath {
|
||||
case UINT:
|
||||
case BOOLEAN:
|
||||
return ArrayMath.subInt(b.intValue(), a);
|
||||
case LONG:
|
||||
case ULONG:
|
||||
return ArrayMath.subLong(b.longValue(), a);
|
||||
case FLOAT:
|
||||
return ArrayMath.subFloat(b.floatValue(), a);
|
||||
case DOUBLE:
|
||||
@ -837,6 +933,80 @@ public class ArrayMath {
|
||||
return r;
|
||||
}
|
||||
|
||||
private static Array subLong(Array a, Array b) {
|
||||
int broadcast = broadcastCheck(a, b);
|
||||
switch (broadcast) {
|
||||
case 0:
|
||||
Array r = Array.factory(DataType.LONG, a.getShape());
|
||||
if (a.getIndexPrivate().isFastIterator() && b.getIndexPrivate().isFastIterator()) {
|
||||
for (int i = 0; i < a.getSize(); i++) {
|
||||
r.setLong(i, a.getLong(i) - b.getLong(i));
|
||||
}
|
||||
} else {
|
||||
IndexIterator iterA = a.getIndexIterator();
|
||||
IndexIterator iterB = b.getIndexIterator();
|
||||
IndexIterator iterR = r.getIndexIterator();
|
||||
while (iterA.hasNext()) {
|
||||
iterR.setLongNext(iterA.getLongNext() - iterB.getLongNext());
|
||||
}
|
||||
}
|
||||
return r;
|
||||
case 1:
|
||||
int[] shape = broadcast(a, b);
|
||||
r = Array.factory(DataType.LONG, shape);
|
||||
Index index = r.getIndex();
|
||||
Index aindex = a.getIndex();
|
||||
Index bindex = b.getIndex();
|
||||
int n = r.getRank();
|
||||
int na = a.getRank();
|
||||
int nb = b.getRank();
|
||||
int[] current;
|
||||
for (int i = 0; i < r.getSize(); i++) {
|
||||
current = index.getCurrentCounter();
|
||||
setIndex(aindex, bindex, current, n, na, nb);
|
||||
r.setLong(i, a.getLong(aindex) - b.getLong(bindex));
|
||||
index.incr();
|
||||
}
|
||||
return r;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Array subLong(Array a, long b) {
|
||||
Array r = Array.factory(DataType.INT, a.getShape());
|
||||
if (a.getIndexPrivate().isFastIterator()) {
|
||||
for (int i = 0; i < a.getSize(); i++) {
|
||||
r.setLong(i, a.getLong(i) - b);
|
||||
}
|
||||
} else {
|
||||
IndexIterator iterA = a.getIndexIterator();
|
||||
IndexIterator iterR = r.getIndexIterator();
|
||||
while (iterA.hasNext()) {
|
||||
iterR.setLongNext(iterA.getLongNext() - b);
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
private static Array subLong(long b, Array a) {
|
||||
Array r = Array.factory(DataType.LONG, a.getShape());
|
||||
if (a.getIndexPrivate().isFastIterator()) {
|
||||
for (int i = 0; i < a.getSize(); i++) {
|
||||
r.setLong(i, b - a.getLong(i));
|
||||
}
|
||||
} else {
|
||||
IndexIterator iterA = a.getIndexIterator();
|
||||
IndexIterator iterR = r.getIndexIterator();
|
||||
while (iterA.hasNext()) {
|
||||
iterR.setLongNext(b - iterA.getLongNext());
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
private static Array subFloat(Array a, Array b) {
|
||||
int broadcast = broadcastCheck(a, b);
|
||||
switch (broadcast) {
|
||||
@ -1175,6 +1345,9 @@ public class ArrayMath {
|
||||
case UINT:
|
||||
case BOOLEAN:
|
||||
return ArrayMath.mulInt(a, b);
|
||||
case LONG:
|
||||
case ULONG:
|
||||
return ArrayMath.mulLong(a, b);
|
||||
case FLOAT:
|
||||
return ArrayMath.mulFloat(a, b);
|
||||
case DOUBLE:
|
||||
@ -1202,6 +1375,9 @@ public class ArrayMath {
|
||||
case UINT:
|
||||
case BOOLEAN:
|
||||
return ArrayMath.mulInt(a, b.intValue());
|
||||
case LONG:
|
||||
case ULONG:
|
||||
return ArrayMath.mulLong(a, b.longValue());
|
||||
case FLOAT:
|
||||
return ArrayMath.mulFloat(a, b.floatValue());
|
||||
case DOUBLE:
|
||||
@ -1306,6 +1482,87 @@ public class ArrayMath {
|
||||
return r;
|
||||
}
|
||||
|
||||
private static Array mulLong(Array a, Array b) {
|
||||
int broadcast = broadcastCheck(a, b);
|
||||
switch (broadcast) {
|
||||
case 0:
|
||||
Array r = Array.factory(DataType.LONG, a.getShape());
|
||||
if (a.getIndexPrivate().isFastIterator() && b.getIndexPrivate().isFastIterator()) {
|
||||
long va, vb;
|
||||
for (int i = 0; i < r.getSize(); i++) {
|
||||
va = a.getLong(i);
|
||||
vb = b.getLong(i);
|
||||
if (va == Long.MIN_VALUE || vb == Long.MIN_VALUE) {
|
||||
r.setLong(i, Long.MIN_VALUE);
|
||||
} else {
|
||||
r.setLong(i, va * vb);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
IndexIterator iterR = r.getIndexIterator();
|
||||
IndexIterator iterA = a.getIndexIterator();
|
||||
IndexIterator iterB = b.getIndexIterator();
|
||||
long va, vb;
|
||||
while (iterA.hasNext()) {
|
||||
va = iterA.getLongNext();
|
||||
vb = iterB.getLongNext();
|
||||
if (va == Long.MIN_VALUE || vb == Long.MIN_VALUE) {
|
||||
iterR.setLongNext(Long.MIN_VALUE);
|
||||
} else {
|
||||
iterR.setLongNext(va * vb);
|
||||
}
|
||||
}
|
||||
}
|
||||
return r;
|
||||
case 1:
|
||||
int[] shape = broadcast(a, b);
|
||||
r = Array.factory(DataType.LONG, shape);
|
||||
Index index = r.getIndex();
|
||||
Index aindex = a.getIndex();
|
||||
Index bindex = b.getIndex();
|
||||
int n = r.getRank();
|
||||
int na = a.getRank();
|
||||
int nb = b.getRank();
|
||||
int[] current;
|
||||
for (int i = 0; i < r.getSize(); i++) {
|
||||
current = index.getCurrentCounter();
|
||||
setIndex(aindex, bindex, current, n, na, nb);
|
||||
if (a.getLong(aindex) == Long.MIN_VALUE || b.getLong(bindex) == Long.MIN_VALUE) {
|
||||
r.setLong(i, Long.MIN_VALUE);
|
||||
} else {
|
||||
r.setLong(i, a.getLong(aindex) * b.getLong(bindex));
|
||||
}
|
||||
index.incr();
|
||||
}
|
||||
return r;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Array mulLong(Array a, long b) {
|
||||
Array r = Array.factory(DataType.LONG, a.getShape());
|
||||
if (a.getIndexPrivate().isFastIterator()) {
|
||||
for (int i = 0; i < r.getSize(); i++) {
|
||||
r.setLong(i, a.getLong(i) * b);
|
||||
}
|
||||
} else {
|
||||
IndexIterator iterR = r.getIndexIterator();
|
||||
IndexIterator iterA = a.getIndexIterator();
|
||||
long v;
|
||||
while (iterA.hasNext()) {
|
||||
v = iterA.getIntNext();
|
||||
if (v == Long.MIN_VALUE) {
|
||||
iterR.setLongNext(Long.MIN_VALUE);
|
||||
} else {
|
||||
iterR.setLongNext(v * b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
private static Array mulFloat(Array a, Array b) {
|
||||
int broadcast = broadcastCheck(a, b);
|
||||
switch (broadcast) {
|
||||
@ -1615,6 +1872,8 @@ public class ArrayMath {
|
||||
case INT:
|
||||
case UINT:
|
||||
case BOOLEAN:
|
||||
case LONG:
|
||||
case ULONG:
|
||||
return ArrayMath.divInt(a, b);
|
||||
case FLOAT:
|
||||
return ArrayMath.divFloat(a, b);
|
||||
@ -1642,6 +1901,8 @@ public class ArrayMath {
|
||||
case INT:
|
||||
case UINT:
|
||||
case BOOLEAN:
|
||||
case LONG:
|
||||
case ULONG:
|
||||
return ArrayMath.divInt(a, b.intValue());
|
||||
case FLOAT:
|
||||
return ArrayMath.divFloat(a, b.floatValue());
|
||||
@ -1680,6 +1941,8 @@ public class ArrayMath {
|
||||
case INT:
|
||||
case UINT:
|
||||
case BOOLEAN:
|
||||
case LONG:
|
||||
case ULONG:
|
||||
return ArrayMath.divInt(b.intValue(), a);
|
||||
case FLOAT:
|
||||
return ArrayMath.divFloat(b.floatValue(), a);
|
||||
@ -2178,6 +2441,9 @@ public class ArrayMath {
|
||||
case UINT:
|
||||
case BOOLEAN:
|
||||
return ArrayMath.modInt(a, b);
|
||||
case LONG:
|
||||
case ULONG:
|
||||
return ArrayMath.modLong(a, b);
|
||||
case FLOAT:
|
||||
return ArrayMath.modFloat(a, b);
|
||||
case DOUBLE:
|
||||
@ -2203,6 +2469,9 @@ public class ArrayMath {
|
||||
case UINT:
|
||||
case BOOLEAN:
|
||||
return ArrayMath.modInt(a, b.intValue());
|
||||
case LONG:
|
||||
case ULONG:
|
||||
return ArrayMath.modLong(a, b.longValue());
|
||||
case FLOAT:
|
||||
return ArrayMath.modFloat(a, b.floatValue());
|
||||
case DOUBLE:
|
||||
@ -2240,6 +2509,10 @@ public class ArrayMath {
|
||||
return a - Math.floorDiv(a, b) * b;
|
||||
}
|
||||
|
||||
private static long mod(long a, long b) {
|
||||
return a - Math.floorDiv(a, b) * b;
|
||||
}
|
||||
|
||||
private static float mod(float a, float b) {
|
||||
return a - (float)Math.floor(a / b) * b;
|
||||
}
|
||||
@ -2357,6 +2630,115 @@ public class ArrayMath {
|
||||
return r;
|
||||
}
|
||||
|
||||
private static Array modLong(Array a, Array b) {
|
||||
int broadcast = broadcastCheck(a, b);
|
||||
switch (broadcast) {
|
||||
case 0:
|
||||
Array r = Array.factory(DataType.LONG, a.getShape());
|
||||
if (a.getIndexPrivate().isFastIterator() && b.getIndexPrivate().isFastIterator()) {
|
||||
long va, vb;
|
||||
for (int i = 0; i < r.getSize(); i++) {
|
||||
va = a.getLong(i);
|
||||
vb = b.getLong(i);
|
||||
if (va == Long.MIN_VALUE || vb == Long.MIN_VALUE) {
|
||||
r.setLong(i, Long.MIN_VALUE);
|
||||
} else {
|
||||
r.setLong(i, mod(va, vb));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
IndexIterator iterR = r.getIndexIterator();
|
||||
IndexIterator iterA = a.getIndexIterator();
|
||||
IndexIterator iterB = b.getIndexIterator();
|
||||
long va, vb;
|
||||
while (iterA.hasNext()) {
|
||||
va = iterA.getLongNext();
|
||||
vb = iterB.getLongNext();
|
||||
if (va == Long.MIN_VALUE || vb == Long.MIN_VALUE) {
|
||||
iterR.setLongNext(Long.MIN_VALUE);
|
||||
} else {
|
||||
iterR.setLongNext(mod(va, vb));
|
||||
}
|
||||
}
|
||||
}
|
||||
return r;
|
||||
case 1:
|
||||
int[] shape = broadcast(a, b);
|
||||
r = Array.factory(DataType.INT, shape);
|
||||
Index index = r.getIndex();
|
||||
Index aindex = a.getIndex();
|
||||
Index bindex = b.getIndex();
|
||||
int n = r.getRank();
|
||||
int na = a.getRank();
|
||||
int nb = b.getRank();
|
||||
int[] current;
|
||||
long va, vb;
|
||||
for (int i = 0; i < r.getSize(); i++) {
|
||||
current = index.getCurrentCounter();
|
||||
setIndex(aindex, bindex, current, n, na, nb);
|
||||
va = a.getLong(aindex);
|
||||
vb = b.getLong(bindex);
|
||||
if (va == Long.MIN_VALUE || vb == Long.MIN_VALUE) {
|
||||
r.setLong(i, Long.MIN_VALUE);
|
||||
} else {
|
||||
r.setLong(i, mod(va, vb));
|
||||
}
|
||||
index.incr();
|
||||
}
|
||||
return r;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Array modLong(Array a, long b) {
|
||||
Array r = Array.factory(DataType.LONG, a.getShape());
|
||||
long v;
|
||||
if (a.getIndexPrivate().isFastIterator()) {
|
||||
for (int i = 0; i < r.getSize(); i++) {
|
||||
v = a.getLong(i);
|
||||
r.setLong(i, mod(v, b));
|
||||
}
|
||||
} else {
|
||||
IndexIterator iterR = r.getIndexIterator();
|
||||
IndexIterator iterA = a.getIndexIterator();
|
||||
while (iterA.hasNext()) {
|
||||
v = iterA.getLongNext();
|
||||
if (v == Long.MIN_VALUE) {
|
||||
iterR.setLongNext(Long.MIN_VALUE);
|
||||
} else {
|
||||
iterR.setLongNext(mod(v, b));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
private static Array modLong(long b, Array a) {
|
||||
Array r = Array.factory(DataType.LONG, a.getShape());
|
||||
long v;
|
||||
if (a.getIndexPrivate().isFastIterator()) {
|
||||
for (int i = 0; i < r.getSize(); i++) {
|
||||
v = a.getLong(i);
|
||||
r.setLong(i, mod(b, v));
|
||||
}
|
||||
} else {
|
||||
IndexIterator iterR = r.getIndexIterator();
|
||||
IndexIterator iterA = a.getIndexIterator();
|
||||
while (iterA.hasNext()) {
|
||||
v = iterA.getLongNext();
|
||||
if (v == Long.MIN_VALUE) {
|
||||
iterR.setLongNext(Long.MIN_VALUE);
|
||||
} else {
|
||||
iterR.setLongNext(mod(b, v));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
private static Array modFloat(Array a, Array b) {
|
||||
int broadcast = broadcastCheck(a, b);
|
||||
switch (broadcast) {
|
||||
@ -2606,6 +2988,8 @@ public class ArrayMath {
|
||||
case INT:
|
||||
case UINT:
|
||||
case BOOLEAN:
|
||||
case LONG:
|
||||
case ULONG:
|
||||
return ArrayMath.floorDivInt(a, b.intValue());
|
||||
case FLOAT:
|
||||
return ArrayMath.floorDivFloat(a, b.floatValue());
|
||||
@ -2972,6 +3356,9 @@ public class ArrayMath {
|
||||
case UINT:
|
||||
case BOOLEAN:
|
||||
return ArrayMath.powInt(a, b.intValue());
|
||||
case LONG:
|
||||
case ULONG:
|
||||
return ArrayMath.powLong(a, b.longValue());
|
||||
case FLOAT:
|
||||
case DOUBLE:
|
||||
return ArrayMath.powDouble(a, b.doubleValue());
|
||||
@ -3009,6 +3396,9 @@ public class ArrayMath {
|
||||
case UINT:
|
||||
case BOOLEAN:
|
||||
return ArrayMath.powInt(a.intValue(), b);
|
||||
case LONG:
|
||||
case ULONG:
|
||||
return ArrayMath.powLong(a.longValue(), b);
|
||||
case FLOAT:
|
||||
case DOUBLE:
|
||||
return ArrayMath.powDouble(a.doubleValue(), b);
|
||||
@ -3044,6 +3434,9 @@ public class ArrayMath {
|
||||
case INT:
|
||||
case UINT:
|
||||
return ArrayMath.powInt(a, b);
|
||||
case LONG:
|
||||
case ULONG:
|
||||
return ArrayMath.powLong(a, b);
|
||||
case FLOAT:
|
||||
case DOUBLE:
|
||||
return ArrayMath.powDouble(a, b);
|
||||
@ -3102,6 +3495,55 @@ public class ArrayMath {
|
||||
}
|
||||
}
|
||||
|
||||
private static Array powLong(Array a, long b) {
|
||||
Array r = Array.factory(DataType.LONG, a.getShape());
|
||||
for (int i = 0; i < a.getSize(); i++) {
|
||||
r.setLong(i, (long) Math.pow(a.getLong(i), b));
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
private static Array powLong(long a, Array b) {
|
||||
Array r = Array.factory(DataType.LONG, b.getShape());
|
||||
for (int i = 0; i < b.getSize(); i++) {
|
||||
r.setLong(i, (long) Math.pow(a, b.getLong(i)));
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
private static Array powLong(Array a, Array b) {
|
||||
int broadcast = broadcastCheck(a, b);
|
||||
switch (broadcast) {
|
||||
case 0:
|
||||
Array r = Array.factory(DataType.LONG, a.getShape());
|
||||
for (int i = 0; i < a.getSize(); i++) {
|
||||
r.setLong(i, (long) Math.pow(a.getLong(i), b.getLong(i)));
|
||||
}
|
||||
return r;
|
||||
case 1:
|
||||
int[] shape = broadcast(a, b);
|
||||
r = Array.factory(DataType.LONG, shape);
|
||||
Index index = r.getIndex();
|
||||
Index aindex = a.getIndex();
|
||||
Index bindex = b.getIndex();
|
||||
int n = r.getRank();
|
||||
int na = a.getRank();
|
||||
int nb = b.getRank();
|
||||
int[] current;
|
||||
for (int i = 0; i < r.getSize(); i++) {
|
||||
current = index.getCurrentCounter();
|
||||
setIndex(aindex, bindex, current, n, na, nb);
|
||||
r.setLong(i, (long) Math.pow(a.getLong(aindex), b.getLong(bindex)));
|
||||
index.incr();
|
||||
}
|
||||
return r;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Array powDouble(Array a, double b) {
|
||||
Array r = Array.factory(DataType.DOUBLE, a.getShape());
|
||||
for (int i = 0; i < a.getSize(); i++) {
|
||||
|
||||
@ -4,6 +4,7 @@ import org.locationtech.proj4j.BasicCoordinateTransform;
|
||||
import org.locationtech.proj4j.CoordinateTransform;
|
||||
import org.locationtech.proj4j.ProjCoordinate;
|
||||
import org.meteoinfo.common.PointD;
|
||||
import org.meteoinfo.geometry.graphic.Graphic;
|
||||
import org.meteoinfo.geometry.graphic.Transform;
|
||||
|
||||
public class GeoTransform extends Transform {
|
||||
@ -53,6 +54,11 @@ public class GeoTransform extends Transform {
|
||||
return new PointD(t.x, t.y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Graphic transform(Graphic graphic) {
|
||||
return ProjectionUtil.projectClipGraphic(graphic, this.sourceProj, this.targetProj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transform inverted() {
|
||||
return new GeoTransform(this.targetProj, this.sourceProj);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user