MCPcopy Create free account
hub / github.com/Kitware/VTK / reproject_bbox

Function reproject_bbox

ThirdParty/libproj/vtklibproj/src/4D_api.cpp:984–1041  ·  view source on GitHub ↗

/

Source from the content-addressed store, hash-verified

982
983/*****************************************************************************/
984static void reproject_bbox(PJ* pjGeogToCrs,
985 double west_lon, double south_lat,
986 double east_lon, double north_lat,
987 double& minx,
988 double& miny,
989 double& maxx,
990 double& maxy) {
991/*****************************************************************************/
992
993 minx = -std::numeric_limits<double>::max();
994 miny = -std::numeric_limits<double>::max();
995 maxx = std::numeric_limits<double>::max();
996 maxy = std::numeric_limits<double>::max();
997
998 if( !(west_lon == -180.0 && east_lon == 180.0 &&
999 south_lat == -90.0 && north_lat == 90.0) )
1000 {
1001 minx = -minx;
1002 miny = -miny;
1003 maxx = -maxx;
1004 maxy = -maxy;
1005
1006 constexpr int N_STEPS = 20;
1007 constexpr int N_STEPS_P1 = N_STEPS+1;
1008 constexpr int XY_SIZE = N_STEPS_P1 * 4;
1009 std::vector<double> x(XY_SIZE);
1010 std::vector<double> y(XY_SIZE);
1011 const double step_lon = (east_lon - west_lon) / N_STEPS;
1012 const double step_lat = (north_lat - south_lat) / N_STEPS;
1013 for( int j = 0; j <= N_STEPS; j++ )
1014 {
1015 x[j] = west_lon + j * step_lon;
1016 y[j] = south_lat;
1017 x[N_STEPS_P1+j] = x[j];
1018 y[N_STEPS_P1+j] = north_lat;
1019 x[N_STEPS_P1*2+j] = west_lon;
1020 y[N_STEPS_P1*2+j] = south_lat + j * step_lat;
1021 x[N_STEPS_P1*3+j] = east_lon;
1022 y[N_STEPS_P1*3+j] = y[N_STEPS_P1*2+j];
1023 }
1024 proj_trans_generic (
1025 pjGeogToCrs, PJ_FWD,
1026 &x[0], sizeof(double), XY_SIZE,
1027 &y[0], sizeof(double), XY_SIZE,
1028 nullptr, 0, 0,
1029 nullptr, 0, 0);
1030 for( int j = 0; j < XY_SIZE; j++ )
1031 {
1032 if( x[j] != HUGE_VAL && y[j] != HUGE_VAL )
1033 {
1034 minx = std::min(minx, x[j]);
1035 miny = std::min(miny, y[j]);
1036 maxx = std::max(maxx, x[j]);
1037 maxy = std::max(maxy, y[j]);
1038 }
1039 }
1040 }
1041}

Callers 1

add_coord_op_to_listFunction · 0.85

Calls 3

proj_trans_genericFunction · 0.85
maxFunction · 0.50
minFunction · 0.50

Tested by

no test coverage detected