Skip to content

v0.2.50..v0.2.51 changeset ServiceDiffRoadSnapTest.sh.off

Garret Voltz edited this page Jan 15, 2020 · 1 revision
diff --git a/test-files/cmd/slow/serial/ServiceDiffRoadSnapTest.sh.off b/test-files/cmd/slow/serial/ServiceDiffRoadSnapTest.sh.off
new file mode 100755
index 0000000..a0cbafc
--- /dev/null
+++ b/test-files/cmd/slow/serial/ServiceDiffRoadSnapTest.sh.off
@@ -0,0 +1,74 @@
+#!/bin/bash
+set -e
+
+# This test creates a diff between two road datasets using Differential Conflation and snaps unconnected secondary roads back to reference 
+# roads (within a tolerance). It then applies the diff changeset back to the reference data store, after which we may check to see that all the 
+# snapped secondary roads remain connected to the reference roads (not just hovering over top of them unconnected). The type road conflation 
+# algorithm is passed in by calling scripts. 
+
+TEST_NAME=$1
+ALG_CONFIG=$2
+
+INPUT_DIR=test-files/cmd/slow/DiffConflateCmdTest
+GOLD_DIR=test-files/cmd/slow/serial/$TEST_NAME
+OUTPUT_DIR=test-output/cmd/slow/serial/$TEST_NAME
+rm -rf $OUTPUT_DIR
+mkdir -p $OUTPUT_DIR
+
+source conf/database/DatabaseConfig.sh
+export OSM_API_DB_URL="osmapidb://$DB_USER:$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_NAME_OSMAPI"
+export OSM_API_DB_AUTH="-h $DB_HOST -p $DB_PORT -U $DB_USER"
+export PGPASSWORD=$DB_PASSWORD_OSMAPI
+HOOT_DB_URL="hootapidb://$DB_USER:$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_NAME"
+
+GENERAL_OPTS=$CONFIG" -C "$ALG_CONFIG" -C DifferentialConflation.conf -C Testing.conf -D uuid.helper.repeatable=true -D writer.include.debug.tags=true -D reader.add.source.datetime=false -D writer.include.circular.error.tags=false"
+DB_OPTS="-D api.db.email=OsmApiDbHootApiDbConflate@hoottestcpp.org -D hootapi.db.writer.create.user=true -D hootapi.db.writer.overwrite.map=true -D changeset.user.id=1"
+CHANGESET_DERIVE_OPTS="-D changeset.user.id=1 -D changeset.allow.deleting.reference.features=false -D snap.unconnected.ways.mark.snapped.nodes=true -D snap.unconnected.ways.mark.snapped.ways=true"
+
+DEBUG=false
+if [ "$DEBUG" == "true" ]; then
+  GENERAL_OPTS=$GENERAL_OPTS" -D debug.maps.write=true -D debug.maps.filename=$OUTPUT_DIR/debug.osm"
+fi
+LOG_LEVEL="--warn"
+if [ "$DEBUG" == "true" ]; then
+  LOG_LEVEL="--debug"
+  LOG_FILTER="-D log.class.filter=DiffConflator"
+  GENERAL_OPTS=$LOG_LEVEL" "$GENERAL_OPTS" "$LOG_FILTER
+else
+  GENERAL_OPTS=$LOG_LEVEL" "$GENERAL_OPTS
+fi
+
+scripts/database/CleanAndInitializeOsmApiDb.sh
+
+# write ref to osmapidb
+# There's a mix of positive/negative IDs in the source file, so let's treat this like an authoritative data store and give it all positive IDs.
+hoot convert -D reader.use.data.source.ids=false -D id.generator=hoot::PositiveIdGenerator $GENERAL_OPTS $DB_OPTS $INPUT_DIR/input3.osm $OSM_API_DB_URL
+if [ "$DEBUG" == "true" ]; then
+  hoot convert -D reader.use.data.source.ids=true $GENERAL_OPTS $DB_OPTS $OSM_API_DB_URL $OUTPUT_DIR/ref-original.osm
+fi
+
+# write sec to hootapidb
+SEC_LAYER=$HOOT_DB_URL/$TEST_NAME-sec
+# Also a mix of positive/negative IDs here, and we'll treat it like shoebox data and give it all negative IDs.
+hoot convert -D reader.use.data.source.ids=false $GENERAL_OPTS $DB_OPTS $INPUT_DIR/input4.osm $SEC_LAYER
+if [ "$DEBUG" == "true" ]; then
+  hoot convert -D reader.use.data.source.ids=true $GENERAL_OPTS $DB_OPTS $SEC_LAYER $OUTPUT_DIR/sec-original.osm
+fi
+
+# run diff conflate to changeset w/ road snapping
+# retain both sets of IDs during conflate
+hoot conflate $GENERAL_OPTS $DB_OPTS $CHANGESET_DERIVE_OPTS -D conflate.use.data.source.ids.1=true -D conflate.use.data.source.ids.2=true -D differential.snap.unconnected.roads=true -D snap.unconnected.ways.snap.tolerance=10.0 $OSM_API_DB_URL $SEC_LAYER $OUTPUT_DIR/diff.osc.sql $OSM_API_DB_URL --differential
+if [ "$DEBUG" == "true" ]; then
+  hoot conflate $GENERAL_OPTS $DB_OPTS $CHANGESET_DERIVE_OPTS -D conflate.use.data.source.ids.1=true -D conflate.use.data.source.ids.2=true -D differential.snap.unconnected.roads=true -D snap.unconnected.ways.snap.tolerance=10.0 $OSM_API_DB_URL $SEC_LAYER $OUTPUT_DIR/diff.osc --differential
+fi
+
+# apply changeset back to ref
+hoot changeset-apply $GENERAL_OPTS $DB_OPTS $CHANGESET_DERIVE_OPTS $OUTPUT_DIR/diff.osc.sql $OSM_API_DB_URL
+
+# read ref back out and compare to gold
+hoot convert $GENERAL_OPTS $DB_OPTS -D reader.use.data.source.ids=true $OSM_API_DB_URL $OUTPUT_DIR/out.osm
+hoot diff $GENERAL_OPTS $GOLD_DIR/out.osm $OUTPUT_DIR/out.osm
+
+hoot db-delete-map $GENERAL_OPTS $DB_OPTS $SEC_DB_INPUT $HOOT_DB_URL/$TEST_NAME-sec
+
+
Clone this wiki locally