27#include <unordered_map>
44 const std::string& replace)
47 while((pos = target.find(match, pos)) != std::string::npos)
49 target.replace(pos, match.length(), replace);
50 pos += replace.length();
65using point_2t = std::tuple<space_type, space_type>;
76 std::ostringstream oss;
93 const double xscale = 1,
const double yscale = 1)
95 for (
const auto& [x, y] : cpoints)
97 xpoints.push_back(x / xscale);
98 ypoints.push_back(y / yscale);
108 vr.insert(vr.end(), r1.begin(), r1.end());
109 vr.insert(vr.end(), r2.begin(), r2.end());
123 double duprangep(
false);
127 if (y != get<1>(
last))
129 if (duprangep ==
true)
131 simplevr.push_back(
last);
134 simplevr.push_back(
pt);
150 if (!xpoints.empty() && !ypoints.empty())
152 sort(xpoints.begin(), xpoints.end());
153 sort(ypoints.begin(), ypoints.end());
157 const bool padp(
true);
160 const double sigd = pow(10, pown);
162 const double dx = xpoints.back();
163 double ix = std::round(dx * sigd) / sigd;
165 xpoints.push_back(ix);
167 const double dy = ypoints.back();
168 uint iy = std::round(dy * sigd) / sigd;
170 ypoints.push_back(iy);
174 rangemaxx = std::make_tuple(xpoints.back(), ypoints.back());
183 const double xscale = 1,
const double yscale = 1)
197 const double sigd = pow(10, pown);
199 for (
const double& d : points)
204 uint itrunc(dn * sigd);
205 npoints.push_back(itrunc / sigd);
208 npoints.push_back(dn);
220 double rmultp(nceil - nfloor);
221 double valnum(value - min);
222 double valdenom(max - min);
223 double weightn = (rmultp * (valnum / valdenom)) + nfloor;
232 auto [ x1, y1 ] = p1;
233 auto [ x2, y2 ] = p2;
234 auto distancex = (x2 - x1) * (x2 - x1);
235 auto distancey = (y2 - y1) * (y2 - y1);
236 space_type distance = sqrt(distancex + distancey);
258 static double dpi(96.0);
275 constexpr double dpimult = 1.33;
276 return std::lround(i * dpimult);
311constexpr double pi(3.14159265358979323846);
constexpr double pi(3.14159265358979323846)
constexpr char quote('"')
constexpr char comma(',')
constexpr char newline('\n')
constexpr char space(' ')
Formatting character constants.
constexpr char hyphen('-')
@ pt
Point where 1 pixel x 1/72 dpi x 96 PPI = .26 mm.
unsigned short ushort
Base integer type: positive and negative, signed integral value.
vrange find_vrange_change_points(const vrange &vr)
Simplify sorted vrange by removing interior duplicates.
bool detect_collision(const point_2t &p1, const int r1, const point_2t &p2, const int r2)
vspace narrow_vspace(const vspace &points, uint pown)
Truncate double to double with pown signifigant digits.
vrange union_vrange(const vrange &r1, const vrange &r2)
Union two ranges.
std::set< point_2t > srange
Latitude and Longitude Ranges.
double scale_value_on_range(const ssize_type value, const ssize_type min, const ssize_type max, const ssize_type nfloor, const ssize_type nceil)
Scale value from min to max on range (nfloor, nceil).
const string to_string(const unit e)
void string_replace(std::string &target, const std::string &match, const std::string &replace)
double pt_to_px(const uint i=1)
Conversion between point size to pixels given dpi density.
double space_type
Base floating point type.
std::vector< strings > vvstrings
std::vector< vrange > vvranges
std::vector< point_2t > vrange
point_2t max_vrange(vspace &xpoints, vspace &ypoints, const uint pown)
For each dimension of vrnage, find min/max and return (xmax, ymax) NB: Assumes zero is min.
std::tuple< point_2t, ssize_type > point_2tn
Point (x,y) in 2D space with weight n.
constexpr double char_width_to_px(const uint sz)
Approximate pixel height of type of point size @sz.
std::vector< double > vspace
Split range, so one dimension of (x,y) cartesian plane.
constexpr double char_height_to_px(const uint sz)
Approximate pixel height of type of point size @sz.
void split_vrange(const vrange &cpoints, vspace &xpoints, vspace &ypoints, const double xscale=1, const double yscale=1)
Decompose/split 2D ranges to 1D spaces, perhaps with scaling.
double & get_dpi()
Resolution of output display device.
space_type distance_cartesian(const point_2t &p1, const point_2t &p2)
Find cartesian distance between two 2D points.
std::tuple< space_type, space_type > point_2t
Point (x,y) in 2D space.
std::vector< string > strings