Skip to content

read from GeoJSON export of boundaries.osm - #2658

Merged
karussell merged 15 commits into
masterfrom
better_country_borders
Sep 22, 2022
Merged

karussell merged 15 commits into
masterfrom
better_country_borders

Conversation

@karussell

@karussell karussell commented Sep 14, 2022 •

Copy link
Copy Markdown
Member

Fixes #2394. This seems to work (mostly) and the higher precision is indeed visible when routing and the file is even smaller :)

But there is a problem in the boundaries.osm file. The problem might be that the type of the relation member is 'way' but should be 'relation' to create separate Polygons inside the MultiPolygon. This leads to an incorrect handling downstream in our AreaIndex and country lookup because it thinks that there is just a single Polygon with a shell and several holes. (I think I can exclude a bug in our deserializer because when rearranging the coordinates of the MultiPolygon it reads it as expected)

to do:

  • fix MultiPolgons
  • remove the original countries_josm.geojson file from the classpath

@karussell karussell added this to the 7.0 milestone Sep 14, 2022
@karussell
karussell marked this pull request as draft September 14, 2022 08:08
@otbutz

otbutz commented Sep 14, 2022

Copy link
Copy Markdown
Contributor

@karussell

karussell commented Sep 14, 2022 •

Copy link
Copy Markdown
Member Author

I created a converter which fixes the problems of the exported boundaries.geojson file. With the produced GeoJSON all the tests pass now.

@otbutz

otbutz commented Sep 14, 2022

Copy link
Copy Markdown
Contributor

@westnordost this could also be interesting for you, since you mentioned that you contributed upstream

@otbutz

otbutz commented Sep 14, 2022

Copy link
Copy Markdown
Contributor

@karussell should we run the converter as part of the maven build using exec:java?

@westnordost

westnordost commented Sep 14, 2022 •

Copy link
Copy Markdown

Thanks for the ping. However, I am not sure what is reported in https://josm.openstreetmap.de/ticket/22372
Is it a bug in the JOSM export as GeoJson feature or in the actual boundaries.osm? Possibly, it is not even a bug in either of the two but the export as GeoJson feature simply doesn't work (as expected) for the boundaries.osm specifically because the latter does not consist of "normal" OSM data. I.e. JOSM doesn't know whether to export the closed ways that make up the boundary as a polyline or as a polygon because there is no area=yes or similar tagged on them.

Regarding countryboundaries library: It takes the boundaries.osm as input directly. The "generator" java console application can output a geojson too, but this is implemented explicitly, e.g. https://github.com/westnordost/countryboundaries/blob/master/generator/src/main/java/de/westnordost/countryboundaries/GeoJsonWriter.java

@westnordost

westnordost commented Sep 14, 2022 •

Copy link
Copy Markdown

So maybe you want to read the *.osm file directly. This should work smoother as part of the build process too, because you do not have the manual step of opening that file in JOSM and exporting it to geojson but can directly pull the file from the JOSM repo.

Here is the Java code I use, it uses JTS too:
https://github.com/westnordost/countryboundaries/blob/master/generator/src/main/java/de/westnordost/countryboundaries/JosmCountryBoundariesReader.java

If you like to use that, you can use it and the associated tests under the terms of the Apache license 2.0.

@karussell

Copy link
Copy Markdown
Member Author

@karussell should we run the converter as part of the maven build using exec:java?

An update from time to time which we can manually review is better IMO. (does not seem to update too often)

I.e. JOSM doesn't know whether to export the closed ways that make up the boundary as a polyline or as a polygon because there is no area=yes or similar tagged on them.

Ah, ok. Yes, this is then probably the case.

And thanks a lot for the hint regarding your boundaries reader and letting us use the code (and its tests!) under the Apache license, still probably we'll just use the geojson export directly. Will see how it works :)

@karussell
karussell marked this pull request as ready for review September 15, 2022 08:27
@karussell

karussell commented Sep 15, 2022 •

Copy link
Copy Markdown
Member Author

Thanks @westnordost - this works now and creating this with your tool is a better solution than the more involved process with josm and the converter before. Also less code changes are required.

For simplicity I attach the generator.zip I used.

@karussell

karussell commented Sep 15, 2022 •

Copy link
Copy Markdown
Member Author

Ok, with westnordost/countryboundaries#10 and the latest commit we can now use the unmodified version to create the countries.geojson file -> generator.zip

@easbar easbar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, great news you were able to improve the country border resolution! I took a look at the code only, it seems like you already tested the quality of the new country file.


private final String name;
private final String twoLetterCode;
private final String displayName;

@easbar easbar Sep 22, 2022 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

displayName sounds like you need to distinguish the name and a displayName? But there is no name? Ok, maybe this String is the displayName of the country code rather than the name of the country, but then the enum should be called CountryCode... Or we need to think of Country being a country code that has a display name. Because Afghanistan is certainly the name of the country Afghanistan, and not its display name :) But it is the display name of the AFG country code (rather than its name)... Anyway, for simplicity my vote goes for Country and name :) But not so important.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But there is no name?

I thought so too, but there is: the name() method of the enum itself and it was confusing to have getName() and name() and both returning two different things.

But I surely understand your argument regarding the name of the country. Hm.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. Maybe getCountryName()?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good idea!

@karussell
karussell merged commit 65b70f9 into master Sep 22, 2022
@karussell
karussell deleted the better_country_borders branch September 22, 2022 20:35
@easbar

easbar commented Sep 22, 2022

Copy link
Copy Markdown
Member

Nice, thanks!

@karussell

Copy link
Copy Markdown
Member Author

Thanks to you and @westnordost + @otbutz. A lot of nice improvements since I started :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can we improve the country borders file?

4 participants