Josm: is it posible to download multipolygons automatically?

Is there some option in josm to download multipolygons automatically?

When I download osm data by rectangular area, a lot of multipolygons come broken. It’s very annoying.

I believe not. If an area has many relations, when downloading you could end up with a large amount of data outside the area, which may cause JOSM to become slow due to increased memory usage. When you download by a rectangular boundary, you are already indicating that you want a limited amount of data.

However, you can download only the members of the relation of interest (or all of them).
Select a line or point that belongs to a relation, then in the tags panel select one or more relations, right-click, and choose one of the available options.

1 Like

I believe not.

@DressyPear4, thank you for answer. I’ve already started to afraid that I am missing something obvious – after 15 years in the project :rofl:

I was speaking about multipolygons only. Downloading them should not fetch the whole planet. Strange a bit that it was not recognized as a problem yet by anybody.

But OK, I will think how to live with that :slight_smile:

It might not fetch the whole planet, but there are some very large multipolygons out there – the Florida Keys National Marine Sanctuary, for example, breaks programs on a regular basis with its 2662 members.

3 Likes

Or you can use a script (Scripting plugin) to download all missing members from the dataset.
“Jython Script: Download all missing Multipolygon members”

from org.openstreetmap.josm.gui import MainApplication, Notification
from org.openstreetmap.josm.gui.dialogs.relation import DownloadRelationMemberTask
from javax.swing import UIManager

def download_all_multipolygon_members():
    # 1. Check for active layer and manager safely
    manager = MainApplication.getLayerManager()
    if manager is None:
        return

    edit_layer = manager.getEditLayer()
    if not edit_layer:
        Notification("No active edit layer found.") \
            .setIcon(UIManager.getIcon("OptionPane.warningIcon")) \
            .show()
        return

    dataset = edit_layer.data
    if not dataset:
        return

    relations = dataset.getRelations()
    task_count = 0

    # 2. Iterate and identify incomplete multipolygons
    for relation in relations:
        if relation.get("type") == "multipolygon" and relation.hasIncompleteMembers():
            incomplete_members = relation.getIncompleteMembers()
            
            # 3. Create download task
            task = DownloadRelationMemberTask(relation, incomplete_members, edit_layer)
            
            # 4. Execute in worker pool
            try:
                MainApplication.workerPool.execute(task)
                task_count += 1
            except AttributeError:
                task.run()
                task_count += 1

    # 5. Final Notifications with UIManager icons
    if task_count == 0:
        Notification("No incomplete members found.") \
            .setIcon(UIManager.getIcon("OptionPane.informationIcon")) \
            .show()
    else:
        msg = "Downloading members for {} multipolygons.".format(task_count)
        Notification(msg) \
            .setIcon(UIManager.getIcon("OptionPane.informationIcon")) \
            .show()

# Execution
download_all_multipolygon_members()
1 Like

To give another example, Lake Huron (relation 1205151) is a multipolygon with 14 thousand members.

So if someone does want to run a script to download automatically (like @DressyPear4), I suggest adding a check for number of members and only proceeding if it’s not more than a few hundred or so…

2 Likes

Maybe I am stupid, but I do not get it. If those huge relations are not downloadable, what’s the point of them at all?

Also, it seems that I’ve found a bug in Josm. If I download lake Huron via “File–> Download Object”, it loads quite fast. but if I download a rectangle somewhere there, and then select the relation and click "download incomplete members", the process never ends.

They are definitely downloadable, but they’re at a scale where you might not want to download them unknowingly.

Just like the planet is downloadable…

3 Likes

image

Those are two very different operations. If you download the object as a whole, that’s just one request sent to the API (https://wiki.openstreetmap.org/wiki/API_v0.6#Full:_GET_/api/0.6/[way|relation]/#id/full).
If you ask JOSM to download only the incomplete relation members, it has to send individual requests for those elements (or possibly batch requests via multi-fetch https://wiki.openstreetmap.org/wiki/API_v0.6#Multi_fetch:_GET_/api/0.6/[nodes|ways|relations]?#parameters). Either way it’s going to end up with more requests and more work when there are that many incomplete members.

Now, this process could potentially be optimized in some cases to speed it up, but as always “Someone Needs To Do It” :tm:

2 Likes