Indoor map in android application

759 views
Skip to first unread message

Viala Simon-Alexandre

unread,
Jun 21, 2014, 8:34:34 AM6/21/14
to mapsfo...@googlegroups.com
Hello everybody, 

I am currently in a french engineering school where I am asked to developp an android application which would allow the user to localise himself indoor (one floor of an hospital). The localisation would be possible thanks to wifi signals coupled with what our device would receive from Google.

Anyway, I am asking for your help because we basically have had no lessons about android development (2 hours...) ! I made an indoor representation of the floor i am supposed to localise myself in thanks to JOSM (check for "indoor OSM" for further informations, what Heidelberg university did is very interesting). So I now have a beautiful file PVA.osm. 

My question was, and once more sorry if I am asking for the basics, how can I, from this .osm file, have a .map of my floor on my android application ? Mapsforge seems to be the tool I need, since I could use the markers and put my position (which would come from the wifi signals), but I am not very comfortable with the online tutorial.

Could anyone help me ? Or at least give me clues to find my way through that ? 

Simon-Alexandre


Emux

unread,
Jun 21, 2014, 9:43:32 AM6/21/14
to mapsfo...@googlegroups.com
Yes mapsforge can be used for custom indoor maps too.
Map writer performs the conversion from osm to map.

In order to do that it needs an xml file for understanding what layer is supposed to be put at map file,
from what zoom level and what fields it can contain.
That xml file is the tag-mapping.xml. If you don't provide one then the default will be used.
That's perfect for original OpenStreetMap osm files, but for custom ones like yours, you have to create one with your custom layers and fields.

Once you have your custom tag-mapping.xml you can create the map file with a command like this:
osmosis --rx file=pva.osm --s --mw file=pva.map bbox=minLat,minLon,maxLat,maxLon map-start-position=lat,lon map-start-zoom=zoom tag-conf-file=tag-mapping.xml

After the creation of the map file you'll have to create also your render theme which contains instructions about how to render the vector data at the screen.
Again you cannot use the default osmarender.xml since you have a custom map.

I hope to help you a bit for start, don't hesitate to ask us anything for help.

--
Emux
Cruiser - Atlas

Viala Simon-Alexandre

unread,
Jun 21, 2014, 11:10:11 AM6/21/14
to mapsfo...@googlegroups.com
Thank you very much ! I'll try this as soon as I will have received the minLat, minLon, maxLat, maxLon. Just to be sure : do I have to work on the virtual machine to do all that, or since my macBook is now running with linux I can use it ? 

Emux

unread,
Jun 21, 2014, 11:40:49 AM6/21/14
to mapsfo...@googlegroups.com
Yes at all OS you have several options for testing your maps:
- Use an actual device connected to your pc
- Use the official Android emulator (which is slow)
- Use a fast Android VM like Genymotion

At all these you can use your Android application of choice for map viewing
or try Cruiser which has convenient map and render theme file choosers.

Personally I tend to build maps using also Atlas, a Java mapsforge viewer working at Win, Mac, Linux.

Viala Simon-Alexandre

unread,
Jun 22, 2014, 6:27:50 AM6/22/14
to mapsfo...@googlegroups.com
Okay, so let me just sum up what I have understood : 

- I have to create an tag-mapping.xml. Knowing that my map in just a floor of an hospital, what should it contain ?... the  tag-mapping.xml refers to 

- After that I use my terminal to go in the directory where pva.osm is, and I use your command :
"osmosis --rx file=pva.osm --s --mw file=pva.map bbox=minLat,minLon,maxLat,maxLon map-start-position=lat,lon map-start-zoom=zoom tag-conf-file=tag-mapping.xml" BUT before, I have to download of install the map writer plugin ? 

- Then do I have to code for the render theme too ? Do I have to follow the examples ? 

- Finally, I have my pva.map (Hallelujah !!). And I use Cruiser or Atlas in order to open it. At this moment I'll be able to code to put it in my android application.

Am I right ? 


Emux

