R package for downloading OpenStreetMap data
at main 73 lines 2.2 kB view raw
1/*************************************************************************** 2 * Project: osmdata 3 * File: get-bbox.cpp 4 * Language: C++ 5 * 6 * osmdata is free software: you can redistribute it and/or modify it under 7 * the terms of the GNU General Public License as published by the Free 8 * Software Foundation, either version 3 of the License, or (at your option) 9 * any later version. 10 * 11 * osmdata is distributed in the hope that it will be useful, but WITHOUT ANY 12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 14 * details. 15 * 16 * You should have received a copy of the GNU General Public License along with 17 * osm-router. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * Author: Mark Padgham 20 * E-Mail: mark.padgham@email.com 21 * 22 * Description: Header for rcpp_get_bbox 23 * 24 * Limitations: 25 * 26 * Dependencies: none (rapidXML header included in osmdata) 27 * 28 * Compiler Options: -std=c++11 29 ***************************************************************************/ 30 31#include "get-bbox.h" 32 33Rcpp::NumericMatrix rcpp_get_bbox (double xmin, double xmax, double ymin, double ymax) 34{ 35 std::vector <std::string> colnames, rownames; 36 colnames.push_back ("min"); 37 colnames.push_back ("max"); 38 rownames.push_back ("x"); 39 rownames.push_back ("y"); 40 Rcpp::List dimnames (2); 41 dimnames (0) = rownames; 42 dimnames (1) = colnames; 43 44 Rcpp::NumericMatrix bbox (Rcpp::Dimension (2, 2)); 45 bbox (0, 0) = xmin; 46 bbox (0, 1) = xmax; 47 bbox (1, 0) = ymin; 48 bbox (1, 1) = ymax; 49 50 bbox.attr ("dimnames") = dimnames; 51 52 return bbox; 53} 54 55Rcpp::NumericVector rcpp_get_bbox_sf (double xmin, double xmax, double ymin, double ymax) 56{ 57 std::vector <std::string> names; 58 names.push_back ("xmin"); 59 names.push_back ("ymin"); 60 names.push_back ("xmax"); 61 names.push_back ("ymax"); 62 63 Rcpp::NumericVector bbox (4, NA_REAL); 64 bbox (0) = xmin; 65 bbox (1) = xmax; 66 bbox (2) = ymin; 67 bbox (3) = ymax; 68 69 bbox.attr ("names") = names; 70 bbox.attr ("class") = "bbox"; 71 72 return bbox; 73}