Skip to content

Commit 2970a22

Browse files
committed
Added augmented diff id finder.
1 parent efe7a31 commit 2970a22

File tree

2 files changed

+78
-1
lines changed

2 files changed

+78
-1
lines changed

src/cgi-bin/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cgibindir = ${prefix}/cgi-bin
22
cgibin_PROGRAMS = interpreter position_flag show_position
3-
dist_cgibin_SCRIPTS = convert convert_xapi draw-line kill_my_queries sitemap sketch-line sketch-options sketch-route template xapi xapi_meta
3+
dist_cgibin_SCRIPTS = augmented_state_by_date convert convert_xapi draw-line kill_my_queries sitemap sketch-line sketch-options sketch-route template xapi xapi_meta
44

55
escape_xml_cc = ../expat/escape_xml.cc
66
expat_cc = ../expat/expat_justparse_interface.cc
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2008, 2009, 2010, 2011, 2012 Roland Olbricht
4+
#
5+
# This file is part of Overpass_API.
6+
#
7+
# Overpass_API is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU Affero General Public License as
9+
# published by the Free Software Foundation, either version 3 of the
10+
# License, or (at your option) any later version.
11+
#
12+
# Overpass_API is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU Affero General Public License
18+
# along with Overpass_API. If not, see <http://www.gnu.org/licenses/>.
19+
20+
BUF="$QUERY_STRING&"
21+
22+
STATE=
23+
EXECBASE="`dirname $0`/../"
24+
BIN_DIR="${EXECBASE}bin"
25+
26+
IFS=$'&'
27+
for KEY_VAL in $QUERY_STRING; do
28+
{
29+
if [[ ${KEY_VAL:0:9} == "osm_base=" ]]; then
30+
STATE="${KEY_VAL:9}"
31+
fi
32+
}; done
33+
unset IFS
34+
35+
36+
TARGET_TIME="`echo "$STATE" | $BIN_DIR/uncgi`"
37+
LOWER="0"
38+
UPPER="`cat /var/www/augmented_diffs/state.txt`"
39+
LOCAL_DIR="/var/www/augmented_diffs/"
40+
41+
get_replicate_filename()
42+
{
43+
printf -v TDIGIT3 %03u $(($TARGET % 1000))
44+
ARG=$(($TARGET / 1000))
45+
printf -v TDIGIT2 %03u $(($ARG % 1000))
46+
ARG=$(($ARG / 1000))
47+
printf -v TDIGIT1 %03u $ARG
48+
LOCAL_PATH="$LOCAL_DIR/$TDIGIT1/$TDIGIT2"
49+
REPLICATE_FILENAME="$LOCAL_PATH/$TDIGIT3"
50+
};
51+
52+
update_state()
53+
{
54+
get_replicate_filename
55+
if [[ -s "$REPLICATE_FILENAME.state.txt" ]]; then {
56+
TIMESTAMP_LINE=`cat "$REPLICATE_FILENAME.state.txt"`
57+
DATA_VERSION=${TIMESTAMP_LINE:9}
58+
}; fi
59+
};
60+
61+
while [[ $(($LOWER + 1)) -lt $UPPER ]]; do
62+
{
63+
TARGET=$((($LOWER + $UPPER) / 2))
64+
update_state
65+
#echo "$TARGET - $TIMESTAMP_LINE"
66+
if [[ -s "$REPLICATE_FILENAME.state.txt" && "$DATA_VERSION" < "$TARGET_TIME" ]]; then
67+
{
68+
LOWER=$TARGET
69+
}; else
70+
{
71+
UPPER=$TARGET
72+
}; fi
73+
}; done
74+
75+
echo "Content-Type: text/plain; charset=utf-8"
76+
echo
77+
echo "$LOWER"

0 commit comments

Comments
 (0)