Thursday, August 20, 2015

Wrapping things up

As you may know, the Google Summer of Code deadline is around the corner, so it's high time I wrap things up in Marble's OpenStreetMap editor.

Firstly, a quick summary on what's been done since the program started, in case you aren't aware of what my project consists in: I'm working on offering support for ".osm" maps in Marble's map editor. This implies importing the ".osm" files, editing them with appropriate tools and presets, and finally, exporting them.

Parsing and writing ".osm" files

Before my involvement, Marble already had an ".osm" file parser, but it was only focused on translating the OSM features to valid KML ones, without saving a lot of relevant data.
Fully supporting OSM maps meant that this was not the case anymore, so a new OSM style back-end data structure had to be implemented.

The ".osm" file exporting part was absent, so it had to be done from scratch. Keeping in mind the differences between the OSM and KML schemas, a lot of translations had to be done, while still maintaining the data valid. The solution to that was mainly making use of KML's ExtendedData feature, that allows custom data to be inserted into objects. This also meant that conversion between file formats is somewhat possible ( with a few drawbacks ). 

An almost full cycle can be done while importing and exporting:

Editing tags

Tags are elements that give meaning to placemarks: A point without tags is just that, a point on the map; adding "amenity=hospital" or "amenity=place_of_worship" certainly adds more sense to that. They are used by renderer in order to offer customized looks, but also by certain search algorithms, to make them more relevant while looking up places.

With that in mind, having a neat way to add and edit tags is bound to be a critical step in offering OSM support in Marble. And so was done: when creating any kind of placemark within the Annotate plugin, adding tags is now possible in an interactive way. Based on the current tags, new, relevant tags that fit are dynamically suggested:

Editing relations

Relations are used to model logical relationships between various places (members) on the map.
A good example for a relation would be a bus route with the ways over which the bus travels and the bus stops as its members.

Such functionality could not be missing from Marble, so a way to handle them had to be implemented:
Placemarks within the Annotate Plugin can now be easily added to existing or newly created relations. The relation editor makes use of the tag editor mentioned earlier, offering users the possibility to highly customize their relations while keeping them close to the OSM recommended standards:

Let's a assume we want to create a bus route. We first create street on which the bus travels.

We now go to the Relations tab, and we create a new relation!

