HotPixel.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* 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: noding/snapround/HotPixel.java r320 (JTS-1.12)
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <geos/geom/Coordinate.h> // for composition
#include <geos/util/IllegalArgumentException.h>
#include <geos/util/math.h>
#include <array>
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
#endif
// Forward declarations
namespace geos {
namespace geom {
class Envelope;
}
namespace algorithm {
class LineIntersector;
}
namespace noding {
class NodedSegmentString;
}
}
namespace geos {
namespace noding { // geos::noding
namespace snapround { // geos::noding::snapround
class GEOS_DLL HotPixel {
private:
static constexpr double TOLERANCE = 0.5;
static constexpr int UPPER_RIGHT = 0;
static constexpr int UPPER_LEFT = 1;
static constexpr int LOWER_LEFT = 2;
static constexpr int LOWER_RIGHT = 3;
// Store all ordinates because we may use them in constructing a SegmentNode.
geom::CoordinateXYZM originalPt;
double scaleFactor;
/* The scaled ordinates of the hot pixel point */
double hpx;
double hpy;
/* Indicates if this hot pixel must be a node in the output. */
bool hpIsNode;
double scaleRound(double val) const
{
// Use Java-compatible round implementation
return util::round(val * scaleFactor);
};
double scale(double val) const
{
return val * scaleFactor;
};
bool intersectsPixelClosure(const geom::Coordinate& p0,
const geom::Coordinate& p1) const;
bool intersectsScaled(double p0x, double p0y, double p1x, double p1y) const;
// Declare type as noncopyable
HotPixel(const HotPixel& other) = delete;
HotPixel& operator=(const HotPixel& rhs) = delete;
public:
double getWidth() const { return 1.0 / scaleFactor; };
double getScaleFactor() const { return scaleFactor; };
template<typename CoordType>
HotPixel(const CoordType& pt, double scaleFact)
: originalPt(pt)
, scaleFactor(scaleFact)
, hpx(pt.x)
, hpy(pt.y)
, hpIsNode(false)
{
if(scaleFactor <= 0.0) {
throw util::IllegalArgumentException("Scale factor must be non-zero");
}
if(scaleFactor != 1.0) {
hpx = scaleRound(pt.x);
hpy = scaleRound(pt.y);
}
}
/*
* Gets the coordinate this hot pixel is based at.
*
* @return the coordinate of the pixel
*/
const geom::CoordinateXYZM& getCoordinate() const;
bool intersects(const geom::CoordinateXY& p0,
const geom::CoordinateXY& p1) const;
bool intersects(const geom::CoordinateXY& p) const;
bool isNode() const { return hpIsNode; };
void setToNode() { hpIsNode = true; };
std::ostream& operator<< (std::ostream& os);
};
} // namespace geos::noding::snapround
} // namespace geos::noding
} // namespace geos
#ifdef _MSC_VER
#pragma warning(pop)
#endif
geos::algorithm::LineIntersector
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition LineIntersector.h:53
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
geos::geom::Envelope
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
geos::noding::NodedSegmentString
Represents a list of contiguous line segments, and supports noding the segments.
Definition NodedSegmentString.h:58
geos::noding::snapround::HotPixel::intersects
bool intersects(const geom::CoordinateXY &p) const
geos::noding::snapround::HotPixel::HotPixel
HotPixel(const CoordType &pt, double scaleFact)
Definition HotPixel.h:117
geos::noding::snapround::HotPixel::getWidth
double getWidth() const
Definition HotPixel.h:107
geos::noding::snapround::HotPixel::intersects
bool intersects(const geom::CoordinateXY &p0, const geom::CoordinateXY &p1) const
geos::util::IllegalArgumentException
Indicates one or more illegal arguments.
Definition IllegalArgumentException.h:33
geos::algorithm
Contains classes and interfaces implementing fundamental computational geometry algorithms.
Definition Angle.h:32
geos::geom
Definition Angle.h:26
geos::noding::snapround
Contains classes to implement the Snap Rounding algorithm for noding linestrings.
Definition namespaces.h:175
geos::noding
Classes to compute nodings for arrangements of line segments and line segment sequences.
Definition CoverageCleaner.h:42
geos::util::round
double round(double val)
Definition math.h:36
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38