Modify

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#18902 closed defect (duplicate)

Polygons are exported to GeoJSON as linestrings

Reported by: Zverikk Owned by: team
Priority: normal Milestone:
Component: Core geojson Version: latest
Keywords: geojson Cc:

Description

How to reproduce:

  1. Create an empty layer.
  2. Draw a closed way.
  3. Save as GeoJSON.
  4. Look inside.

The feature is saved as a LineString, despite it being closed.

Adding "area=yes" or even "natural=water" does not help — although I'd prefer for polygons to be exported without any properties at all, defaulting to this type with no tags.

This would make JOSM highly useful for maintaining polygon bounds for osmium tool and such.

Attachments (0)

Change History (9)

comment:1 by GerdP, 4 years ago

Resolution: duplicate
Status: newclosed

Closed as duplicate of #17453.
You can set prefernce geojson.export.untagged-closed-is-polygon=true to force type Polygon.

Version 0, edited 4 years ago by GerdP (next)

comment:2 by GerdP, 4 years ago

Setting natural=water should also work as long as your map style renders it as an area.

comment:3 by Zverikk, 4 years ago

Thanks for the tip. Double-checking the styling panel and enabling one that shows natural=water as an area helps.

But.

Defaulting to exporting closed ways as linestrings is really non-obvious, and having to enable expert mode, opening advanced preferences tab, searching for this long-named key and toggling it, only to make JOSM behave in an obvious way, feels broken. Using the default JOSM style disables nodes on low zooms by default, which doesn't help with drawing boundaries on a country scale. And adding OSM tags on polygons just to make JOSM produce polygons again seems extra. This essentially makes the editor unsuitable for anything besides editing actual OSM data. No editing of GeoJSON (because it would break them), no making polygon boundaries for any external tools.

Is there a reason why this was made the default?

comment:4 by GerdP, 4 years ago

I don't know the reasons, I didn't code it. See my thoughts in ticket:17453#comment:8 and below

comment:5 by GerdP, 4 years ago

If you ask why I didn't change the default with r15429 so that an untagged closed way is exported as a Polygon:
I don't know how important the old behaviour is for other users, so it seemed less dangerous to add an option.

comment:6 by Zverikk, 4 years ago

Would you change it if I made a ticket for switching the default? Judging by #18903, not many people use this feature, and defaulting to polygons would be easier to understand.

comment:7 by GerdP, 4 years ago

You can try, I have no idea how many users there are.

comment:8 by anonymous, 4 years ago

I am currently drawing some suburb boundaries and I really need to export them as .geojson polygons. instead i get an array of linestrings. i already changes the preference mentioned in this thead but i still get the linestrings despite the fact that the paths are closed. can someone tell me the exact steps in order to export a suburb as a polygon in geojson format

comment:9 by GerdP, 4 years ago

If your (closed) way is tagged you have to make sure that the mapstyle renders it as area.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.