Reputation: 314
I am trying to use OSM's Atlas project in order to be able to "walk" around the planet's streets and maps as a graph, but I am having trouble using it. The documentation seems a little scarce.
It seems that I need .atlas files, but I am not sure how to get/generate them.
I tried downloading files from the OpenStreetMap export function. It seems to give me .osm files. Then I tried to convert them to .osm.pbf files with osmconvert map.osm -o=map.osm.pbf
. Then I tried to use the CLI command from Atlas to convert the .osm.pbf file to an .atlas file: atlas pbf2atlas --countryName BGR map.osm.pbf
.
This doesn't seem to work though because I then try to load the .atlas file, but it throws an exception.
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
I found some other already generated .atlas files for testing in the Atlas repo and they load normally with this code, so it seems that I can't generate the .atlas files properly. How do I do that? I want to open the OSM map and get a region of it as an .atlas file so that I can explore it through code.
Upvotes: 2
Views: 347