1 /******************************************************************************
2 * Copyright (c) 2019, Hobu Inc. (info@hobu.co)
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following
8 * conditions are met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided
15 * with the distribution.
16 * * Neither the name of Hobu, Inc. names of its contributors may be
17 * used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
31 * OF SUCH DAMAGE.
32 ****************************************************************************/
33
34 #include <limits>
35
36 #include <pdal/SrsBounds.hpp>
37
38 namespace
39 {
40
41 const double LOWEST = (std::numeric_limits<double>::lowest)();
42 const double HIGHEST = (std::numeric_limits<double>::max)();
43
44 }
45
46 namespace pdal
47 {
48
SrsBounds(const BOX3D & box)49 SrsBounds::SrsBounds(const BOX3D& box) : Bounds(box)
50 {}
51
52
SrsBounds(const BOX3D & box,const SpatialReference & srs)53 SrsBounds::SrsBounds(const BOX3D& box, const SpatialReference& srs) :
54 Bounds(box), m_srs(srs)
55 {}
56
57
SrsBounds(const BOX2D & box)58 SrsBounds::SrsBounds(const BOX2D& box) : Bounds(box)
59 {}
60
61
SrsBounds(const BOX2D & box,const SpatialReference & srs)62 SrsBounds::SrsBounds(const BOX2D& box, const SpatialReference& srs) :
63 Bounds(box), m_srs(srs)
64 {}
65
66
parse(const std::string & s,std::string::size_type & pos)67 void SrsBounds::parse(const std::string& s, std::string::size_type& pos)
68 {
69 Bounds::parse(s, pos);
70 pos += Utils::extractSpaces(s, pos);
71 if (pos == s.size())
72 return;
73
74 if (s[pos++] != '/')
75 throw Bounds::error("Invalid character following valid bounds box.");
76
77 pos += Utils::extractSpaces(s, pos);
78 SpatialReference srs;
79 m_srs.parse(s, pos);
80 pos += Utils::extractSpaces(s, pos);
81 }
82
operator <<(std::ostream & out,const SrsBounds & srsBounds)83 std::ostream& operator << (std::ostream& out, const SrsBounds& srsBounds)
84 {
85 out << static_cast<const Bounds&>(srsBounds);
86 out << " / " << srsBounds.m_srs;
87 return out;
88 }
89
90 } // namespace pdal
91