Payload sizing

A count site represents a logical object (like an intersection or a parking facility)  where speeds, flows, counts, etc. are measured with different technologies (for example, loops and cameras). It is a logical aggregation of many types of hardware devices.

A count site is composed of one or more count locations.

A count location is composed of one or more detectors.

You can build the entire hierarchy of a count site by defining a payload to feed the POST endpoint:

POST https://api.ptvgroup.tech/dataprovider/v1/detectors/count-site

If the count site hierarchy is very extended, it could be necessary to build a very "big" payload. If the size of the paylaod overcomes 1 Mb, the endpoint elaboration could fail with an HTTP code 413 - Content too large.

You can avoid this situation through two distinct strategies.

Payload minimization

You can reduce the volume of the payload through this procedure:

  1. Build your payload in JSON format.
  2. Delete all spaces (maintaining the correctness of the structure).
  3. Delete all newline characters (maintaining the correctness of the structure).
  4. Send the resulting payload using HTTP gzip compression.
EXAMPLE for Linux environment

The command that you can use in Linux environment to perform steps 2 and 3 is:

cat payload_name.json | jq -c > payload_name.min.json

EXAMPLE for Windows environment

The command that you can use in Windows environment (PowerShell/cmd.exe) to perform steps 2 and 3 is:

jq -c . payload_name.json > payload_name.min.json

 

Payload splitting

You can build the count site payload, splitting the structure through a well-defined sequence of POST endpoints.

For example, if you have M count sites, you can decide to deploy two sets of N=M/2 count sites using two distinct requests.

To achieve this goal, you can use an endpoint that deploys an array of N count sites, each of them with the associated payload describing the count site hierarchy of count locations and detectors:

POST https://api.ptvgroup.tech/dataprovider/v1/detectors/count-site

For additional details, see Reference API.