2

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.

frostblooded
  • 304
  • 1
  • 6
  • 15
  • Offtopic for StackOverflow since this is not a programming question. Try asking at http://gis.stackexchange.com/ or http://help.openstreetmap.org/ instead. – scai Jun 03 '19 at 13:38
  • It looks like the `atlas` command you used is correct, and that the file produced was corrupted somehow. Were there any errors printed while creating the Atlas? Can you try re-running the `atlas` command with a small pbf from Geofabrik (Like Belize for example) and see if that happens again? This would rule out any problem with the pbf file. – matthieun Jun 03 '19 at 16:35
  • I downloaded the .osm.pbf for Belize from [here](https://download.geofabrik.de/central-america.html). Then I did `atlas pbf2atlas --countryName BLZ belize-latest.osm.pbf` and the error is the same when I try to open the resulting `BLZ_belize-latest.osm.atlas` file with the given Java code. – frostblooded Jun 07 '19 at 06:15
  • I cannot reproduce the same issue... I have taken the latest atlas command (`atlas-config list` returns `atlas-c7ff685` which is https://github.com/osmlab/atlas/tree/e2988f3). The atlas builds properly for me, with the latest pbf from your link. I was able to print it and visualize it. Try re-running `atlas-config repo install atlas` to update to the latest command code? I have also uploaded my Atlas for you to take a look in the same folder: https://github.com/osmlab/atlas/tree/e2988f3d642ee21bb51d58393a4a65a79b8797f7/src/main/java/org/openstreetmap/atlas/geography/atlas#using-atlas – matthieun Jun 10 '19 at 17:18
  • This still seems to not be working, which is odd... I ran `atlas-config repo install atlas` and now `atlas-config list` returns `atlas-3e1cb92`. The files still don't have a correct meta data when generated through the command though. I managed to find out that this code (https://pastebin.com/9Q4L8vDv) can be used instead of the command and it generates files that can be opened correctly. But I am not sure if it does the same thing. – frostblooded Jun 12 '19 at 05:22
  • Yes, your code seems correct, and does the same thing as the command. I am not sure why the command does not work though. Can you create an issue in the Atlas github repo and describe your problem in as much detail as possible so we can try to reproduce it hopefully fix it? – matthieun Jun 17 '19 at 16:21

0 Answers0