/usr/include/mongo/geo/coordinates2d.h is in libmongoclient-dev 1.1.2-6ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | /* Copyright 2014 MongoDB Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** @file */
#pragma once
#include <utility>
#include <vector>
#include "mongo/client/export_macros.h"
#include "mongo/db/jsobj.h"
#include "mongo/geo/coordinates.h"
namespace mongo {
namespace geo {
/**
* Represents a 2D position (x, y).
*
* Example Usage:
*
* Coordinates2D coords(1, 2);
* Point<Coordinates2D> point(coords);
* Query nearQuery = QUERY("<field_name>" << NEAR(point));
* conn.query("<db_name>.<collection_name>", nearQuery);
*/
class MONGO_CLIENT_API Coordinates2D : public Coordinates {
public:
Coordinates2D() : _x(0), _y(0) {}
/**
* Coordinates2D constructor
*
* @param coords The coordinate values.
*
* @pre coords.size() == Coordinates2D::dimensionality().
*/
explicit Coordinates2D(const std::vector<double>& coords);
/**
* Coordinates2D constructor
*
* @param coords The coordinate values.
*/
explicit Coordinates2D(const std::pair<double, double>& coords);
/**
* Coordinates2D constructor
*
* @param x The x coordinate value.
* @param y The y coordinate value.
*/
Coordinates2D(double x, double y) : _x(x), _y(y) {}
/**
* Get the x coordinate.
*
* @return double The x coordinate value.
*/
double getX() const {
return _x;
}
/**
* Get the y coordinate.
*
* @return double The y coordinate value.
*/
double getY() const {
return _y;
}
/**
* Get the x and y coordinates.
*
* @return std::vector<double> A vector [x, y] of this object's
* coordinate values.
*/
virtual std::vector<double> getValues() const;
/**
* Get the x and y coordinates as a std::pair.
*
* @return std::pair<double, double> A std::pair (x, y) of this
* object's coordinate values.
*/
std::pair<double, double> getValuesAsPair() const;
/**
* Get a BSON representation of the coordinates.
*
* @return BSONObj A BSONObj of the coordinates, structured as:
* { "coordinates" : [ x, y ] }
*/
virtual BSONObj toBSON() const;
/**
* Get the value of this coordinate at the given dimension.
*
* @param dimension 0 -> x, 1 -> y, any other input
* besides 0 or 1 is an error.
*
* @return The coordinate value at the given dimension.
*
* @pre 0 <= dimension < Coordinates2D::dimensionality()
*/
virtual double operator[](size_t dimension) const;
/**
* Get the dimensionality of this coordinate type.
*
* @return 2, the number of dimensions in Coordinates2D.
*/
static size_t MONGO_CLIENT_FUNC dimensionality() {
return 2;
}
private:
double _x;
double _y;
};
} // namespace geo
} // namespace mongo
|