<commit_before>/**********************************************************************
 * $Id$
 *
 * GEOS - Geometry Engine Open Source
 * http://geos.refractions.net
 *
 * Copyright (C) 2006 Refractions Research Inc.
 *
 * 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.
 *
 **********************************************************************
 *
 * Last port: operation/distance/DistanceOp.java rev 1.17
 *
 **********************************************************************/

#ifndef GEOS_OP_DISTANCE_DISTANCEOP_H
#define GEOS_OP_DISTANCE_DISTANCEOP_H

#include <geos/algorithm/PointLocator.h> // for composition

#include <vector>

// Forward declarations
namespace geos {
	namespace geom { 
		class Coordinate;
		class Polygon;
		class LineString;
		class Point;
		class Geometry;
		class CoordinateSequence;
	}
	namespace operation { 
		namespace distance { 
			class GeometryLocation;
		}
	}
}


namespace geos {
namespace operation { // geos::operation
namespace distance { // geos::operation::distance

/**
 * \brief
 * Find two points on two {@link Geometry}s which lie
 * within a given distance, or else are the nearest points
 * on the geometries (in which case this also
 * provides the distance between the geometries).
 * 
 * The distance computation also finds a pair of points in the
 * input geometries which have the minimum distance between them.
 * If a point lies in the interior of a line segment,
 * the coordinate computed is a close
 * approximation to the exact point.
 * 
 * The algorithms used are straightforward O(n^2)
 * comparisons.  This worst-case performance could be improved on
 * by using Voronoi techniques or spatial indexes.
 *
 */
class DistanceOp {
public:
	/**
	 * \brief
	 * Compute the distance between the closest points of two geometries.
	 *
	 * @param g0 a {@link Geometry}
	 * @param g1 another {@link Geometry}
	 * @return the distance between the geometries
	 */
	static double distance(const geom::Geometry& g0,
	                       const geom::Geometry& g1);

	/// @deprecated, use the version taking references
	static double distance(const geom::Geometry *g0,
	                        const geom::Geometry *g1);

	/**
	 * \brief
	 * Test whether two geometries lie within a given distance of
	 * each other.
	 *
	 * @param g0 a {@link Geometry}
	 * @param g1 another {@link Geometry}
	 * @param distance the distance to test
	 * @return true if g0.distance(g1) <= distance
	 */
	static bool isWithinDistance(const geom::Geometry& g0,
	                             const geom::Geometry& g1,
	                                            double distance);

	/**
	 * Compute the the closest points of two geometries.
	 * The points are presented in the same order as the input Geometries.
	 *
	 * @param g0 a {@link Geometry}
	 * @param g1 another {@link Geometry}
	 * @return the closest points in the geometries, ownership to caller
	 */
	static geom::CoordinateSequence* closestPoints(geom::Geometry *g0, geom::Geometry *g1);

	/// @deprecated use the one taking references
	DistanceOp(const geom::Geometry *g0, const geom::Geometry *g1);

	/**
	 * \brief
	 * Constructs a DistanceOp that computes the distance and<commit_msg>Document semantic of a null return from closestPoints<commit_after>/**********************************************************************
 * $Id$
 *
 * GEOS - Geometry Engine Open Source
 * http://geos.refractions.net
 *
 * Copyright (C) 2006 Refractions Research Inc.
 *
 * 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.
 *
 **********************************************************************
 *
 * Last port: operation/distance/DistanceOp.java rev 1.17
 *
 **********************************************************************/

#ifndef GEOS_OP_DISTANCE_DISTANCEOP_H
#define GEOS_OP_DISTANCE_DISTANCEOP_H

#include <geos/algorithm/PointLocator.h> // for composition

#include <vector>

// Forward declarations
namespace geos {
	namespace geom { 
		class Coordinate;
		class Polygon;
		class LineString;
		class Point;
		class Geometry;
		class CoordinateSequence;
	}
	namespace operation { 
		namespace distance { 
			class GeometryLocation;
		}
	}
}


namespace geos {
namespace operation { // geos::operation
namespace distance { // geos::operation::distance

/**
 * \brief
 * Find two points on two {@link Geometry}s which lie
 * within a given distance, or else are the nearest points
 * on the geometries (in which case this also
 * provides the distance between the geometries).
 * 
 * The distance computation also finds a pair of points in the
 * input geometries which have the minimum distance between them.
 * If a point lies in the interior of a line segment,
 * the coordinate computed is a close
 * approximation to the exact point.
 * 
 * The algorithms used are straightforward O(n^2)
 * comparisons.  This worst-case performance could be improved on
 * by using Voronoi techniques or spatial indexes.
 *
 */
class DistanceOp {
public:
	/**
	 * \brief
	 * Compute the distance between the closest points of two geometries.
	 *
	 * @param g0 a {@link Geometry}
	 * @param g1 another {@link Geometry}
	 * @return the distance between the geometries
	 */
	static double distance(const geom::Geometry& g0,
	                       const geom::Geometry& g1);

	/// @deprecated, use the version taking references
	static double distance(const geom::Geometry *g0,
	                        const geom::Geometry *g1);

	/**
	 * \brief
	 * Test whether two geometries lie within a given distance of
	 * each other.
	 *
	 * @param g0 a {@link Geometry}
	 * @param g1 another {@link Geometry}
	 * @param distance the distance to test
	 * @return true if g0.distance(g1) <= distance
	 */
	static bool isWithinDistance(const geom::Geometry& g0,
	                             const geom::Geometry& g1,
	                                            double distance);

	/**
	 * Compute the the closest points of two geometries.
	 *
	 * The points are presented in the same order as the input Geometries.
	 *
	 * @param g0 a {@link Geometry}
	 * @param g1 another {@link Geometry}
	 *
	 * @return the closest points in the geometries, ownership to caller.
	 *         A NULL return means one of the geometries is empty.
	 */
	static geom::CoordinateSequence* closestPoints(
	                                        const geom::Geometry *g0,
	                                        const geom::Geometry *g1);

	/// @deprecated use the one taking references
	DistanceOp(const geom::Geometry *g0, const geom::Geometry *g1);

	/**
	 * \brief
	 * Constructs a DistanceOp that computes the distance and
{'fraction_non_alphanumeric': 0.13834391229082516, 'fraction_numerical': 0.0075014425851125215, 'mean_word_length': 3.2481617647058822, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7481836', 'n_tokens_mistral': 1942, 'n_tokens_neox': 1692, 'n_words': 729}