-
Notifications
You must be signed in to change notification settings - Fork 74
v0.2.47..v0.2.48 changeset OsmXmlReaderTest.cpp
Garret Voltz edited this page Sep 27, 2019
·
1 revision
diff --git a/hoot-core-test/src/test/cpp/hoot/core/io/OsmXmlReaderTest.cpp b/hoot-core-test/src/test/cpp/hoot/core/io/OsmXmlReaderTest.cpp
index cf70f9a..bd68d82 100644
--- a/hoot-core-test/src/test/cpp/hoot/core/io/OsmXmlReaderTest.cpp
+++ b/hoot-core-test/src/test/cpp/hoot/core/io/OsmXmlReaderTest.cpp
@@ -44,6 +44,7 @@ class OsmXmlReaderTest : public HootTestFixture
CPPUNIT_TEST(runUncompressTest);
CPPUNIT_TEST(runDecodeCharsTest);
CPPUNIT_TEST(runBoundsTest);
+ CPPUNIT_TEST(runBoundsLeaveConnectedOobWaysTest);
CPPUNIT_TEST_SUITE_END();
public:
@@ -52,7 +53,7 @@ public:
: HootTestFixture("test-files/io/OsmXmlReaderTest/",
"test-output/io/OsmXmlReaderTest/")
{
- setResetType(ResetBasic);
+ setResetType(ResetAll);
}
void runTest()
@@ -156,10 +157,11 @@ public:
CPPUNIT_ASSERT(f.remove());
}
- //This test ensures that characters not allowed in well-formed XML get decoded as read in.
- //Qt's XML reading does this for us automatically.
void runDecodeCharsTest()
{
+ //This test ensures that characters not allowed in well-formed XML get decoded as read in.
+ //Qt's XML reading does this for us automatically.
+
OsmXmlReader uut;
OsmMapPtr map(new OsmMap());
@@ -201,10 +203,34 @@ public:
uut.setBounds(geos::geom::Envelope(-104.8996,-104.8976,38.8531,38.8552));
OsmMapPtr map(new OsmMap());
uut.read("test-files/ToyTestA.osm", map);
+ uut.close();
CPPUNIT_ASSERT_EQUAL(32, (int)map->getNodes().size());
CPPUNIT_ASSERT_EQUAL(2, (int)map->getWays().size());
}
+
+ void runBoundsLeaveConnectedOobWaysTest()
+ {
+ // This will leave any ways in the output which are outside of the bounds but are directly
+ // connected to ways which cross the bounds.
+
+ OsmXmlReader uut;
+ uut.setBounds(geos::geom::Envelope(38.91362, 38.915478, 15.37365, 15.37506));
+ uut.setKeepImmediatelyConnectedWaysOutsideBounds(true);
+
+ // set cropping up for strict bounds handling
+ conf().set(ConfigOptions::getConvertBoundingBoxKeepEntireFeaturesCrossingBoundsKey(), false);
+ conf().set(ConfigOptions::getConvertBoundingBoxKeepOnlyFeaturesInsideBoundsKey(), true);
+
+ OsmMapPtr map(new OsmMap());
+ uut.read("test-files/ops/ImmediatelyConnectedOutOfBoundsWayTagger/in.osm", map);
+ uut.close();
+ //OsmMapWriterFactory::write(
+ //map, _outputPath + "/runBoundsLeaveConnectedOobWaysTest.osm", false, true);
+
+ CPPUNIT_ASSERT_EQUAL(17, (int)map->getNodes().size());
+ CPPUNIT_ASSERT_EQUAL(3, (int)map->getWays().size());
+ }
};
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(OsmXmlReaderTest, "quick");