GridIntersection.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2018-2025 ISciences, LLC
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************/
#pragma once
#include <memory>
#include <geos/geom/Geometry.h>
#include <geos/operation/grid/Grid.h>
#include <geos/operation/grid/Matrix.h>
namespace geos::geom {
class Geometry;
class LineString;
}
namespace geos::operation::grid {
class Cell;
class GEOS_DLL GridIntersection
{
public:
GridIntersection(const Grid<bounded_extent>& raster_grid, const geom::Geometry& g, std::shared_ptr<Matrix<float>> cov = nullptr);
GridIntersection(const Grid<bounded_extent>& raster_grid, const geom::Envelope& box, std::shared_ptr<Matrix<float>> cov = nullptr);
std::shared_ptr<Matrix<float>> getResults() { return m_results; }
static std::unique_ptr<geom::Geometry> subdividePolygon(const Grid<bounded_extent>& p_grid, const geom::Geometry& g, bool includeExterior);
static std::shared_ptr<Matrix<float>>
getIntersectionFractions(const Grid<bounded_extent>& raster_grid, const geom::Geometry& g);
static std::shared_ptr<Matrix<float>>
getIntersectionFractions(const Grid<bounded_extent>& raster_grid, const geom::Envelope& box);
static geom::Envelope
processingRegion(const geom::Envelope& raster_extent, const geom::Geometry& geometry);
private:
void process(const geom::Geometry& g);
void processLine(const geom::LineString& ls, bool exterior_ring);
void processRectangularRing(const geom::Envelope& box, bool exterior_ring);
void addRingResults(size_t i0, size_t j0, const Matrix<float>& areas, bool exterior_ring);
void setAreal(bool areal);
static Matrix<float> collectAreas(const Matrix<std::unique_ptr<Cell>>& cells,
const Grid<bounded_extent>& finite_ring_grid,
const geom::Geometry& g);
Grid<infinite_extent> m_geometry_grid;
std::shared_ptr<Matrix<float>> m_results;
bool m_first_geom;
bool m_areal;
};
}
geos::geom::Envelope
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
geos::geom::Geometry
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:196
geos::geom::LineString
Definition LineString.h:66
geos::operation::grid::Cell
The Cell class stores information about the spatial extent of a Grid cell and any cases where a line ...
Definition Cell.h:30
geos::operation::grid::GridIntersection::GridIntersection
GridIntersection(const Grid< bounded_extent > &raster_grid, const geom::Envelope &box, std::shared_ptr< Matrix< float > > cov=nullptr)
Compute the fraction of each cell in a rectangular grid that is covered by an Envelope....
geos::operation::grid::GridIntersection::processingRegion
static geom::Envelope processingRegion(const geom::Envelope &raster_extent, const geom::Geometry &geometry)
Determines the bounding box of the raster-vector intersection. Considers the bounding boxes of indivi...
geos::operation::grid::GridIntersection::subdividePolygon
static std::unique_ptr< geom::Geometry > subdividePolygon(const Grid< bounded_extent > &p_grid, const geom::Geometry &g, bool includeExterior)
Partition a polygonal geometry by a grid.
geos::operation::grid::GridIntersection::GridIntersection
GridIntersection(const Grid< bounded_extent > &raster_grid, const geom::Geometry &g, std::shared_ptr< Matrix< float > > cov=nullptr)
Compute the fraction of each cell in a rectangular grid that is covered by a Geometry....
geos::operation::grid::GridIntersection::getResults
std::shared_ptr< Matrix< float > > getResults()
Return the intersection result matrix.
Definition GridIntersection.h:59
geos::geom
Definition Angle.h:26