unread,
Jun 22, 2014, 8:04:28 AM6/22/14
to mapsfo...@googlegroups.com
- I have to create an tag-mapping.xml. Knowing that my map in just a floor of an hospital, what should it contain ?... the  tag-mapping.xml refers to

You have to study the existing default tag-mapping.xml to understand it's structure.
Then you can build a similar one describing your vector data, nodes and ways (lines or polygons).
Start with only one layer for start.


- After that I use my terminal to go in the directory where pva.osm is, and I use your command :
"osmosis --rx file=pva.osm --s --mw file=pva.map bbox=minLat,minLon,maxLat,maxLon map-start-position=lat,lon map-start-zoom=zoom tag-conf-file=tag-mapping.xml" BUT before, I have to download of install the map writer plugin ?

You'll need the Osmosis tool which can process osm/pbf files.
Then place the map-writer plugin jar in your osmosis/lib/default folder.


- Then do I have to code for the render theme too ? Do I have to follow the examples ?

You can study the default osmarender theme and try to describe your layers (see also the Wiki).


- Finally, I have my pva.map (Hallelujah !!). And I use Cruiser or Atlas in order to open it. At this moment I'll be able to code to put it in my android application.

Finally you need a viewer to see how the map and render theme look like and modify them at your will.

Viala Simon-Alexandre

unread,
Jun 22, 2014, 9:45:49 AM6/22/14
to mapsfo...@googlegroups.com
Anyway I do have one only layer (my floor) ! This tag-mapping should include like corridors, rooms, examination room. That's right ? (We're talking about a hospital floor). That's for "pois". And for way it is only pedestrian.

Emux

unread,
Jun 22, 2014, 9:56:15 AM6/22/14
to mapsfo...@googlegroups.com
I meant to start with one vector data of your collection and perform the whole cycle of building the map and render theme to get accustomed to the process.
You probably have polygons, lines, points. Then you can add the rest.
e.g. try to build a map with the corridors to have a plan of the whole floor.

Viala Simon-Alexandre

unread,
Jun 22, 2014, 10:21:16 AM6/22/14
to mapsfo...@googlegroups.com
Ok.... I think I might need my teacher's help right now ! I'm a bit lost in all this ! 

Emux

unread,
Jun 22, 2014, 10:40:16 AM6/22/14
to mapsfo...@googlegroups.com
Let me attach a simple tag-mapping.xml and its relevant theme.xml to show the 2 files in its simplest form.

They have two types of vector data:
- line e.g. rivers
- point e.g. cafe

The tags amenity=cafe and waterway=river come from the initial osm file we want to process.

tag-mapping.xml
theme.xml

Viala Simon-Alexandre

unread,
Jun 22, 2014, 11:26:36 AM6/22/14
to mapsfo...@googlegroups.com
Ok. So These "rivers" and "cafe" refer to ojects that are present in your osm file. The thing is I don't have any Point of Interest I want to underline ! I just want on my application the walls to be represented. 

Emux

unread,
Jun 22, 2014, 11:32:04 AM6/22/14
to mapsfo...@googlegroups.com
The 'walls' have to be identified in the osm with some unique tag name,
which you'll use in the tag-mapping and render theme xml files.

Viala Simon-Alexandre

unread,
Jun 22, 2014, 11:49:54 AM6/22/14
to mapsfo...@googlegroups.com
Right of course... So if I want to show nothing but the outside walls I can put in my tag-mapping.xml 

"<ways>
<osm-tag key="building" value="wall" zoom-appear="15"/>
</ways>"

And put the same key and value in JOSM ? 


Emux

unread,
Jun 22, 2014, 11:53:34 AM6/22/14
to mapsfo...@googlegroups.com
That's right like this.

Viala Simon-Alexandre

unread,
Jun 22, 2014, 12:07:11 PM6/22/14
to mapsfo...@googlegroups.com
And do I have to change the 
"<tag-mapping xmlns="http://mapsforge.org/tag-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://mapsforge.org/tag-mapping ../resources/tag-mapping.xsd" default-zoom-appear="16" profile-name="default-profile">"  ? 

Especially regarding de xmlns:xsi ? And schemaLocation ? 

