# constructors

This module contains functions that create new geographies from coordinates or already existing geographies.

## ST\_BEZIERSPLINE <a href="#st_bezierspline" id="st_bezierspline"></a>

```sql
ST_BEZIERSPLINE(linestring [, resolution] [, sharpness])
```

**Description**

Takes a line and returns a curved version of it by applying a Bezier spline algorithm. Note that the resulting geography will be a LineString with additional points inserted.

**Input parameters**

* `geog`: `GEOMETRY` input LineString.
* `resolution` (optional): `INT` total time in milliseconds assigned to the line. Tthe default value is `10000`. Internal curve vertices are generated in 10 ms increments, so the maximum number of resulting points will be `resolution/10` (close points may be merged resulting in less points). A higher number will increase the accuracy of the result but will increase the computation time and number of points.
* `sharpness` (optional): `FLOAT8` a measure of how curvy the path should be between splines. If not specified, the default value of `0.85` will be used.

**Return type**

`VARCHAR(MAX)`

**Examples**

{% code overflow="wrap" lineNumbers="true" %}

```sql
SELECT carto.ST_BEZIERSPLINE(
  ST_GEOMFROMTEXT(
    'LINESTRING (-76.091308 18.427501,-76.695556 18.729501,-76.552734 19.40443,-74.61914 19.134789,-73.652343 20.07657,-73.157958 20.210656)'
  )
);
-- {"type": "LineString", "coordinates": [[-76.091308, 18.427501], [-76.09134585033101, 18.427508082543092], ...
```

{% endcode %}

{% code overflow="wrap" lineNumbers="true" %}

```sql
SELECT carto.ST_BEZIERSPLINE(
  ST_GEOMFROMTEXT(
    'LINESTRING (-76.091308 18.427501,-76.695556 18.729501,-76.552734 19.40443,-74.61914 19.134789,-73.652343 20.07657,-73.157958 20.210656)'
  ),
  10000
);
-- {"type": "LineString", "coordinates": [[-76.091308, 18.427501], [-76.09134585033101, 18.427508082543092], ...
```

{% endcode %}

{% code overflow="wrap" lineNumbers="true" %}

```sql
SELECT carto.ST_BEZIERSPLINE(
  ST_GEOMFROMTEXT(
    'LINESTRING (-76.091308 18.427501,-76.695556 18.729501,-76.552734 19.40443,-74.61914 19.134789,-73.652343 20.07657,-73.157958 20.210656)'
  ),
  10000,
  0.9
);
-- {"type": "LineString", "coordinates": [[-76.091308, 18.427501], [-76.09134541990707, 18.42750717125151], ...
```

{% endcode %}

## ST\_MAKEELLIPSE <a href="#st_makeellipse" id="st_makeellipse"></a>

```sql
ST_MAKEELLIPSE(center, xSemiAxis, ySemiAxis [, angle] [, units] [, steps])
```

**Description**

Takes a Point as input and calculates the ellipse polygon given two semi-axes expressed in variable units and steps for precision.

**Input parameters**

* `center`: `GEOMETRY` center point.
* `xSemiAxis`: `FLOAT8` semi (major) axis of the ellipse along the x-axis.
* `ySemiAxis`: `FLOAT8` semi (minor) axis of the ellipse along the y-axis.
* `angle` (optional): `FLOAT8` angle of rotation (along the horizontal axis), from East in decimal degrees, positive clockwise. If not specified, the default value of `0` will be used.
* `units` (optional): `VARCHAR(10)` units of length. The supported options are: miles, kilometers, meters, and degrees. If not specified, `kilometers` will be used.
* `steps` (optional): `INT` number of steps. If not specified, the default value of `64` will be used.

**Return type**

`VARCHAR(MAX)`

**Examples**

{% code overflow="wrap" lineNumbers="true" %}

```sql
SELECT carto.ST_MAKEELLIPSE(ST_POINT(-73.9385,40.6643), 5, 3);
-- {"type": "Polygon", "coordinates": [[[-73.87922034627275, 40.6643], [-73.88056149301754, 40.67000644486112], ...
```

{% endcode %}

{% code overflow="wrap" lineNumbers="true" %}

```sql
SELECT carto.ST_MAKEELLIPSE(ST_POINT(-73.9385,40.6643), 5, 3, -30);
-- {"type": "Polygon", "coordinates": [[[-73.88703173808466, 40.68643711664552], [-73.89195608204625, 40.69086946050236], ...
```

{% endcode %}

{% code overflow="wrap" lineNumbers="true" %}

```sql
SELECT carto.ST_MAKEELLIPSE(ST_Point(-73.9385,40.6643), 5, 3, -30, 'miles');
-- {"type": "Polygon", "coordinates": [[[-73.85566162723387, 40.69992623586439], [-73.86358797643032, 40.707058494394765], ...
```

{% endcode %}

{% code overflow="wrap" lineNumbers="true" %}

```sql
SELECT carto.ST_MAKEELLIPSE(ST_Point(-73.9385,40.6643), 5, 3, -30, 'miles', 80);
-- {"type": "Polygon", "coordinates": [[[-73.8557003345262, 40.70003619338248], [-73.86178810440265, 40.705912341919415], ...
```

{% endcode %}

## ST\_MAKEENVELOPE <a href="#st_makeenvelope" id="st_makeenvelope"></a>

```sql
ST_MAKEENVELOPE(xmin, ymin, xmax, ymax)
```

**Description** Creates a rectangular Polygon from the minimum and maximum values for X and Y.

**Input parameters**

* `xmin`: `FLOAT8` minimum value for X.
* `ymin`: `FLOAT8` minimum value for Y.
* `xmax`: `FLOAT8` maximum value for X.
* `ymax`: `FLOAT8` maximum value for Y.

**Return type**

`GEOMETRY`

**Example**

{% code overflow="wrap" lineNumbers="true" %}

```sql
SELECT carto.ST_MAKEENVELOPE(0, 0, 1, 1);
-- POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))
```

{% endcode %}

## ST\_TILEENVELOPE <a href="#st_tileenvelope" id="st_tileenvelope"></a>

```sql
ST_TILEENVELOPE(zoomLevel, xTile, yTile)
```

**Description** Returns the boundary polygon of a tile given its zoom level and its X and Y indices.

**Input parameters**

* `zoomLevel`: `INT` zoom level of the tile.
* `xTile`: `INT` X index of the tile.
* `yTile`: `INT` Y index of the tile.

**Return type**

`GEOMETRY`

**Example**

{% code overflow="wrap" lineNumbers="true" %}

```sql
SELECT carto.ST_TILEENVELOPE(10, 384, 368);
-- {'type': 'Polygon', 'coordinates': [[[-45.0, 44.84029065139799], [-45.0, 45.089035564831015], ...
```

{% endcode %}