Now we create a return way for the bus, and add it to the existing relation ( Bus Route #1 ):

Finally we create a bus stop, and add it to the relation:

And that's it, we have a functional bus route, easy to look up for lost tourists that want to move around.

Finishing touches and TO-DOs

Creating a complete OSM editor is certainly no easy task, so obviously there's room for improvement. During the summer the base was founded: creating the core data elements  ( tags, relations ) manipulation tools. Adding more "map-making" convenience tools is definitely a neat goal for the upcoming period. Such tools might include: mouse-scroll height manipulation for placemarks, preset polygon shapes, parallel way builder and more crazy ideas I'd rather not mention.

Sunday, August 16, 2015

OSM tags in Marble's map editor

OpenStreetMap(OSM) tags play an important role in both rendering and searching for placemarks in any OSM based map. This makes editing them inside Marble an absolute must.

Since the last update, I've been working on a widget that allows the user intuitively, edit tags for any placemark loaded within Marble's Annotate plugin. Here's what I've come with:

For the purpose of better presenting the editor, let's assume this scenario: We want to create St Paul's
Cathedral in London in the Annotate plugin.

After creating a new placemark, we can already browse through it's current tags ( currently only the name one ):
A bunch of tags are already visible in the recommended list.

Let's choose amenity = place_of_worship!

When the place_of_worship is chosen, the editor dynamically generates a new set of recommended tags that fit the current tags:

Let's choose religion=christian!

As before, the recommended list updates, now suggesting us tags that require us to insert our own values:

As we had inserted the addr:postcode
and addr:street, we finished editing the placemark!

Now let's add a cemetery ( fictional ) ! The tag editor works almost exactly the same for polygons and ways:

And a weird path to the entrance:

That's it for this update, more on the way!

Wednesday, July 1, 2015

Road so far

As GSOC's mid-term is closing in, I thought I'd share what's been done so far! In case you haven't seen my earlier posts, here's a quick reminder on what I'm working on: implementing an Open Street Map (OSM) editor for Marble that allows the user to import ".osm" files, edit them with OSM-specific tools, and finally export them into ready-for-upload files. All that inside Marble's existing Annotate Plugin ( editor for ".kml" maps ).

What's been done so far?  

As one would imagine, OSM( ) has noticeable differences from KML ( ), the schema upon which Marble is built. These differences, from an OSM perspective, mainly consist in server-generated data such as id, changeset, timestamp etc. but also in core data elements, such as the <relation> and <tag> tags.

Up until now, I've developed a way to store this server-generated data, mainly by saving it
as KML's  ExtendedData. Exporting to ".osm" files is now possible as well, so that pretty much makes Marble a KML-to-OSM ( and in reverse )  translator at the moment ( it has some draw backs of course )

What was the main challenge?
Not everything can be translated perfectly from OSM to KML and vice-versa, so while translating, I had to ensure as little data as possible is lost.

Since data parsing isn't a really picture-worthy topic, here is an example of a map's journey through Marble's editor:

The OSM version of a highway: "sample highway"
<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="Marble 0.21.23 (0.22 development version)">
    <node lat="-23.7082750358" lon="-4.4577696853" id="-1" action="modify" visible="false"/>
    <node lat="-21.0946495732" lon="-11.9900406335" id="-2" action="modify" visible="false"/>
    <node lat="-16.6010784801" lon="-6.7785258299" id="-3" action="modify" visible="true">
        <tag k="name" v="sample placemark"/>
    <way id="-75891" action="modify" visible="true">
        <tag k="name" v="sample highway"/>
        <tag k="highway" v="residential"/>
        <nd ref="-1"/>
        <nd ref="-2"/>

The KML version of it after going through Marble's editor: The osm data( that is irrelevant from a KML perspective ) is stored within an ExtendedData block
            <name>sample highway</name>
            <ExtendedData xmlns:osm_data="Marble/temporary/namespace">
                <osm_data:OsmDataSnippet id="-75891" visible="true">
                        <osm_data:tag k="highway" v="residential"/>
                        <osm_data:nd count="0">
                            <osm_data:OsmDataSnippet id="-1" visible="false" action="modify"/>
                        <osm_data:nd count="1">
                            <osm_data:OsmDataSnippet id="-2" visible="false" action="modify"/>
                <coordinates>-4.457769,-23.708275 -11.990040,-21.094649</coordinates>

Sunday, May 31, 2015

Getting started!

How about that!? Google Summer of Code coding period started ( quite a while ago though ) and I thought I'd share some of my enthusiasm with you!

Firstly, impression about the program itself:

From what I've seen so far, the best part is definitely having the chance to code along with such great people, while getting precious feedback. This is what I've lacked so far in my experience as a student, and it certainly is the best way to get introduced to open-source software ( especially KDE :D ).

Now about the project:

My work this summer will revolve around offering OpenStreetMap( OSM ) support to Marble: this will involve offering the user a complete experience: from opening OSM files, to viewing and editing them, to finally exporting them in ".osm" files. 

Some of the work is already done, yet it still requires some tweaking, some technical bits will involve some code refactoring, and some parts( the most exciting ones ) consist of creating specialized tools for the map editor. 

Here's a sample to give you an idea of what interesting stuff I'm working on:

(Mock-up on what editing OSM relations might look like)

Adding them to a relation
Settings tags for that relation

Well, that's all folks! I hope I've passed some of my enthusiasm, and if that's the case, stay tuned for my progress along the summer, as I'll be posting more :D