All Products
Search
Document Center

PolarDB:ST_ShadowRatio

Last Updated:Oct 13, 2023

This topic describes the ST_ShadowRatio function. This function calculates the shadow ratio of a single point or multiple points over a period of time or at a point in time.

Syntax

geometry  ST_ShadowRatio(scene  sc, geometry points, cstring sunlight);
geometry  ST_ShadowRatio(scene  sc, geometry points,  geometry location, cstring time);

Parameters

Parameter

Description

sc

The scene object.

points

The point data that is used to calculate the shadow ratio. The value is of the Geometry type.

sunlight

The sunlight information. The value is in the JSON format.

location

The longitude and latitude of the scene for shadow analysis. The value is of the Geometry type.

time

The time when the shadow ratio is analyzed.

The following table describes the fields of the JSON-formatted sunlight parameter.

Field

Description

Remarks

location

The longitude and latitude of the scene in which the shadow ratio is analyzed. For example, if the shadow ratio of a community in Beijing, China is analyzed, the longitude and latitude coordinate of the community is used.

The European Petroleum Survey Group (EPSG) 4326 coordinate system must be used. The coordinates in scene objects are local coordinates. This field is required to specify the longitude and latitude of the scene object to calculate the sunlight direction.

start_time

The start time of the shadow ratio analysis.

The value must be in a valid time format.

end_time

The end time of the shadow ratio analysis.

The value must be in a valid time format.

time_interval

The sampling interval at which the shadow ratio is analyzed.

The value cannot be 0.

The following example describes the sunlight parameter:

{
  sunlight = {
  "location": "srid=4326; POINT(120 30)", //The longitude and latitude.
  "start_time": "2021-07-12 08:00:00+0800", //The start time.
  "end_time": "2021-07-12 18:00:00+0800", //The end time.
  "time_interval": "01:00:00" //The sampling interval.
}

Description

  • Method 1: This function samples data at a specified interval to calculate the shadow ratio of one or more points based on the input sunlight information. Then, the function records the shadow ratio in the m-coordinate of one or more points.

  • Method 2: This function checks whether the shadow covers one or more points at a specified time. If the shadow covers one or more points, the shadow ratio is 1. If the shadow does not cover one or more points, the shadow ratio is 0. The function records the shadow ratio in the m-coordinate of one or more points.

Examples

  • Method 1

    SELECT ST_AsText(ST_ShadowRatio(the_scene, 'MULTIPOINT(0 0 -2, 1 2 8, -70 -400 1330)'::geometry, '{"location": "srid=4326; POINT(120 30)", 
        "start_time": "2021-07-12 08:00:00 +0800", "end_time":"2021-07-12 18:00:00 +0800", "time_interval": "01:00:00"}')) from t_scene;
    --------
    MULTIPOINT ZM ((0 0 -2 0.636363636363636),(1 2 8 0),(-70 -400 1330 0))
  • Method 2

    SELECT ST_AsText(ST_ShadowRatio(the_scene, 'MULTIPOINT(-2 0 0, 0 0 0, 2 0 0, 0 0 2)'::geometry, 'srid=4326; POINT(120 30)'::geometry,
        '2021-07-12 12:00:00 +0800')) from t_scene;
    --------
     MULTIPOINT ZM ((-2 0 0 0),(0 0 0 1),(2 0 0 0),(0 0 2 0))