Viala Simon-Alexandre

unread,
Jun 22, 2014, 12:09:41 PM6/22/14
to mapsfo...@googlegroups.com
I hope you don't picture me like that : 
Or at least not too much .. 

Emux

unread,
Jun 22, 2014, 12:11:30 PM6/22/14
to mapsfo...@googlegroups.com
If you're using an xml editor capable to process / validate the xml schema (xsd) then you can write your proper path for the tag-mapping.xsd file.

Emux

unread,
Jun 22, 2014, 12:15:21 PM6/22/14
to mapsfo...@googlegroups.com
Not at all, we're here to help! :-)

Viala Simon-Alexandre

unread,
Jun 22, 2014, 12:17:10 PM6/22/14
to mapsfo...@googlegroups.com
I just downloaded Oxygen as a xml editor to try with it ! 

Viala Simon-Alexandre

unread,
Jun 22, 2014, 12:37:39 PM6/22/14
to mapsfo...@googlegroups.com
"you can write your proper path for the tag-mapping.xsd file." ... which is ? 

Emux

unread,
Jun 22, 2014, 12:40:57 PM6/22/14
to mapsfo...@googlegroups.com
I mean the absolute or relative path of tag-mapping.xsd as it is saved in your hard disk.

Viala Simon-Alexandre

unread,
Jun 22, 2014, 12:47:15 PM6/22/14
to mapsfo...@googlegroups.com
Okay so now is the time I have to use map writer and to have installed the plug in. 

Viala Simon-Alexandre

unread,
Jun 22, 2014, 1:08:08 PM6/22/14
to mapsfo...@googlegroups.com
Ok so i have my tag-mapping.xml file, with the proper path in it, in the same directory than my tag-mapping.xsd ; both in the directory where my pva.osm is. Now I use the terminal, i go in this directory. In which directory should I be with my terminal to execute the command you sent me yesterday (starting with osmosis) ? 

Emux

unread,
Jun 22, 2014, 1:12:37 PM6/22/14
to mapsfo...@googlegroups.com
Try using absolute paths at the osmosis command, for all file parameters.
That way it'll work regardless your current path.

Viala Simon-Alexandre

unread,
Jun 22, 2014, 1:16:14 PM6/22/14
to mapsfo...@googlegroups.com
I am doing it wrong .. Am I not ? 
Capture d’écran 2014-06-22 à 19.15.03.png

Emux

unread,
Jun 22, 2014, 1:21:42 PM6/22/14
to mapsfo...@googlegroups.com
The osmosis "executable" is inside the osmosis/bin/ folder:
osmosis/bin/osmosis

So either try running the command from inside osmosis/bin folder.
Or from outside you have to provide the absolute path for the "osmosis".

Viala Simon-Alexandre

unread,
Jun 22, 2014, 1:32:30 PM6/22/14
to mapsfo...@googlegroups.com
Alright. Now that I am in the bin folder, i have to enter 
"--rx file=pva.osm --s --mw file=pva.map bbox=minLat,minLon,maxLat,maxLon map-start-position=lat,lon map-start-zoom=zoom tag-conf-file=tag-mapping.xml" 

Problems : 

- I have to wait to have minLat,minLon,maxLat,maxLon 
- It returns either "-bash: --rx: command not found" or "-bash: osmosis: command not found" 

Emux

unread,
Jun 22, 2014, 1:39:46 PM6/22/14
to mapsfo...@googlegroups.com
You missed the "osmosis" at the start of your command.

In case Osmosis does not recognize the map writer plugin, try its newer version mapsforge-map-writer-0.5.0-SNAPSHOT.jar from here.
Remember to place it in your osmosis/lib/default sub folder.

Viala Simon-Alexandre

unread,
Jun 22, 2014, 1:52:11 PM6/22/14
to mapsfo...@googlegroups.com
It doesn't recognize it neither, I get the "-bash: --rx: command not found" or "-bash: osmosis: command not found". I'll try with the newer plugin.

Emux

