#!/bin/bash
################################################################################
#
# Fitting Road Network Data to a Graph Tutorial
#
# This script backs the Fitting Road Network Data to a Graph Tutorial on the doc 
# site
#
# A local Kinetica instance will handle calls to /create/graph, 
# /create/jointable, and /create/projection for a D.C.-based graph
#
# NOTE:
#       Running the script requires that the 'dc_shape' dataset be ingested
#       into the same Kinetica instance this script will be run against. This
#       dataset can be downloaded from the documentation site and imported via
#       GAdmin.
#
# EXAMPLE:
#       ./fit_data.sh localhost
#
################################################################################

THIS_SCRIPT=$(basename ${BASH_SOURCE[0]})
THIS_SCRIPT_LOG=${THIS_SCRIPT%.*}.log
THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
HOSTNAME="${1:-localhost}"

echo
echo FITTING ROAD NETWORK DATA OUTPUT
echo ================================
echo

echo "CREATE GRAPH (INLINE EXPRESSION)"
echo "--------------------------------"
echo 

curl -sS -X POST --header "Content-Type: application/json" \
-d @create_graph_inline.json http://${HOSTNAME}:9191/create/graph
echo
echo

echo CREATE JOIN TABLE
echo -----------------
echo 

curl -sS -X POST --header "Content-Type: application/json" \
-d @create_join_table.json http://${HOSTNAME}:9191/create/jointable
echo
echo

echo CREATE PROJECTION
echo -----------------
echo 

curl -sS -X POST --header "Content-Type: application/json" \
-d @create_projection.json http://${HOSTNAME}:9191/create/projection
echo
echo

echo "CREATE GRAPH (EXPANSION)"
echo "------------------------"
echo 

curl -sS -X POST --header "Content-Type: application/json" \
-d @create_graph_expansion.json http://${HOSTNAME}:9191/create/graph
echo
echo