我正在尝试使用OSM 的 Atlas 项目,以便能够在地球的街道上“行走”,并将地图作为图表,但我在使用它时遇到了麻烦。文档似乎有点稀缺。
看来我需要 .atlas 文件,但我不确定如何获取/生成它们。
我尝试从OpenStreetMap 导出功能下载文件。它似乎给了我 .osm 文件。然后我尝试将它们转换为 .osm.pbf 文件osmconvert map.osm -o=map.osm.pbf
。然后我尝试使用 Atlas 的 CLI 命令将 .osm.pbf 文件转换为 .atlas 文件:atlas pbf2atlas --countryName BGR map.osm.pbf
.
这似乎不起作用,因为然后我尝试加载 .atlas 文件,但它会引发异常。
import org.openstreetmap.atlas.geography.atlas.Atlas;
import org.openstreetmap.atlas.geography.atlas.AtlasResourceLoader;
import org.openstreetmap.atlas.streaming.resource.File;
public class Main {
public static void main(String[] args) {
File atlasFile = new File("BGR_map.osm.atlas");
Atlas atlas = new AtlasResourceLoader().load(atlasFile);
atlas.nodes().forEach(System.out::println);
}
}
Exception in thread "main" org.openstreetmap.atlas.exception.CoreException: MetaData not here!
at org.openstreetmap.atlas.geography.atlas.packed.PackedAtlasSerializer.load(PackedAtlasSerializer.java:96)
at org.openstreetmap.atlas.geography.atlas.packed.PackedAtlas.load(PackedAtlas.java:190)
at org.openstreetmap.atlas.geography.atlas.AtlasResourceLoader.load(AtlasResourceLoader.java:73)
at org.openstreetmap.atlas.geography.atlas.AtlasResourceLoader.load(AtlasResourceLoader.java:96)
at Main.main(Main.java:9)
Caused by: org.openstreetmap.atlas.exception.CoreException: Unable to read Atlas field metaData
at org.openstreetmap.atlas.geography.atlas.packed.PackedAtlasSerializer.deserializeIfNeeded(PackedAtlasSerializer.java:154)
at org.openstreetmap.atlas.geography.atlas.packed.PackedAtlas.metaData(PackedAtlas.java:511)
at org.openstreetmap.atlas.geography.atlas.packed.PackedAtlasSerializer.load(PackedAtlasSerializer.java:92)
... 4 more
Caused by: org.openstreetmap.atlas.exception.CoreException: Could not load Field metaData from BGR_map.osm.atlas
at org.openstreetmap.atlas.geography.atlas.packed.PackedAtlasSerializer.deserializeResource(PackedAtlasSerializer.java:258)
at org.openstreetmap.atlas.geography.atlas.packed.PackedAtlasSerializer.deserializeSingleField(PackedAtlasSerializer.java:275)
at org.openstreetmap.atlas.geography.atlas.packed.PackedAtlasSerializer.load(PackedAtlasSerializer.java:344)
at org.openstreetmap.atlas.geography.atlas.packed.PackedAtlasSerializer.deserializeIfNeeded(PackedAtlasSerializer.java:149)
... 6 more
Caused by: java.io.StreamCorruptedException: invalid stream header: 08811E10
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:866)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:358)
at org.openstreetmap.atlas.geography.atlas.packed.PackedAtlasSerializer.deserializeResource(PackedAtlasSerializer.java:247)
... 9 more
我在 Atlas repo 中发现了一些其他已经生成的 .atlas 文件进行测试,并且它们使用此代码正常加载,所以似乎我无法正确生成 .atlas 文件。我怎么做?我想打开 OSM 地图并将其中的一个区域作为 .atlas 文件获取,以便我可以通过代码对其进行探索。