author:            Todd King
summary:           PDS4 Product Registry
id:                pds4-product-registry
categories:        sdk
environments:      android
status:            published
feedback link:     https://github.com/nasa-pds/pds4-product-registry/issues
analytics account: 0

# PDS4 Product Registry

## Overview of the tutorial
Duration: 5:05


This tutorial shows you how to install and user the PDS4 Product Registry.

The PDS4 product registry is designed to work on large scale registries of data products. The registry, web services and command-line tools are written in Node.js with installation using NPM.

In this tutorial you will do the following: 

* Install the PDS4 Product Registry.
* Generate a data product level inventory.
* Load the inventory into the product registry.
* Query the registry 

Prerequesites

* NPM and Node.js
* One or more PDS4 collections

We recommend you to have npm and Node.js already installed on your machine to quickly boot up a http server.

## Install PDS4 Product Registry
Duration: 0:10

Before you start, you need to download the latest version of our offline functional examples from [here](https://developer.tomtom.com/maps-sdk-web/downloads) [Download functional examples](https://api.tomtom.com/maps-sdk-js/4.23.3/jssdk-4.23.3-distribution-vector.zip).

![tomtom_portal](https://s3-eu-west-1.amazonaws.com/released-artifacts-3.x/assets/tutorial_images/creating-styles/step1.png)

## Extract the examples
Duration: 0:05

Create a new directory and extract the examples there.

For this tutorial, I created a directory called "examples". This is how it should look like after the extraction:

![sdk_dir](https://s3-eu-west-1.amazonaws.com/released-artifacts-3.x/assets/tutorial_images/creating-styles/step2a.png)

The contents of the "sdk" folder should look like this:

![style_dir](https://s3-eu-west-1.amazonaws.com/released-artifacts-3.x/assets/tutorial_images/creating-styles/step2b.png)

There are several directories and files, but we are only interested in the following ones:

* glyphs - contains fonts used for rendering vector maps
* sprites - contains images used for rendering vector maps
* styles - contains json files with style definition

TomTom vector maps styles are compatible with Mapbox Styles Specification. This format defines rendered maps properties - fill colors, line styles and thickness, etc. To read more about this specification, please go to [here](https://www.mapbox.com/mapbox-gl-js/style-spec/) .

To be able to provide labels and additional images on the map (e.g. road shields) two more assets are required:

* glyphs - these are fonts in a binary pbf format. They are transformed to speed up rendering process. To read more about it, please go to here. This is a rather advanced article.
* sprites - they consist of two files:
  - image file - a png file containing concatenated images
  - index file - a json file describing content of an image file. 

Sprites might be provided in an additional form appropriate for high-DPI devices. In that case "@2x" suffix should be appended to the file names, e.g. "sprites@2x.png"
More about sprites can be found here.

## Run server with examples
Duration: 0:10

This step is a prerequisite needed to configure the styles editor. In order to accomplish it, you need to have Node.js installed (this is out of the scope of this tutorial). Please, refer to [https://nodejs.org/en/download/](https://nodejs.org/en/download/), if you need further assistance with this task.  

Open a console terminal and go to a directory created to host offline examples. Now, type in the following instruction:

``` bash
npm install && npm start
```

After a while, you should see text similar to the one in this picture:

![console](https://s3-eu-west-1.amazonaws.com/released-artifacts-3.x/assets/tutorial_images/creating-styles/step3.png)

If you would like to know more about running offline examples, you may take a look at one of our tutorials: [Running examples locally](https://developer.tomtom.com/maps-sdk-web/tutorials-basics/running-examples-locally)

## Upload styles
Duration: 0:15

There are several ways to edit styles. You may do this manually in a text editor of your choice, but we prefer to use Maputnik - a visual map designer. You may find it here: [https://maputnik.github.io/editor/](https://maputnik.github.io/editor/)

The first step is to upload a file containing a style definition to Maputnik. Click on the "Open" button.
![screen1](https://s3-eu-west-1.amazonaws.com/released-artifacts-3.x/assets/tutorial_images/creating-styles/step4a.png)

Now, in a popup window, select the "Upload" button.
![screen2](https://s3-eu-west-1.amazonaws.com/released-artifacts-3.x/assets/tutorial_images/creating-styles/step4b.png)

For this particular tutorial, we will edit the "basic_main.json" style. You may find it in the "styles" directory described in the"Extract the examples" step.

## Provide an API key in order to access data sources
Duration: 0:05

One of the prerequisites for this tutorial is to obtain API key for an Online Map product. Now we will use it.
  
Click on the "Sources" button.

![step5a](https://s3-eu-west-1.amazonaws.com/released-artifacts-3.x/assets/tutorial_images/creating-styles/step5a.png)

Next, replace "{key}" placeholder in each of the tile URLs with your API key.

![step5b](https://s3-eu-west-1.amazonaws.com/released-artifacts-3.x/assets/tutorial_images/creating-styles/step5b.png)

Close the overlay to apply the changes by clicking on X in the top right corner.

## Update glyphs and sprites paths
Duration: 0:05

In order to complete this step, we will use the http server with examples run in one of the previous steps. Click on the "Style Settings" button.

![step6a](https://s3-eu-west-1.amazonaws.com/released-artifacts-3.x/assets/tutorial_images/creating-styles/step6a.png)

In a popup window, replace "Sprite URL" with

```
http://localhost:8080/sdk/sprites/sprite
```

and "Glyphs URL" with

```
http://localhost:8080/sdk/glyphs/{fontstack}/{range}.pbf
```

![step6b](https://s3-eu-west-1.amazonaws.com/released-artifacts-3.x/assets/tutorial_images/creating-styles/step6b.png)

Close the overlay to apply the changes by clicking on X in the top right corner.

## Edit a style
Duration: 0:15

Now, you should be able to see a map in the editor. From now on, you may edit all style properties and you will see an impact of your changes instantly. To give you a glimpse of possibilities, we will change the color of oceans. Click on an ocean on a map and select the "Ocean or sea" layer name from a popup.

![step7a](https://s3-eu-west-1.amazonaws.com/released-artifacts-3.x/assets/tutorial_images/creating-styles/step7a.png)

From "Paint properties", select "Color".
![step7c](https://s3-eu-west-1.amazonaws.com/released-artifacts-3.x/assets/tutorial_images/creating-styles/step7c.png)

Set a color of your choice. After this operation, oceans should be filled with a chosen color.
![step7d](https://s3-eu-west-1.amazonaws.com/released-artifacts-3.x/assets/tutorial_images/creating-styles/step7d.png)

## Export a style
Duration: 0:05

In order to download an edited style, click on the "Export" button.

![step8a](https://s3-eu-west-1.amazonaws.com/released-artifacts-3.x/assets/tutorial_images/creating-styles/step8a.png)

In a popup window, choose the **"Download"** button.

![step8b](https://s3-eu-west-1.amazonaws.com/released-artifacts-3.x/assets/tutorial_images/creating-styles/step8b.png)

Your new style should be available on your computer. Rename to gangdam.json ;) :) 

## Test your new style
Duration: 0:10

Now, it's time to test your style. Go [here](https://developer.tomtom.com/maps-sdk-web/functional-examples#vector-map-style-altering) and upload the modified style (click on the "Choose File" button). After a while you should achieve a following result:


![step9](https://image.ibb.co/b1pFAS/gangdam.png)

Above steps allow you configure a default TomTom style for edition in Maputnik. If you are interested in the topic of vector tiles or the style customization, please find the following list of suggested further readings:

1. Online Maps Vector Tile documentation (https://developer.tomtom.com/online-maps/online-maps-documentation-vector/tile) in order to create custom styles you need to know more about a data source. In advanced use cases, it is useful to know possible layers' names and their types.
2. Maputnik editor documentation (https://github.com/maputnik/editor/wiki) guides and tutorials for the Maputnik editor




