# `GeoFrame.Testing`
[🔗](https://github.com/CountlinkX-Solutions/geoframe/blob/v0.3.4/lib/geo_frame/testing.ex#L1)

Assertions for comparing geometry in tests, like `geopandas.testing`.

Both functions raise `ExUnit.AssertionError` (part of Elixir core, so there is no compile
time dependency on the test framework) with a readable report of the first differing rows,
and return `:ok` otherwise.

    import GeoFrame.Testing

    assert_geoseries_equal(result, expected)
    assert_geodataframe_equal(result, expected, check_less_precise: true)

## How geometries are compared

GeoPandas compares with topological `geom_equals` by default and with a tolerance when
`check_less_precise` is set; GeoFrame makes the same choice:

  * default - `GeoFrame.GeoSeries.geom_equals/2`: the same point set, so vertex order, start
    vertex and ring orientation do not matter;
  * `check_less_precise: true` - `GeoFrame.GeoSeries.geom_equals_exact/3` with a tolerance
    of `1.0e-6`, which does care about vertex order;
  * `normalize: true` - always the topological comparison, which is already independent of
    vertex order (GeoFrame has no `normalize` operation), so it wins over
    `check_less_precise`.

Two null rows are equal; a null row never equals a geometry. Two rows that both hold the
same empty geometry are equal.

## Options

  * `:check_crs` - also require equal CRS (default `true`).
  * `:check_less_precise` - tolerance comparison (default `false`). For frames it also lets
    float attribute values differ by `1.0e-6`.
  * `:check_geom_type` - also require equal geometry types per row (default `false`).
  * `:normalize` - see above (default `false`).
  * `:check_dtype` - frames only: require equal attribute dtypes (default `true`).

# `assert_geodataframe_equal`

```elixir
@spec assert_geodataframe_equal(
  GeoFrame.GeoDataFrame.t(),
  GeoFrame.GeoDataFrame.t(),
  keyword()
) :: :ok
```

Asserts two `GeoFrame.GeoDataFrame` are equal: same attribute and geometry column names in
order, equal attributes, equal geometries. Secondary geometry columns
(`GeoFrame.GeoDataFrame.put_geometry/3`) are compared like the active one, each with its own
CRS. See the module documentation for options.

## Examples

    iex> geometry = GeoFrame.GeoSeries.from_wkt!(["POINT (1 1)"])
    iex> gdf = GeoFrame.GeoDataFrame.new(Explorer.DataFrame.new(id: [1]), geometry)
    iex> GeoFrame.Testing.assert_geodataframe_equal(gdf, gdf)
    :ok

# `assert_geoseries_equal`

```elixir
@spec assert_geoseries_equal(
  GeoFrame.GeoSeries.t(),
  GeoFrame.GeoSeries.t(),
  keyword()
) :: :ok
```

Asserts two `GeoFrame.GeoSeries` are equal. See the module documentation for options.

## Examples

    iex> a = GeoFrame.GeoSeries.from_wkt!(["POINT (1 1)", nil])
    iex> b = GeoFrame.GeoSeries.from_wkt!(["POINT (1 1)", nil])
    iex> GeoFrame.Testing.assert_geoseries_equal(a, b)
    :ok

---

*Consult [api-reference.md](api-reference.md) for complete listing*
