This is not an officially supported Google product, though support will be provided on a best-effort basis.
Copyright 2018 Google LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
This AppEngine sample application is designed to process your Waze CCP JSON Feed into; BigQuery GIS tables for analysis, Google Cloud Storage as GeoJSON for use in desktop or web GIS applications, and, optionally into Carto for advanced spatial visualization.
Join the Group for updates and discussion
- Google AppEngine
- Google Cloud Datastore
- Google BigQuery
- Google Cloud Storage
From here on out, we'll refer to your Project ID as {project-id} and Project Name as {project-name}
From here on out, we'll refer to your Dataset as {bqDataset}
From here on out, we'll refer to your Bucket as {gcsPath}
git clone https://github.com/google/waze-ccp-gcp.git
First, generate a GUID. This will be referred to as {guid} and its just a way to create a non-guessable URL for the handler that Cron will call to update the Waze data every 10 minutes.
- In app.yaml
- Line 15: Change {project-name} to your {project-name}
- Line 37: Change {guid} to your {guid}
- In cron.yaml
- Line 17: Change {guid} to your {guid}
- In main.py
- Line 29: Change {waze-url} to your Waze CCP URL
- Line 38: Change {gcsPath} to your {gcsPath}
- Line 41: Change {bqDataset} to your {bqDataset}
- Line 873: Change {guid} to your {guid}
This application utilizes Google-provided Python libraries that are not part of AppEngine Standard, but are easily installed using the vendor library method. Becaue these libraries update frequently and themselves install additional dependencies, you will use the requirements.txt file provided and pip to install them.
From the terminal, change directories to where you cloned the source code.
cd {your-app-folder}
Next, use pip to install the required libraries to the /lib folder.
pip install -r requirements.txt -t lib/
The special file "appengine_config.py" uses the Vendor library to include any dependencies located in the /lib folder.
gcloud config set project {project-name}
gcloud app create
gcloud app deploy {your-app-folder}/app.yaml
Even though you generated a GUID to serve as the URL path that AppEngine's Cron accesses to cause a data update, someone could discover it and maliciously hit that URL, and, they could also hit the /newCase/ endpoint. In order to prevent unwanted use of these URLs, you will enable IAP and lock down access to the application only to approved users (or just you).
When you go to IAP settings for your project, you'll first have to set up a Credentials Screen (Oath2). Set the Application Type to "Internal".
Then, under IAP - turn the IAP on for the AppEngine app:
You can verify that IAP is working by visiting https://{project-name}.appspot.com in an Incognito browser. You should be redircted to your OAuth2 Credentials Screen, which shows that the IAP is working and protecting the entire application.
Simply visit https://{project-name}.appspot.com/newCase/?name={your-case-name} You should just see a blank page rendered, and no 500 errors if everything worked correctly. To confirm the Case Study was crated, you can visit Datastore and confirm the Entity you expect to see is there.
Within 10 minutes, the Cron job described in cron.yaml will call https://{project-name}.appspot.com/{guid}/ and will start populating the tables in BigQuery. *Note - the cron function of AppEngine is internal so it is automatically inscope for IAP purposes.In BigQuery, you should see the three tables (alerts, jams, irregularities) under your {bqDataset}
These tables will contain all the unique elements from your {waze-url}
Once you have a few days worth of data, you can start experimenting with building Data Studio dashboards.
If you come up with something interesting, be sure to share with the group: