-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removing superfluous Atlas Point (#48)
* Removing superfluous Atlas Point and tests * Fixing javadoc warning * Using text atlas files instead of .osm files to properly test Atlas creation * undoing text atlas conversion * Explaining PBF presence as test data
- Loading branch information
Showing
12 changed files
with
475 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
168 changes: 168 additions & 0 deletions
168
src/test/java/org/openstreetmap/atlas/geography/atlas/pbf/OsmPbfNodeToAtlasItemTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
package org.openstreetmap.atlas.geography.atlas.pbf; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.openstreetmap.atlas.geography.Latitude; | ||
import org.openstreetmap.atlas.geography.Location; | ||
import org.openstreetmap.atlas.geography.Longitude; | ||
import org.openstreetmap.atlas.geography.atlas.Atlas; | ||
import org.openstreetmap.atlas.geography.atlas.items.Node; | ||
import org.openstreetmap.atlas.geography.atlas.items.Point; | ||
import org.openstreetmap.atlas.utilities.collections.Iterables; | ||
|
||
/** | ||
* Tests OSM Node to Atlas {@link Node} and {@link Point} conversion given various use cases. | ||
* | ||
* @author mgostintsev | ||
*/ | ||
public class OsmPbfNodeToAtlasItemTest | ||
{ | ||
private static final Location OSM_NODE_LOCATION = new Location(Latitude.degrees(7.014003), | ||
Longitude.degrees(-10.5466545)); | ||
|
||
@Rule | ||
public final OsmPbfNodeToAtlasItemTestRule setup = new OsmPbfNodeToAtlasItemTestRule(); | ||
|
||
@Test | ||
public void testOsmNodeNotInRelationNoTagsAtIntersection() | ||
{ | ||
// Two OSM Ways intersecting at an OSM Node, that has no tags. We expect two Atlas Nodes | ||
// created at the end points of each way and an Atlas Node at the intersection. | ||
final Atlas atlas = this.setup.getNoRelationNoTagsAtIntersectionAtlas(); | ||
final Iterable<Node> nodes = atlas.nodesAt(OSM_NODE_LOCATION); | ||
final Iterable<Point> points = atlas.pointsAt(OSM_NODE_LOCATION); | ||
|
||
// Verify a Node was created at the middle location | ||
assertEquals(1, Iterables.size(nodes)); | ||
assertEquals(0, Iterables.size(points)); | ||
|
||
// Verify nodes created at both end points and middle | ||
assertEquals(5, Iterables.size(atlas.nodes())); | ||
} | ||
|
||
@Test | ||
public void testOsmNodeNotInRelationNoTagsNotAtIntersection() | ||
{ | ||
// Single OSM Way with an OSM Node in the middle without tags. We expect two Atlas Nodes | ||
// created at the end points with a shape point in the middle. | ||
final Atlas atlas = this.setup.getNoRelationNoTagsNoIntersectionAtlas(); | ||
final Iterable<Node> nodes = atlas.nodesAt(OSM_NODE_LOCATION); | ||
final Iterable<Point> points = atlas.pointsAt(OSM_NODE_LOCATION); | ||
|
||
// Verify nothing was created at the middle location | ||
assertEquals(0, Iterables.size(nodes)); | ||
assertEquals(0, Iterables.size(points)); | ||
|
||
// Verify nodes created at end points | ||
assertEquals(2, Iterables.size(atlas.nodes())); | ||
} | ||
|
||
@Test | ||
public void testOsmNodeNotInRelationWithTagsAtIntersection() | ||
{ | ||
// Two OSM Ways intersecting at an OSM node, that has tags. We expect two Atlas Nodes | ||
// created at the end points of each line and both an Atlas Node and an Atlas Point at the | ||
// intersection. | ||
final Atlas atlas = this.setup.getNoRelationWithTagsAtIntersectionAtlas(); | ||
final Iterable<Node> nodes = atlas.nodesAt(OSM_NODE_LOCATION); | ||
final Iterable<Point> points = atlas.pointsAt(OSM_NODE_LOCATION); | ||
|
||
// Verify a Node was created at the middle location | ||
assertEquals(1, Iterables.size(nodes)); | ||
assertEquals(1, Iterables.size(points)); | ||
|
||
// Verify nodes created at both end points and middle | ||
assertEquals(5, Iterables.size(atlas.nodes())); | ||
} | ||
|
||
@Test | ||
public void testOsmNodeNotInRelationWithTagsNotAtIntersection() | ||
{ | ||
// Single OSM Way with an OSM Node in the middle with tags. We expect two Atlas Nodes | ||
// created at the end points and an Atlas Point in the middle. | ||
final Atlas atlas = this.setup.getNoRelationWithTagsNoIntersectionAtlas(); | ||
final Iterable<Node> nodes = atlas.nodesAt(OSM_NODE_LOCATION); | ||
final Iterable<Point> points = atlas.pointsAt(OSM_NODE_LOCATION); | ||
|
||
// Verify a Point was created at the middle location | ||
assertEquals(0, Iterables.size(nodes)); | ||
assertEquals(1, Iterables.size(points)); | ||
|
||
// Verify nodes created at end points | ||
assertEquals(2, Iterables.size(atlas.nodes())); | ||
} | ||
|
||
@Test | ||
public void testOsmNodePartOfRelationNoTagsAtIntersection() | ||
{ | ||
// Two OSM Ways meeting at an OSM node with no tags. The two ways are part of a no u-turn | ||
// restriction with the OSM Node as the Via role. We expect two Atlas Nodes | ||
// created at the end points and a Node in the middle. | ||
final Atlas atlas = this.setup.getPartOfRelationNoTagsAtIntersectionAtlas(); | ||
final Iterable<Node> nodes = atlas.nodesAt(OSM_NODE_LOCATION); | ||
final Iterable<Point> points = atlas.pointsAt(OSM_NODE_LOCATION); | ||
|
||
// Verify a Node was created at the middle location | ||
assertEquals(1, Iterables.size(nodes)); | ||
assertEquals(0, Iterables.size(points)); | ||
|
||
// Verify nodes created at end points and middle | ||
assertEquals(3, Iterables.size(atlas.nodes())); | ||
} | ||
|
||
@Test | ||
public void testOsmNodePartOfRelationNoTagsNotAtIntersection() | ||
{ | ||
// Three OSM Nodes are part of a Relation. Two of them have tagging, and the middle one | ||
// doesn't. We expect all 3 to show up as Atlas Points. | ||
final Atlas atlas = this.setup.getPartOfRelationNoTagsNoIntersectionAtlas(); | ||
final Iterable<Node> nodes = atlas.nodesAt(OSM_NODE_LOCATION); | ||
final Iterable<Point> points = atlas.pointsAt(OSM_NODE_LOCATION); | ||
|
||
// Verify a single Point was created at the untagged location | ||
assertEquals(0, Iterables.size(nodes)); | ||
assertEquals(1, Iterables.size(points)); | ||
|
||
// Verify only Points were created | ||
assertEquals(3, Iterables.size(atlas.points())); | ||
assertEquals(0, Iterables.size(atlas.nodes())); | ||
} | ||
|
||
@Test | ||
public void testOsmNodePartOfRelationWithTagsAtIntersection() | ||
{ | ||
// Two OSM Ways meeting at an OSM node with barrier tags. The two ways are part of a no | ||
// u-turn restriction with the OSM Node as the Via role. We expect two Atlas Nodes | ||
// created at the end points and an Atlas Node in the middle. | ||
final Atlas atlas = this.setup.getPartOfRelationWithTagsAtIntersectionAtlas(); | ||
final Iterable<Node> nodes = atlas.nodesAt(OSM_NODE_LOCATION); | ||
final Iterable<Point> points = atlas.pointsAt(OSM_NODE_LOCATION); | ||
|
||
// Verify a Node was created at the middle location | ||
assertEquals(1, Iterables.size(nodes)); | ||
assertEquals(1, Iterables.size(points)); | ||
|
||
// Verify nodes created at end points and middle | ||
assertEquals(3, Iterables.size(atlas.nodes())); | ||
} | ||
|
||
@Test | ||
public void testOsmNodePartOfRelationWithTagsNotAtIntersection() | ||
{ | ||
// A single OSM Way and a single OSM Node (with tags), with a relation associating the Node | ||
// as a house to the Way as the Street. We expect two Atlas Nodes created at the end points | ||
// of the Way and an Atlas Point to represent the house. | ||
final Atlas atlas = this.setup.getPartOfRelationWithTagsNoIntersectionAtlas(); | ||
final Iterable<Node> nodes = atlas.nodesAt(OSM_NODE_LOCATION); | ||
final Iterable<Point> points = atlas.pointsAt(OSM_NODE_LOCATION); | ||
|
||
// Verify a Point was created at the house location | ||
assertEquals(0, Iterables.size(nodes)); | ||
assertEquals(1, Iterables.size(points)); | ||
|
||
// Verify nodes created at end points and middle | ||
assertEquals(2, Iterables.size(atlas.nodes())); | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
src/test/java/org/openstreetmap/atlas/geography/atlas/pbf/OsmPbfNodeToAtlasItemTestRule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package org.openstreetmap.atlas.geography.atlas.pbf; | ||
|
||
import org.openstreetmap.atlas.geography.atlas.Atlas; | ||
import org.openstreetmap.atlas.utilities.testing.CoreTestRule; | ||
import org.openstreetmap.atlas.utilities.testing.TestAtlas; | ||
|
||
/** | ||
* {@link OsmPbfNodeToAtlasItemTest} test cases. This class relies on "loadFromJosmOsmResource" | ||
* methods, instead of text atlases, because it relies on loading from PBF and testing the | ||
* conversion from OSM PBF to Atlas Item. Loading in any other format, would skip this step. | ||
* | ||
* @author mgostintsev | ||
*/ | ||
public class OsmPbfNodeToAtlasItemTestRule extends CoreTestRule | ||
{ | ||
@TestAtlas(loadFromJosmOsmResource = "noRelationNoTagsNoIntersectionAtlas.osm") | ||
private Atlas atlasWithoutRelationNoTagsNoIntersection; | ||
|
||
@TestAtlas(loadFromJosmOsmResource = "partOfRelationNoTagsAtIntersectionAtlas.osm") | ||
private Atlas atlasPartOfRelationNoTagsAtIntersection; | ||
|
||
@TestAtlas(loadFromJosmOsmResource = "partOfRelationWithTagsNoIntersectionAtlas.osm") | ||
private Atlas atlasPartOfRelationWithTagsNoIntersection; | ||
|
||
@TestAtlas(loadFromJosmOsmResource = "partOfRelationWithTagsAtIntersectionAtlas.osm") | ||
private Atlas atlasPartOfRelationWithTagsAtIntersection; | ||
|
||
@TestAtlas(loadFromJosmOsmResource = "noRelationWithTagsNoIntersectionAtlas.osm") | ||
private Atlas atlasWithoutRelationWithTagsNoIntersection; | ||
|
||
@TestAtlas(loadFromJosmOsmResource = "noRelationNoTagsAtIntersectionAtlas.osm") | ||
private Atlas atlasWithoutRelationNoTagsAtIntersection; | ||
|
||
@TestAtlas(loadFromJosmOsmResource = "noRelationWithTagsAtIntersectionAtlas.osm") | ||
private Atlas atlasWithoutRelationWithTagsAtIntersection; | ||
|
||
@TestAtlas(loadFromJosmOsmResource = "partOfRelationNoTagsNoIntersectionAtlas.osm") | ||
private Atlas atlasPartOfRelationNoTagsNoIntersection; | ||
|
||
public Atlas getNoRelationNoTagsAtIntersectionAtlas() | ||
{ | ||
return this.atlasWithoutRelationNoTagsAtIntersection; | ||
} | ||
|
||
public Atlas getNoRelationNoTagsNoIntersectionAtlas() | ||
{ | ||
return this.atlasWithoutRelationNoTagsNoIntersection; | ||
} | ||
|
||
public Atlas getNoRelationWithTagsAtIntersectionAtlas() | ||
{ | ||
return this.atlasWithoutRelationWithTagsAtIntersection; | ||
} | ||
|
||
public Atlas getNoRelationWithTagsNoIntersectionAtlas() | ||
{ | ||
return this.atlasWithoutRelationWithTagsNoIntersection; | ||
} | ||
|
||
public Atlas getPartOfRelationNoTagsAtIntersectionAtlas() | ||
{ | ||
return this.atlasPartOfRelationNoTagsAtIntersection; | ||
} | ||
|
||
public Atlas getPartOfRelationNoTagsNoIntersectionAtlas() | ||
{ | ||
return this.atlasPartOfRelationNoTagsNoIntersection; | ||
} | ||
|
||
public Atlas getPartOfRelationWithTagsAtIntersectionAtlas() | ||
{ | ||
return this.atlasPartOfRelationWithTagsAtIntersection; | ||
} | ||
|
||
public Atlas getPartOfRelationWithTagsNoIntersectionAtlas() | ||
{ | ||
return this.atlasPartOfRelationWithTagsNoIntersection; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...urces/org/openstreetmap/atlas/geography/atlas/pbf/noRelationNoTagsAtIntersectionAtlas.osm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<osm version='0.6' generator='JOSM'> | ||
<node id='-1409998' action='modify' lat='7.01378166705' lon='-10.54718467843' /> | ||
<node id='-1409999' action='modify' lat='7.01400307686' lon='-10.54665453727' /> | ||
<node id='-1410001' action='modify' lat='7.01357328126' lon='-10.54613226949' /> | ||
<node id='-1410003' action='modify' lat='7.01317734799' lon='-10.54639734007' /> | ||
<node id='-1410005' action='modify' lat='7.01327244286' lon='-10.54497940386' /> | ||
<way id='-1410000' action='modify'> | ||
<nd ref='-1409998' /> | ||
<nd ref='-1409999' /> | ||
<nd ref='-1410001' /> | ||
<tag k='highway' v='motorway' /> | ||
<tag k='oneway' v='yes' /> | ||
</way> | ||
<way id='-1410008' action='modify'> | ||
<nd ref='-1410003' /> | ||
<nd ref='-1409999' /> | ||
<nd ref='-1410005' /> | ||
<tag k='highway' v='primary' /> | ||
<tag k='oneway' v='yes' /> | ||
</way> | ||
</osm> |
Oops, something went wrong.