Created .map file, "Invalid magic byte" message in BasicMapViewer

1,022 views
Skip to first unread message

Joey

unread,
Jan 18, 2012, 1:57:00 PM1/18/12
to mapsforge-dev
I tried create a .map file of Alaska from the .osm file provided by
downloads.cloudmade.com.

I finally got a .map file, but I had to convert the .osm to a .pbf
first, otherwise I was getting the following Exception upon running

~/Development/osmosis-0.40.1/bin/osmosis --rx file="alaska.osm" --
bounding-polygon file="alaska.poly" --mw file="alaska.map" type=hd

SEVERE: Thread for task 1-rx failed
java.lang.NullPointerException
at
org.mapsforge.preprocessing.map.osmosis.MapFileWriterTask.release(MapFileWriterTask.java:
192)
at
org.openstreetmap.osmosis.areafilter.v0_6.AreaFilter.release(AreaFilter.java:
640)
at org.openstreetmap.osmosis.xml.v0_6.XmlReader.run(XmlReader.java:
125)
at java.lang.Thread.run(Thread.java:680)
Jan 17, 2012 6:25:07 PM org.openstreetmap.osmosis.core.Osmosis main
SEVERE: Execution aborted.

After downloading and building osmconvert (download osmconvert.c, run
"cc osmconvert.c -lz -o osmconvert"), I was able to do the conversion
with:

~/Development/osmosis-0.40.1/osmconvert/osmconvert alaska.osm -
o=alaska.pbf

Then running the following, gave me the .map file:

~/Development/osmosis-0.40.1/bin/osmosis --rb file="alaska.pbf" --
bounding-polygon file="alaska.poly" --wb alaska.map

I pushed the .map file onto my device so it lives at /sdcard/
alaska.map.

Changed the hardcoded String in the BasicMapViewer.java file to point
to that map file (instead of Berlin, which worked fine). Now, when I
activate that activity I get the following log messages:

01-18 10:27:19.440: D/osm(3256): main: invalid magic byte: ������
01-18 10:27:19.440: D/osm(3256): OSMHeader 1 %


I get the same message when I try to use the California map from
http://download.mapsforge.org/maps/north-america/us/.

Anyone have a good idea what is going on? I am happy to provide more
information if it would be helpful.

Thanks,
Joey

Thilo Mühlberg

unread,
Jan 26, 2012, 3:59:48 PM1/26/12
to mapsfo...@googlegroups.com
Hello Joey,

which version of map-writer and map library did you use? We have made
significant changes to the binary map format in the past months,
therefore the latest map writer and map library from our SVN repository
are not compatible with the file format from the 0.2.4 release.

If you are using the 0.2.4 version of map writer and reader, then we
should check if we can reproduce the problem by using our latest writer
and reader from SVN. Maybe the bug has already been fixed there.

Greetings,
Thilo

signature.asc

Joey

unread,
Jan 27, 2012, 3:00:11 PM1/27/12
to mapsforge-dev
Thanks for the reply Thilo.

In my ~/.openstreetmap/osmosis/plugins directory I have mapsforge-
mapfile-writer-0.2.4.jar.

Within my eclipse project, I am referencing mapsforge-map-0.2.4.jar.
So I think I'm using compatible libraries (at least based on the jar
file names).

The Adnroid project, however, is probably 0.3.0 since I just cloned it
a couple weeks ago. I had to fix a couple of things to get it to
compile, but I chalked that up to differences between 0.2.4 and
0.3.0. However, since I am referencing a 0.2.4 jar and the project
compiles and runs on my device, I assume the dependencies are all
good.

I have the map file that I generated. It's about 12MB, and if there
is a way to send it to you, I'd be happy to do so.

Thanks in advance for any guidance...

Joey

PS: something that might be helpful would be explicit instructions on
how to build the mapsforge-mapfile-writer and mapsforge-map jars from
the current branch. That way I could be certain that the code in the
Android "Samples" project and the libraries are built against the same
code. I tried a few times and just couldn't build the jars. Mostly
my unfamiliarity with using jar, I think.

Joey

unread,
Jan 27, 2012, 3:39:46 PM1/27/12
to mapsforge-dev
Just an update. california-0.2.4.map actually does work for me. It's
just the map that I created as described in the first post that does
not work (Invalid magic byte).

Thanks again for any help...

Joey

Gonzalo

unread,
Mar 7, 2012, 7:21:05 PM3/7/12
to mapsforge-dev
I am having same trouble.
I download a map for Daejeon, South Korea from cloudmade.
Then I converted it using osmosis:

osmosis --rx file=daejeon.osm --mapfile-writer file=daejeon.map map-
start-position=36.3366,127.4059 bbox=36.1778,127.2512,36.4953,127.5606

Osmosis is 0.40.1, and the version of both map writer and mapforge is
0.24.

Any ideas?

Thilo Mühlberg

unread,
Mar 8, 2012, 4:01:53 PM3/8/12
to mapsfo...@googlegroups.com
With the upcoming 0.3.0 release, the binary map file format has changed.
Please follow the instructions at
https://code.google.com/p/mapsforge/wiki/MapFileWriterOsmosis to build a
(snapshot) version of the map-writer and create files based on the new
format. Note that this is a development stage and things might
change/break at any time!

For testing purposes you can also find some new map files on our
download server: http://download.mapsforge.org/maps/snapshot/

Greetings,
Thilo

signature.asc
Reply all
Reply to author
Forward
0 new messages