Skip to content

GoogleCloudPlatform/bigquery-geotools

Repository files navigation

bigquery-geotools

Add BigQuery support to Geoserver.

Install

Build or download the JARs and copy them into geoserver's WEB-INF/lib folder in the same way you install other geoserver plugins.

Download

A .zip containing the bigquery-geotools JAR and required dependency JARs is built against JDK 8 is available in under releases.

Build

  1. Use Cloud Build
gcloud builds submit .
  1. Build locally. Requires JDK 8+.
mvn package -DskipTests

Authentication

The service account used to authenticate with BigQuery needs the following permissions:

  • bigquery.jobs.create
  • bigquery.tables.get
  • bigquery.tables.getData
  • bigquery.tables.lister

You can use one of three authentication methods to connect to BigQuery, depending on your requirements:

  1. If your geoserver instance is running inside GCP, on a VM or elsewhere, you can make use of Default service account credentials. (Recommended)

  2. Set the GOOGLE_APPLICATION_CREDENTIALS environment variable

  3. Export a service account key JSON file, add it to disk, and manually select the file when configuring the BigQuery data source. Note: Do not store the service account key file in the geoserver data directory, it may not be secure there.

Usage

1. Create a new Vector source

Create a new data soruce he same way as other databases. Under Stores, select Add New Store, then select BigQuery Table.

2. Configure the Vector Source

Now, you will configure the connection to a BigQuery dataset. Datasets can contain many tables, and are roughly analogous to PostGIS schemas.

Pregenerate Materialized Views

The Pregenerate Materialized Views setting will do one of the following:

  • MV_NONE: do not generate or utilize any pregenerated materialized views.
  • MV_USE_EXISTING: utilize any existing materialized views, but do not generate any.
  • MV_PREGEN_ALL: pregenerate 4 tables of simplified geometries at tolerances 1m, 10m, 100m, and 1000m.

To generate materialized views manually, see this sample SQL.

3. Add and configure layer

Select Publish to configure and publish a vectory layer from BigQuery.

Configuration

There are several configuration options that can be set when adding a BigQuery data source.

Parameter Default Description
Access Method QUERY_API Select whether to query using the BigQuery Storage API or standard Query API.
Simplify Geometries true Attempt to simplify geometries at wider zoom levels without impacting accuracy
Use Query Cache true Use the BigQuery query cache when possible
Query Recent Partition true When querying a partitioned table, automatically detect the most recent partition and use it for queries