unread,
Jun 22, 2014, 1:56:31 PM6/22/14
to mapsfo...@googlegroups.com
If you're not using absolute paths for osmosis
and you're inside the osmosis/bin folder then you have to run it with:

./osmosis --rx file=pva.osm --s --mw file=pva.map bbox=minLat,minLon,maxLat,
maxLon map-start-position=lat,lon map-start-zoom=zoom tag-conf-file=tag-mapping.xml

--rx is a parameter not a command.

Viala Simon-Alexandre

unread,
Jun 22, 2014, 2:03:27 PM6/22/14
to mapsfo...@googlegroups.com
Perfect !! That works with the ./ !! I'll do this tomorrow with the right minLat, maxLat, minLon, maxLon !
After that I should have my .map, use the render theme and either Cruiser or Atlas to visualise my map. 

To end with it, I have to understand how to put it in an Android application, thanks to mapsforge and add my marker. I might find a tutorial on the internet.

Emux

unread,
Jun 22, 2014, 2:07:37 PM6/22/14
to mapsfo...@googlegroups.com
To end with it, I have to understand how to put it in an Android application, thanks to mapsforge and add my marker. I might find a tutorial on the internet.

You can start with the GettingStartedAndroidApp Wiki.

Also you can study the Samples app which has many more examples.

Viala Simon-Alexandre

unread,
Jun 23, 2014, 1:11:23 PM6/23/14
to mapsfo...@googlegroups.com
I'm back ! So I now have my coordinates. I am typing on my terminal : 

"./osmosis --rx file=pva.osm --s --mw file=pva.map bbox=48.118278,-1.695017,48.119307,-1.69272 map-start-position=48.118278,-1.695017 map-start-zoom=zoom tag-conf-file=tag-mapping.xml"

I need to have the file tag-mapping.xml in the same directory, but where does my pva.osm goes ? Knowing that there still are errors 

(for the record, i get as an answer : 

" pc7:bin SimonAlexandre$ ./osmosis --rx file=pva.osm --s --mw file=pva.map bbox=48.118278,-1.695017,48.119307,-1.69272 map-start-position=48.118278,-1.695017 map-start-zoom=zoom tag-conf-file=tag-mapping.xml

juin 23, 2014 7:06:53 PM org.openstreetmap.osmosis.core.Osmosis run

INFOS: Osmosis Version 0.43.1

juin 23, 2014 7:06:54 PM org.java.plugin.registry.xml.ManifestParser <init>

INFOS: got SAX parser factory - org.apache.xerces.jaxp.SAXParserFactoryImpl@3b6eb2ec

juin 23, 2014 7:06:54 PM org.java.plugin.registry.xml.PluginRegistryImpl configure

INFOS: configured, stopOnError=false, isValidating=true

juin 23, 2014 7:06:54 PM org.java.plugin.registry.xml.PluginRegistryImpl register

INFOS: plug-in and fragment descriptors registered - 1

juin 23, 2014 7:06:54 PM org.java.plugin.standard.StandardPluginManager activatePlugin

INFOS: plug-in started - org.openstreetmap.osm...@0.0.0.42-6-gf39a160-dirty

juin 23, 2014 7:06:54 PM org.openstreetmap.osmosis.core.Osmosis run

INFOS: Preparing pipeline.

juin 23, 2014 7:06:54 PM org.openstreetmap.osmosis.core.Osmosis main

GRAVE: Execution aborted.

org.openstreetmap.osmosis.core.OsmosisRuntimeException: Task type mw doesn't exist.

at org.openstreetmap.osmosis.core.pipeline.common.TaskManagerFactoryRegister.getInstance(TaskManagerFactoryRegister.java:60)

at org.openstreetmap.osmosis.core.pipeline.common.Pipeline.buildTasks(Pipeline.java:50)

at org.openstreetmap.osmosis.core.pipeline.common.Pipeline.prepare(Pipeline.java:112)

at org.openstreetmap.osmosis.core.Osmosis.run(Osmosis.java:86)

at org.openstreetmap.osmosis.core.Osmosis.main(Osmosis.java:37)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:483)

at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:329)

at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)

at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)

at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

at org.codehaus.classworlds.Launcher.main(Launcher.java:47)

")

Emux

unread,
Jun 23, 2014, 1:30:13 PM6/23/14
to mapsfo...@googlegroups.com
- You forgot to put a value at map-start-zoom

- For the 3 files (osm, map, xml) you can place wherever you want, just write their absolute paths at command

- The exception indicates that osmosis does not find the map writer plugin.
Did you put the mapsforge-map-writer-0.5.0-SNAPSHOT.jar at osmosis/lib/default folder?
Note that you must have only 1 map writer jar inside that folder.

Viala Simon-Alexandre

unread,
Jun 23, 2014, 2:08:59 PM6/23/14
to mapsfo...@googlegroups.com
Is "file=/Users/SimonAlexandre/Desktop/PVA-PFE/pva.osm" supposed to work ? Jesus, I have even more problems haha ... 


Emux

unread,
Jun 23, 2014, 2:22:43 PM6/23/14
to mapsfo...@googlegroups.com
Well it's bash rules, yes that's an absolute path.

Viala Simon-Alexandre

unread,
Jun 23, 2014, 3:20:49 PM6/23/14
to mapsfo...@googlegroups.com
Yeah, I saw it in C++ .....! 

I thaught I had the latest version mapsforge-map-writer-0.5.0-SNAPSHOT.jar, yet it now sends me : 
- "GRAVE: Thread for task 1-rx failedorg.openstreetmap.osmosis.core.OsmosisRuntimeException: Node -1752 does not have a version attribute as OSM 0.6 are required to have.  Is this a 0.5 file?" + the errors
- and then "GRAVE: Execution aborted.

org.openstreetmap.osmosis.core.OsmosisRuntimeException: One or more tasks failed.' which I believe come from the same problem ...

Message has been deleted

Emux

unread,
Jun 23, 2014, 3:40:13 PM6/23/14
to mapsfo...@googlegroups.com
Ok now we're getting into the OSM stuff.

I don't know how you create your osm file, but the elements inside it should have a 'version' and a 'timestamp' attribute to be compatible with the latest osm 0.6 version.

I suggest to download a small osm file from Geofabrik to see its structure.

Viala Simon-Alexandre

unread,
Jun 23, 2014, 3:43:28 PM6/23/14
to mapsfo...@googlegroups.com
I'll check that, but how do I open the .pbf file ? 

Viala Simon-Alexandre

unread,
Jun 23, 2014, 4:22:39 PM6/23/14
to mapsfo...@googlegroups.com
I just started a tutorial on how-to for the future application, my report, and perhaps put it online so that other beginners may use it ... 

Did I made a mistake / forgot something ? 
tutorial.pdf

Viala Simon-Alexandre

unread,
Jun 23, 2014, 5:37:36 PM6/23/14
to mapsfo...@googlegroups.com
I am sorta advancing here, but I have a few silly questions to ask. 

- I opened with an XML editor my pva.osm, and found out that my nodes had irrelevant coordinates (for instance : <node id='-1686' visible='true' lat='-36.18028516938705' lon='-88.4656380240849' />) ; that's because I did not specified any coordinates when I created my JOSM project, since I thaught it didn't matter. Was it a mistake ? 

- Where some codes begin with : 
"<?xml version='1.0' encoding='UTF-8'?>
<osm version="0.6" generator="osmconvert 0.7P" timestamp="2013-12-12T20:55:02Z">"
mine begins with : 

"<osm version='0.6' upload='true' generator='JOSM'>" 

I do not have any timestamp, how can I change that ? 

Emux

unread,
Jun 24, 2014, 2:12:04 AM6/24/14
to mapsfo...@googlegroups.com
I'll check that, but how do I open the .pbf file ?

PBF is a binary format.

Download a .osm.bz2 file, it's a zipped osm.
Unzip it and read the osm with an xml editor.

Viala Simon-Alexandre

unread,
Jun 24, 2014, 2:29:43 AM6/24/14
to mapsfo...@googlegroups.com
So if I picture it right, it is a big deal if it is not the right coordinates in the osm file ....! Can I change them on the xml file ? 

