Skip to content

Instantly share code, notes, and snippets.

@tyrasd
Forked from hjanetzek/gist:5521755
Last active December 26, 2015 14:39
Show Gist options
  • Save tyrasd/7167203 to your computer and use it in GitHub Desktop.
Save tyrasd/7167203 to your computer and use it in GitHub Desktop.
pbf output cgi-bin script for overpass-api
#!/usr/bin/env bash
# Copyright 2008, 2009, 2010, 2011, 2012 Roland Olbricht
#
# This file is (not yet) part of Overpass_API
#
# Overpass_API is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License
# along with Overpass_API. If not, see <http://www.gnu.org/licenses/>.
EXEC_DIR="`dirname $0`/"
if [[ ! ${EXEC_DIR:0:1} == "/" ]]; then
{
EXEC_DIR="`pwd`/$EXEC_DIR"
};
fi
BIN_DIR="$EXEC_DIR/../bin"
echo "Content-Type: application/octet-stream"
echo
# see https://github.com/drolbr/Overpass-API/issues/37#issuecomment-24020046
echo "$QUERY_STRING" | ../bin/osm3s_query --quiet | $BIN_DIR/osmconvert - --out-pbf
EXITCODE=$?
if [[ $EXITCODE -ne 0 ]]; then
echo "Content-Type: text/plain; charset=utf-8"
echo "Status: 400 Bad Request"
echo
echo "Error in ...:"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment