Permalink
Browse files

Fixed several typos in bash scripts.

  • Loading branch information...
1 parent 1bd58fb commit 2d239f8fdee9095587cb507a1c73b52ca0d2daea @drolbr committed Apr 30, 2012
View
@@ -1,4 +1,4 @@
-bin/
-cgi-bin/
-test-bin/
+/bin/
+/cgi-bin/
+/test-bin/
@@ -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"
@@ -84,6 +84,6 @@ while [[ true ]]; do
{
rm -f "$CLONE_DIR/trigger"
sleep 28800
- }
+ }; done
}; done
@@ -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]."
@@ -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_) {}
@@ -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")
@@ -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)
@@ -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)
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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);
@@ -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;
@@ -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
@@ -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

0 comments on commit 2d239f8

Please sign in to comment.