[英]MathTransform doesn't work in Android project: “The type java.awt.geom.Point2D$Double cannot be resolved.”
I need to transform coordinates using GeoTools. 我需要使用GeoTools转换坐标。 My code works fine in a Java project but when I put it in the Android I get the error at the mathTransform.transform(...) line: "The type java.awt.geom.Point2D$Double cannot be resolved. It is indirectly referenced from required .class files".
我的代码在Java项目中工作正常,但是当我将其放入Android时,我在mathTransform.transform(...)行收到错误消息:“类型java.awt.geom.Point2D $ Double无法解析。它是从所需的.class文件间接引用”。 Here's my code:
这是我的代码:
CoordinateReferenceSystem sourceCrs = CRS.decode("EPSG:3765");
CoordinateReferenceSystem targetCrs = CRS.decode("EPSG:4326");
boolean lenient = true;
double x, y;
MathTransform mathTransform = CRS.findMathTransform(sourceCrs, targetCrs, lenient);
parts = result.split(" ");
String coors = "";
for (int i = 0; i < parts.length; i += 2) {
x = Double.parseDouble(parts[i]);
y = Double.parseDouble(parts[i+1]);
DirectPosition2D srcDirectPosition2D = new DirectPosition2D(sourceCrs, x, y);
DirectPosition2D destDirectPosition2D = new DirectPosition2D();
mathTransform.transform(srcDirectPosition2D, destDirectPosition2D);
x = destDirectPosition2D.x;
y = destDirectPosition2D.y;
coors += x + " " + y + " ";
}
System.out.println(coors + ";");
Now I found this question which explains the reasons for it: Can't import Java awt in Eclipse , but what would be the solution? 现在,我发现了一个可以解释其原因的问题: 无法在Eclipse中导入Java awt ,但是解决方案是什么?
what would be the solution?
解决办法是什么?
You could not use this JAR, but instead find some other similar library that is ready for Android. 您无法使用此JAR,而是找到了一些其他适用于Android的类似库。
Or you could read up on prior attempts to get GeoTools working on Android . 或者,您也可以阅读之前使GeoTools在Android上运行的尝试 。
Or you could contribute code changes back to the project that eliminate references to java.awt
classes, replacing that code with algorithms implemented in the library itself. 或者,您可以将代码更改归还给项目,从而消除对
java.awt
类的引用,而用在库本身中实现的算法替换该代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.