Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AtlasDelta and AtlasDeltaGenerator Revamp #195

Merged
merged 10 commits into from
Aug 16, 2018
Merged

Conversation

hallahan
Copy link
Contributor

Description:

This PR re-implements AtlasDeltaGenerator, as the old implementation was not working. Now, this tool will generate GeoJSON both for the features as well as the relations. It will also output the text-based "diff view friendly string".

Potential Impact:

AtlasDelta is mainly used for testing and data verification.

Unit Test Approach:

Because this PR is focused on the GeoJSON generation, I have AtlasDeltaGeoJsonIntegrationTest generate GeoJSON and assert certain things about it such as:

  • length of serialized JSON
  • feature count
  • if the features have the necessary diff related properties

Test Results:

In addition, I have been running AtlasDeltaGenerator on various atlases (just shards), and then take the generated GeoJSON and look at it in JOSM.

Note that I'm continuing with the existing approach where we separate relations from nodes and ways in the delta GeoJSONs. This helps reduce noise, because typically when a relation is modified, a lot of underlying geometry is affected.

@hallahan
Copy link
Contributor Author

Improved docs for making shaded JAR and setting up in IntelliJ IDEA.


```
java -cp atlas-5.1.8-SNAPSHOT-shaded.jar org.openstreetmap.atlas.geography.atlas.delta.AtlasDeltaGenerator <args...>
```
Copy link
Contributor

Choose a reason for hiding this comment

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

Great README addition.

if (afterEntity != null)
{
final Map<String, String> afterTags = afterEntity.getTags();
afterTags.put("diff", "AFTER");
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like this is the only difference between these code blocks. Maybe could move the if(null) check here and avoid duplicating a lot of this code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great point, I will change this.

@@ -36,28 +36,29 @@
* Difference between two {@link Atlas}.
*
* @author matthieun
* @author hallahan
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure a variable name change warrants an author tag ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

LOL, yeah, you're right! I'll take it out. I didn't realize I did it for that file.

*/
@Test
public void parseGeoJson()
{
Copy link
Contributor

Choose a reason for hiding this comment

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

This functionality is going to be a huge win.


final AtlasDelta delta = new AtlasDelta(beforeAtlas, afterAtlas).generate();

final String txt = delta.toDiffViewFriendlyString();
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: we try to avoid any and all abbreviations in atlas. We would prefer text over txt. If I didn't say it I know @MikeGost would have :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, I'll change that!

final AtlasDelta delta = new AtlasDelta(beforeAtlas, afterAtlas).generate();

final String txt = delta.toDiffViewFriendlyString();
final File txtFile = new File(
Copy link
Contributor

Choose a reason for hiding this comment

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

Same thing here.

@@ -1,6 +1,6 @@
# `PackedAtlas`

This is the base `Atlas`. It is immutable, and stores all its items in large arrays in memory.
This is the before `Atlas`. It is immutable, and stores all its items in large arrays in memory.
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the new before/after naming choices over base/alter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, I was hoping it was ok.

Copy link
Contributor

@lucaspcram lucaspcram left a comment

Choose a reason for hiding this comment

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

I really like these changes. Just see my minor nit about a variable name :)

private static final Switch<File> OUTPUT_FOLDER_SWITCH = new Switch<>("outputFolder",
"The path of the output folder", string -> new File(string), Optionality.REQUIRED);
private static final Switch<Path> OUTPUT_DIR_SWITCH = new Switch<>("outputDir",
"The path of the output directory.", Paths::get, Optionality.REQUIRED);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: outputDir -> outputDirectory. As @lucaspcram said we try to avoid abbreviations, even popular ones

lucaspcram
lucaspcram previously approved these changes Aug 15, 2018
@hallahan
Copy link
Contributor Author

Ok @lucaspcram and @jwpgage , ready for another review!

lucaspcram
lucaspcram previously approved these changes Aug 15, 2018
MikeGost
MikeGost previously approved these changes Aug 15, 2018
Copy link
Contributor

@MikeGost MikeGost left a comment

Choose a reason for hiding this comment

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

Nice changes @hallahan! Couple minor nits regarding abbreviations.

public void testGeoJson()
{
final String geoJson = delta.toGeoJson();
final int len = geoJson.length();
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: len --> length

public void testRelationsGeoJson()
{
final String relationsGeoJson = delta.toRelationsGeoJson();
final int len = relationsGeoJson.length();
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: same

@hallahan hallahan dismissed stale reviews from MikeGost and lucaspcram via 3043dc7 August 16, 2018 01:04
@hallahan
Copy link
Contributor Author

Ok, @MikeGost , ready for review / merge? Fixed len abbrev.

@lucaspcram lucaspcram merged commit 1686af6 into osmlab:dev Aug 16, 2018
@MikeGost
Copy link
Contributor

Looks good! I'm comfortable with the merge, wanted @matthieun to look at it first since he was original author.

@lucaspcram
Copy link
Contributor

Ah sorry. Looks like I jumped the gun on this one.

@hallahan
Copy link
Contributor Author

@MikeGost and @lucaspcram - I'll have another PR out today, and maybe @matthieun can chime in and I can make any changes needed there?

@MikeGost
Copy link
Contributor

@hallahan Sounds good! @lucaspcram you're fine!

@matthieun matthieun added this to the 5.1.9 milestone Aug 27, 2018
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.

5 participants