Skip to content

Commit

Permalink
Fixed several typos in bash scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
drolbr committed Apr 30, 2012
1 parent 1bd58fb commit 2d239f8
Show file tree
Hide file tree
Showing 9 changed files with 264 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bin/
cgi-bin/
test-bin/
/bin/
/cgi-bin/
/test-bin/

74 changes: 74 additions & 0 deletions src/bin/bisect_timestamp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env bash

# Copyright 2008, 2009, 2010, 2011, 2012 Roland Olbricht
#
# This file is part of Overpass_API.
#
# Overpass_API is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Overpass_API is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Overpass_API. If not, see <http://www.gnu.org/licenses/>.

SOURCE_DIR="$1"
LOCAL_DIR="$2"
TARGET_TIME="$3"
LOWER="$4"
UPPER="$5"
TARGET=

get_replicate_filename()
{
printf -v TDIGIT3 %03u $(($TARGET % 1000))
ARG=$(($TARGET / 1000))
printf -v TDIGIT2 %03u $(($ARG % 1000))
ARG=$(($ARG / 1000))
printf -v TDIGIT1 %03u $ARG
LOCAL_PATH="$LOCAL_DIR/$TDIGIT1/$TDIGIT2"
REPLICATE_FILENAME="$LOCAL_PATH/$TDIGIT3"
REMOTE_PATH="$SOURCE_DIR/$TDIGIT1/$TDIGIT2"
REMOTE_FILE="$REMOTE_PATH/$TDIGIT3"
};

# $1 - remote source
# $2 - local destination
fetch_file()
{
wget -nv -O "$2" "$1"
};

update_state()
{
get_replicate_filename
if [[ ! -s "$REPLICATE_FILENAME.state.txt" ]]; then {
mkdir -p "$LOCAL_PATH"
fetch_file "$REMOTE_FILE.state.txt" "$REPLICATE_FILENAME.state.txt"
}; fi
if [[ -s "$REPLICATE_FILENAME.state.txt" ]]; then {
TIMESTAMP_LINE=`grep "^timestamp" <"$REPLICATE_FILENAME.state.txt"`
DATA_VERSION=${TIMESTAMP_LINE:10}
}; fi
};

while [[ $(($LOWER + 1)) -lt $UPPER ]]; do
{
TARGET=$((($LOWER + $UPPER) / 2))
update_state
#echo "$TARGET - $TIMESTAMP_LINE"
if [[ -s "$REPLICATE_FILENAME.state.txt" && "$DATA_VERSION" < "$TARGET_TIME" ]]; then
{
LOWER=$TARGET
}; else
{
UPPER=$TARGET
}; fi
}; done

echo "$LOWER"
2 changes: 1 addition & 1 deletion src/bin/compress_clone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ while [[ true ]]; do
{
rm -f "$CLONE_DIR/trigger"
sleep 28800
}
}; done

}; done
30 changes: 30 additions & 0 deletions src/bin/convert_wiki.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

# Copyright 2008, 2009, 2010, 2011, 2012 Roland Olbricht
#
# This file is part of Overpass_API.
#
# Overpass_API is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Overpass_API is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Overpass_API. If not, see <http://www.gnu.org/licenses/>.

echo "Overpass QL:"
echo "<source lang=cpp>"
echo "$1" | ./osm3s_query --dump-pretty-map-ql --concise
echo "</source>"
echo
echo "XML:"
echo "<source lang=xml>"
echo "$1" | ./osm3s_query --dump-xml --concise
echo "</source>"
echo
echo "Display result: [http://overpass-api.de/api/convert?data=`echo "$1" | ./tocgi`&target=openlayers&zoom=12&lat=50.72&lon=7.1 OpenLayers map] [http://overpass-api.de/api/interpreter?data=%5Bout:json%5D;`echo "$1" | ./tocgi` JSON], [http://overpass-api.de/api/interpreter?data=`echo "$1" | ./tocgi` XML]."
19 changes: 19 additions & 0 deletions src/overpass_api/osm-backend/generate_test_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,21 @@ struct Accept_Recurse_20 : public Accept_All_Tags
uint pattern_size;
};

struct Accept_Recurse_21 : public Accept_All_Tags
{
Accept_Recurse_21(uint pattern_size_) : pattern_size(pattern_size_) {}

virtual bool admit_node(uint id) const
{
return (id == pattern_size + 1 || id == pattern_size + 2);
}
virtual bool admit_way(uint id) const { return false; }
virtual bool admit_relation(uint id) const { return false; }

private:
uint pattern_size;
};

