Java Geotools无法找到错误路径异常

Java Geotools无法找到错误路径异常,java,geotools,Java,Geotools,我使用Java中的geotools获得从节点到节点1的最短路径 下面是检索路径的Java代码: AStarShortestPathFinder finder = new AStarShortestPathFinder(g, node, node1, null); Path path = finder.getPath(); 我试图在上面的代码行中围绕“ErrorPathException”try catch,但出现了错误消息 “类型org.geotools.graph.path.ErrorP

我使用Java中的geotools获得从节点到节点1的最短路径

下面是检索路径的Java代码:

 AStarShortestPathFinder finder = new AStarShortestPathFinder(g, node, node1, null);
 Path path = finder.getPath();
我试图在上面的代码行中围绕“ErrorPathException”try catch,但出现了错误消息 “类型org.geotools.graph.path.ErrorPathException不可见”

以前有人遇到过这个错误吗?有什么解决办法吗

我使用了maven,这是我的pom.xml。这是我第一次使用maven,如果有任何错误,请告诉我

<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.geotools</groupId>
<artifactId>tutorial</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>tutorial</name>
<url>http://maven.apache.org</url>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <geotools.version>24-SNAPSHOT</geotools.version>
</properties>
<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-shapefile</artifactId>
        <version>${geotools.version}</version>
    </dependency>
    <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-swing</artifactId>
        <version>${geotools.version}</version>
    </dependency>
    <dependency>
        <groupId>org.geotools</groupId>
        <artifactId>gt-graph</artifactId>
        <version>${geotools.version}</version>
    </dependency>
</dependencies>
<repositories>
  <repository>
    <id>osgeo</id>
    <name>OSGeo Release Repository</name>
    <url>https://repo.osgeo.org/repository/release/</url>
    <snapshots><enabled>false</enabled></snapshots>
    <releases><enabled>true</enabled></releases>
  </repository>
  <repository>
    <id>osgeo-snapshot</id>
    <name>OSGeo Snapshot Repository</name>
    <url>https://repo.osgeo.org/repository/snapshot/</url>
    <snapshots><enabled>true</enabled></snapshots>
    <releases><enabled>false</enabled></releases>
  </repository>
</repositories>

<build>
    <plugins>
        <plugin>
            <inherited>true</inherited>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>

这是一个问题,目前您可以通过捕获
异常来解决它-但是在今晚的24.x快照(2020/06/19)之后的版本中,我已经应用了一个。

我们可以看到更多的代码吗,以及您正在使用的geotools的哪个版本。@IanTurton我已经向线程添加了更多的代码。非常感谢。请帮忙。
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.geotools.data.FeatureSource;
import org.geotools.data.FileDataStore;
import org.geotools.data.FileDataStoreFinder;
import org.geotools.data.simple.SimpleFeatureIterator;
import org.geotools.feature.FeatureCollection;
import org.geotools.geometry.jts.JTSFactoryFinder;
import org.geotools.graph.build.feature.FeatureGraphGenerator;
import org.geotools.graph.build.line.LineStringGraphGenerator;
import org.geotools.graph.path.AStarShortestPathFinder;
import org.geotools.graph.path.Path;
import org.geotools.graph.path.WrongPathException; //ERROR IN THIS LINE
import org.geotools.graph.structure.Graph;
import org.locationtech.jts.geom.Coordinate;
import org.opengis.feature.Feature;

import org.locationtech.jts.geom.Point;
import org.locationtech.jts.geom.GeometryFactory;

import org.geotools.graph.structure.Node;
import org.geotools.graph.structure.line.BasicDirectedXYNode;
import org.geotools.graph.traverse.standard.AStarIterator;


public class App2 {
    public static void main(String[] args) {
        //Import shapefile
        File shapeFile = new File("shape.shp");

        //import all features in the shape.shp into FeatureCollection
        FeatureCollection fCollection = null;

        //.....other code to import the shapefile to FeatureCollection.......

        Graph g = featureGen.getGraph();

        //Using AStarShortestPathFinder to find the Shortest Path between node and node1 with the graph from the Shapefile
        AStarShortestPathFinder finder = new AStarShortestPathFinder(g, node, node1, null);
        Path path = finder.getPath();

    }
}