我试图使用OSM's Atlas project以便能够以图形的形式在地球的街道和地图上“行走”,但是我在使用它时遇到了麻烦。该文档似乎有点稀缺。
似乎我需要.atlas文件,但是我不确定如何获取/生成它们。
我尝试从OpenStreetMap export函数下载文件。它似乎给我.osm文件。然后,我尝试使用osmconvert map.osm -o=map.osm.pbf
将它们转换为.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存储库中找到了一些其他已经生成的.atlas文件进行测试,并且它们正常加载了此代码,因此看来我无法正确生成.atlas文件。我怎么做?我想打开OSM地图并将其区域作为.atlas文件获取,以便我可以通过代码对其进行浏览。