struct Accept_Bbox_Query_1 : public Accept_All_Tags
{
Accept_Bbox_Query_1(uint pattern_size_) : pattern_size(pattern_size_) {}
Expand Down Expand Up @@ -2534,6 +2549,10 @@ int main(int argc, char* args[])
modifier = new Accept_Recurse_19(pattern_size);
else if (string(args[2]) == "recurse_20")
modifier = new Accept_Recurse_20(pattern_size);
else if (string(args[2]) == "recurse_21")
modifier = new Accept_Recurse_21(pattern_size);
else if (string(args[2]) == "recurse_22")
modifier = new Accept_Recurse_21(pattern_size); //recurse_21 and recurse_22 are equal
else if (string(args[2]) == "bbox_query_1")
modifier = new Accept_Bbox_Query_1(pattern_size);
else if (string(args[2]) == "bbox_query_2")
Expand Down
8 changes: 6 additions & 2 deletions src/overpass_api/statements/recurse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,9 @@ void Recurse_Statement::execute(Resource_Manager& rman)
map< Uint32_Index, vector< Node_Skeleton > > rel_nodes
= relation_node_members(*this, rman, mit->second.relations);
into.ways = relation_way_members(*this, rman, mit->second.relations);
into.nodes = way_members(*this, rman, into.ways);
map< Uint31_Index, vector< Way_Skeleton > > source_ways = mit->second.ways;
indexed_set_union(source_ways, into.ways);
into.nodes = way_members(*this, rman, source_ways);
indexed_set_union(into.nodes, rel_nodes);
}
else if (type == RECURSE_DOWN_REL)
Expand All @@ -748,7 +750,9 @@ void Recurse_Statement::execute(Resource_Manager& rman)
map< Uint32_Index, vector< Node_Skeleton > > rel_nodes
= relation_node_members(*this, rman, into.relations);
into.ways = relation_way_members(*this, rman, into.relations);
into.nodes = way_members(*this, rman, into.ways);
map< Uint31_Index, vector< Way_Skeleton > > source_ways = mit->second.ways;
indexed_set_union(source_ways, into.ways);
into.nodes = way_members(*this, rman, source_ways);
indexed_set_union(into.nodes, rel_nodes);
}
else if (type == RECURSE_WAY_RELATION)
Expand Down
66 changes: 58 additions & 8 deletions src/overpass_api/statements/recurse.test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ int main(int argc, char* args[])
{
try
{
// Recurse relation-way
// Recurse down
Nonsynced_Transaction transaction(false, false, args[3], "");
Resource_Manager total_rman(transaction);
perform_id_query(total_rman, "relation", 6);
Expand All @@ -419,7 +419,7 @@ int main(int argc, char* args[])
{
try
{
// Recurse relation-way
// Recurse down-rel with a recursive relation
Nonsynced_Transaction transaction(false, false, args[3], "");
Resource_Manager total_rman(transaction);
perform_id_query(total_rman, "relation", 9);
Expand All @@ -444,7 +444,7 @@ int main(int argc, char* args[])
{
try
{
// Recurse relation-way
// Recurse down-rel with a mixed relation
Nonsynced_Transaction transaction(false, false, args[3], "");
Resource_Manager total_rman(transaction);
perform_id_query(total_rman, "relation", 10);
Expand All @@ -469,7 +469,7 @@ int main(int argc, char* args[])
{
try
{
// Recurse relation-way
// Recurse up
Nonsynced_Transaction transaction(false, false, args[3], "");
Resource_Manager total_rman(transaction);
perform_id_query(total_rman, "node", pattern_size + 2);
Expand All @@ -494,7 +494,7 @@ int main(int argc, char* args[])
{
try
{
// Recurse relation-way
// Recurse up
Nonsynced_Transaction transaction(false, false, args[3], "");
Resource_Manager total_rman(transaction);
perform_id_query(total_rman, "way", 1);
Expand All @@ -519,7 +519,7 @@ int main(int argc, char* args[])
{
try
{
// Recurse relation-way
// Recurse up-rel with a node
Nonsynced_Transaction transaction(false, false, args[3], "");
Resource_Manager total_rman(transaction);
perform_id_query(total_rman, "node", 2);
Expand All @@ -544,7 +544,7 @@ int main(int argc, char* args[])
{
try
{
// Recurse relation-way
// Recurse up-rel with a way
Nonsynced_Transaction transaction(false, false, args[3], "");
Resource_Manager total_rman(transaction);
perform_id_query(total_rman, "way", 2);
Expand All @@ -569,7 +569,7 @@ int main(int argc, char* args[])
{
try
{
// Recurse relation-way
// Recurse up-rel with a relation
Nonsynced_Transaction transaction(false, false, args[3], "");
Resource_Manager total_rman(transaction);
perform_id_query(total_rman, "relation", 1);
Expand All @@ -590,6 +590,56 @@ int main(int argc, char* args[])
<<e.error_number<<' '<<e.filename<<' '<<e.origin<<'\n';
}
}
if ((test_to_execute == "") || (test_to_execute == "21"))
{
try
{
// Recurse down with a way
Nonsynced_Transaction transaction(false, false, args[3], "");
Resource_Manager total_rman(transaction);
perform_id_query(total_rman, "way", 1);
{
const char* attributes[] = { "type", "down", 0 };
Recurse_Statement stmt(2, convert_c_pairs(attributes));
stmt.execute(total_rman);
}
{
const char* attributes[] = { 0 };
Print_Statement stmt(3, convert_c_pairs(attributes));
stmt.execute(total_rman);
}
}
catch (File_Error e)
{
cerr<<"File error caught: "
<<e.error_number<<' '<<e.filename<<' '<<e.origin<<'\n';
}
}
if ((test_to_execute == "") || (test_to_execute == "22"))
{
try
{
// Recurse down-rel with a way
Nonsynced_Transaction transaction(false, false, args[3], "");
Resource_Manager total_rman(transaction);
perform_id_query(total_rman, "way", 1);
{
const char* attributes[] = { "type", "down-rel", 0 };
Recurse_Statement stmt(2, convert_c_pairs(attributes));
stmt.execute(total_rman);
}
{
const char* attributes[] = { 0 };
Print_Statement stmt(3, convert_c_pairs(attributes));
stmt.execute(total_rman);
}
}
catch (File_Error e)
{
cerr<<"File error caught: "
<<e.error_number<<' '<<e.filename<<' '<<e.origin<<'\n';
}
}

cout<<"</osm>\n";
return 0;
Expand Down
71 changes: 71 additions & 0 deletions src/test-bin/dump_by_query.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env bash

# Copyright 2008, 2009, 2010, 2011, 2012 Roland Olbricht
#
# This file is part of Overpass_API.
#
# Overpass_API is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Overpass_API is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Overpass_API. If not, see <http://www.gnu.org/licenses/>.

create_query()
{
echo "<osm-script timeout=\"86400\">" >$5

LAT=$1
while [[ $LAT -lt $2 ]]; do
{
LON=$3
while [[ $LON -lt $4 ]]; do
{
echo "<bbox-query s=\"$LAT\" n=\"$(($LAT+1))\" w=\"$LON\" e=\"$(($LON+1))\"/>" >>$5
echo "<print mode=\"$6\"/>" >>$5
echo "<recurse type=\"node-way\" into=\"ways\"/>" >>$5
echo "<print mode=\"$6\" from=\"ways\"/>" >>$5
echo "<union>" >>$5
echo " <recurse type=\"node-relation\"/>" >>$5
echo " <recurse type=\"way-relation\" from=\"ways\"/>" >>$5
echo "</union>" >>$5
echo "<print mode=\"$6\"/>" >>$5
echo >>$5
LON=$(($LON + 1))
}; done
LAT=$(($LAT+1))
}; done

echo "</osm-script>" >>$5
};

perform_query()
{
create_query $1 $2 $3 $4 query_$5.xml $6
$7/bin/osm3s_query <query_sww.xml | gzip >dump_$5.xml.gz
};

perform_query_stripe()
{
perform_query -90 -30 $1 $2 "s$3" $4 $5
perform_query -30 30 $1 $2 "m$3" $4 $5
perform_query 30 90 $1 $2 "n$3" $4 $5
};

perform_global_query()
{
perform_query_stripe -180 -120 ww $1 $2
perform_query_stripe -120 -60 wm $1 $2
perform_query_stripe -60 0 we $1 $2
perform_query_stripe 0 60 ew $1 $2
perform_query_stripe 60 120 em $1 $2
perform_query_stripe 120 180 ee $1 $2
};

perform_global_query $1 $2
4 changes: 2 additions & 2 deletions src/test-bin/run_unittests_statements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ perform_test_loop print 4 "$DATA_SIZE ../../input/update_database/"
print_test_5 print 5 "$DATA_SIZE ../../input/update_database/"

# Test the recurse statement
prepare_test_loop recurse 20 $DATA_SIZE
prepare_test_loop recurse 22 $DATA_SIZE
date +%T
perform_test_loop recurse 20 "$DATA_SIZE ../../input/update_database/"
perform_test_loop recurse 22 "$DATA_SIZE ../../input/update_database/"

# Test the bbox_query statement
prepare_test_loop bbox_query 8 $DATA_SIZE
Expand Down

0 comments on commit 2d239f8

Please sign in to comment.