1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
/*
# (C) British Crown Copyright 2010 - 2016, Met Office
#
# This file is part of cartopy.
#
# cartopy is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the
# Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cartopy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with cartopy. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef _TRACE_H
#define _TRACE_H
#include <iostream>
#include <geos_c.h>
#include <proj_api.h>
typedef struct {
double x;
double y;
} Point;
typedef struct {
double x;
double y;
double z;
} Vec3;
class Interpolator
{
public:
virtual ~Interpolator();
virtual void set_line(const Point &start, const Point &end);
virtual Point interpolate(double t)=0;
virtual Point project(const Point &point)=0;
protected:
Point m_start, m_end;
};
class CartesianInterpolator : public Interpolator
{
public:
CartesianInterpolator(projPJ src_proj, projPJ dest_proj);
Point interpolate(double t);
Point project(const Point &point);
private:
projPJ m_src_proj, m_dest_proj;
};
class SphericalInterpolator : public Interpolator
{
public:
// XXX Move the constructor and members up to the superclass?
SphericalInterpolator(projPJ src_proj, projPJ dest_proj);
void set_line(const Point &start, const Point &end);
Point interpolate(double t);
Point project(const Point &point);
private:
projPJ m_src_proj, m_dest_proj;
Vec3 m_start3, m_perp3;
double m_angle;
};
GEOSGeometry *_project_line_string(GEOSContextHandle_t handle,
GEOSGeometry *g_line_string,
Interpolator *interpolator,
GEOSGeometry *g_domain, double threshold);
#endif // _TRACE_H
|