# Create A Region

Regions (`BaseRegion`s) are geographical areas that do not yet have any of the necessary extra information to start a download (this is the responsibility of`DownloadableRegion`).

There are 4 types of `BaseRegion`:

{% tabs %}
{% tab title="Rectangle" %}
`RectangleRegion`s are defined by a `LatLngBounds`: two opposite `LatLng`s.

```dart
final region = RectangleRegion(
    LatLngBounds(LatLng(0, 0), LatLng(1, 1)),
);
```

{% hint style="info" %}
This is usually all you get from most apps, so why not give your user a unique experience with some of our other region types...
{% endhint %}
{% endtab %}

{% tab title="Circle" %}
`CircleRegion`s are defined by a center `LatLng` and radius *in kilometers*.

```dart
final region = CircleRegion(
    LatLng(0, 0), // Center coordinate
    1, // Radius in kilometers
);
```

If you instead have two coordinates, one in the center, and one on the edge, you can use ['latlong2's `Distance.distance()`](https://pub.dev/documentation/latlong2/latest/latlong2/Distance/distance.html) method, as below:

```dart
final centerCoordinate = LatLng(0, 0); // Center coordinate
final region = CircleRegion(
    centerCoordinate,
    const Distance(roundResult: false).distance(
        centerCoordinate,
        LatLng(1, 1), // Edge coordinate
    ) / 1000; // Convert to kilometers
);
```

{% endtab %}

{% tab title="(Poly)Line" %}
`LineRegion`s are defined by a list of `LatLng`s, and a radius in meters.

This could be used to download tiles along a planned travel route, for example hiking or long-distance driving. Import coordinates from a routing engine, or from a GPX/KML file for maximum integration!

```dart
final region = LineRegion(
    [LatLng(0, 0), LatLng(1, 1), ...], // List of coordinates
    1000, // Radius in meters
);
```

{% hint style="warning" %}
This region may generate more tiles than strictly necessary to cover the specified region. This is due to an internal limitation with the region generation algorithm, which uses rectangles to approximate the actual desired shape.
{% endhint %}

{% hint style="warning" %}
This type of region may consume more memory/RAM when generating tiles than other region types.
{% endhint %}
{% endtab %}

{% tab title="Custom Polygon" %}
`CustomPolygonRegion`s are defined by a list of `LatLng`s defining the outline of a [simple polygon](https://en.wikipedia.org/wiki/Simple_polygon).

```dart
final region = CustomPolygonRegion(
    [LatLng(0, 0), LatLng(1, 1), ...], // List of coordinates
);
```

{% hint style="warning" %}
Polygons should not contain self-intersections. These may produce unexpected results.

Holes are not supported.
{% endhint %}
{% endtab %}

{% tab title="Recoverable" %}
`RecoverableRegion`s aren't technically the same type of region as the others, and is the odd one out.

However, it can be converted to a downloadable region in the same way as the others, or the original `BaseRegion` extracted using `toRegion`.

For more info, see [Recovery](/v9/stores-and-roots/roots/recovery.md).
{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://fmtc.jaffaketchup.dev/v9/bulk-downloading/regions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
