简体   繁体   English

MathTransform在Android项目中不起作用:“类型java.awt.geom.Point2D $ Double无法解析。”

[英]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.

相关问题 初始化java.awt.geom.Point2D - Initializing java.awt.geom.Point2D 为什么我不能使用 java.awt.geom.Point2D 中的距离方法? - Why can't I use distance method from java.awt.geom.Point2D? 将列表java.awt.geom.Point2D转换为java.awt.geom.Area - Convert a list java.awt.geom.Point2D to a java.awt.geom.Area 无法解析java.awt.geom.AffineTransform类型。 它是从所需的.class文件间接引用的 - The type java.awt.geom.AffineTransform cannot be resolved. It is indirectly referenced from required .class files Android:无法解析java.awt.Image类型。 它是从所需的.class文件间接引用的 - Android: The type java.awt.Image cannot be resolved. It is indirectly referenced from required .class files java.awt.geom.Point2D.createArray() - java.awt.geom.Point2D.createArray() java.io.FilterOutputstream 类型无法解析。 错误 - the type java.io.FilterOutputstream cannot be resolved. error “导入java.awt无法解析”和“ *****无法解析为类型” - “The import java.awt cannot be resolved” and “ ***** cannot be resolved to a type” 无法解析类型java.lang.CharSequence。 汤姆猫 - The type java.lang.CharSequence cannot be resolved. TomCat Eclipse 中的 Java 项目:无法解析 java.lang.Object 类型。 它是从所需的 .class 文件中间接引用的 - Java project in Eclipse: The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM