我正在尝试学习 GeoTools 快速入门教程。我从 http://www.naturalearthdata.com 下载了 map 。
文件是:
这并不完全是教程中链接的文件,因为这似乎是一个死链接,导致 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/