Emux

unread,
Jun 24, 2014, 2:31:51 AM6/24/14
to mapsfo...@googlegroups.com
- I opened with an XML editor my pva.osm, and found out that my nodes had irrelevant coordinates (for instance : <node id='-1686' visible='true' lat='-36.18028516938705' lon='-88.4656380240849' />) ; that's because I did not specified any coordinates when I created my JOSM project, since I thaught it didn't matter. Was it a mistake ?

Your coordinates should be within your bounding box.
It all depends how you create your osm file, by hand, converting a shp file, with a osm specific tool..


- Where some codes begin with : 
"<?xml version='1.0' encoding='UTF-8'?>
<osm version="0.6" generator="osmconvert 0.7P" timestamp="2013-12-12T20:55:02Z">"
mine begins with : 

"<osm version='0.6' upload='true' generator='JOSM'>" 

I do not have any timestamp, how can I change that ?


OSM xml files contain usually nodes, ways and relations.
At those data primitives it's required to have 'version' and 'timestamp'.
OSM is just an xml file, you can edit it with an xml editor.
But it's better to do this automatically with some osm editor.

Viala Simon-Alexandre

unread,
Jun 24, 2014, 2:42:22 AM6/24/14
to mapsfo...@googlegroups.com
Okay so I should modify my xml file by hand for : 

- the top : adding a timestamp, can I do it by hand ? 

- the coordinates 

- the version. What does that mean ? 

- other timestamps for each node (by hand again ?) 


Emux

unread,
Jun 24, 2014, 3:03:17 AM6/24/14
to mapsfo...@googlegroups.com
I just started a tutorial on how-to for the future application, my report, and perhaps put it online so that other beginners may use it ... 

Did I made a mistake / forgot something ?

Ok I have read your tutorial and see that you create the osm file within the JOSM on top of a background picture of the indoor area.
Though I have not used this procedure, in order to know exactly how to make JOSM write 'version' or 'timestamp' at each node, way and relation.

Viala Simon-Alexandre

unread,
Jun 24, 2014, 3:15:57 AM6/24/14
to mapsfo...@googlegroups.com
So I can't just add them in my xml file ...! 

Emux

unread,
Jun 24, 2014, 3:20:38 AM6/24/14
to mapsfo...@googlegroups.com
Of course you can,
either by hand after the osm creation (with an xml editor)
or before inside JOSM by adding the needed tags one by one.

But I should prefer if JOSM would do that automatically.
I think there must be a way..

Viala Simon-Alexandre

unread,
Jun 24, 2014, 3:39:09 AM6/24/14
to mapsfo...@googlegroups.com
I'm looking for this way ! Anyway my building's position is not right ( it's been put in-between the Pacific ocean and the Atlantic ocean !!), so I should also modify this. 

Viala Simon-Alexandre

unread,
Jun 24, 2014, 5:32:43 AM6/24/14
to mapsfo...@googlegroups.com
I now have "The entity timestamp attribute is missing." Any idea on what I could add (i'll type it, i con't find on JOSM what to do !!) ?
Message has been deleted

Emux

unread,
Jun 24, 2014, 6:11:53 AM6/24/14
to mapsfo...@googlegroups.com
timestamp could be something like this:
2014-06-14T09:00:00Z

Viala Simon-Alexandre

unread,
Jun 24, 2014, 6:16:00 AM6/24/14
to mapsfo...@googlegroups.com
New xml file : 
pva4.xml

Viala Simon-Alexandre

unread,
Jun 24, 2014, 8:54:18 AM6/24/14
to mapsfo...@googlegroups.com
Perfect ! It worked ! hallelujah, i now have a pva.map ! To see it, I now have to use Atlas, am I right ? 
Message has been deleted

Emux

unread,
Jun 24, 2014, 9:15:31 AM6/24/14
to mapsfo...@googlegroups.com
This is one way to view it.
Eventually you have to check if the map file was build correctly
and start playing with the render theme rules.

Reply all
Reply to author
Forward
0 new messages