java - GeoTools,加载 map 时出错

标签 java geotools

我正在尝试学习 GeoTools 快速入门教程。我从 http://www.naturalearthdata.com 下载了 map 。

文件是:

http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_admin_0_countries.zip

这并不完全是教程中链接的文件,因为这似乎是一个死链接,导致 404 Not Found。然而,由于我选择的内容来自同一网站,我希望它是正确的。

所有教程都是静态主方法,代码如下。

    File file = JFileDataStoreChooser.showOpenFile("shp", new File("."), null);
    FileDataStore store = FileDataStoreFinder.getDataStore(file);
    SimpleFeatureSource featureSource = store.getFeatureSource();

    // Create a map content and add our shapefile to it
    MapContent map = new MapContent();
    map.setTitle("Quickstart");

    Style style = SLD.createSimpleStyle(featureSource.getSchema());
    Layer layer = new FeatureLayer(featureSource, style);
    map.addLayer(layer);

    // Now display the map
    JMapFrame.showMap(map);

但是

当我运行它并选择 shp 文件(从下载中提取)时,几秒钟后我收到以下异常:

SEVERE: Invalid empty measure '', was expecting a number, eventually followed by px, m or ft

在调试中我看到该行抛出:

JMapFrame.showMap(map);

我该如何解决这个问题?

最佳答案

我也有同样的错误。不知道为什么,但它对我使用快照存储库中的版本 10-SNAPSHOT 有效

<dependency>
  <groupId>org.geotools</groupId>
  <artifactId>gt-shapefile</artifactId>
  <version>10-SNAPSHOT</version>
</dependency>
<dependency>
  <groupId>org.geotools</groupId>
  <artifactId>gt-swing</artifactId>
  <version>10-SNAPSHOT</version>
</dependency>

<repository>
  <snapshots>
    <enabled>true</enabled>
  </snapshots>
  <id>opengeo</id>
  <name>OpenGeo Maven Repository</name>
  <url>http://repo.opengeo.org</url>
</repository>

关于java - GeoTools,加载 map 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20447934/

相关文章:

java - 带文件夹的 Geotools KML 导出

java - 多次调用 geotools 的 SimpleFeatureCollection.features() 会导致 "Maximum lock count exceeded"

java - Maven包错误

java - (Geotools 库)如何转换韩国坐标(EPSG :5179) to Decimal Degree coordinates (EPSG:4326)

java - MessageDriverBean - 重试机制

java - 添加文件夹中的所有文件以使用 Maven 构建路径依赖关系

java - 无法将 spring.example.service.UsuarioService 字段 spring.example.config.security.SecurityConfig.usuario 设置为 $Proxy47

java - 使用地理工具在多边形中点

java - 为什么 Maven 找不到位于另一个模块/项目中的包?

java - 模拟传递给回调的参数(lambdas)