-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
qgspostgisbox3d.cpp
84 lines (61 loc) · 2.41 KB
/
qgspostgisbox3d.cpp
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
/***************************************************************************
qgspostgisbox3d.cpp - PostgreSQL/PostGIS "box3d" representation and
transformation
-------------------
begin : Feb 1, 2005
copyright : (C) 2005 by Brendan Morley
email : morb at ozemail dot com dot au
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
/* $Id$ */
#include <fstream>
#include <cstdlib>
#include <QString>
#include "qgsrect.h"
#include "qgspostgisbox3d.h"
QgsPostGisBox3d::QgsPostGisBox3d( std::string box3d )
{
// If given a nil box3d, give back a nominal QgsPostGisBox3d
if ("" == box3d)
{
xmin = xmax = ymin = ymax = 0;
return;
}
std::string s;
box3d = box3d.substr(box3d.find_first_of("(")+1);
box3d = box3d.substr(box3d.find_first_not_of(" "));
s = box3d.substr(0, box3d.find_first_of(" "));
xmin = strtod(s.c_str(), NULL);
box3d = box3d.substr(box3d.find_first_of(" ")+1);
s = box3d.substr(0, box3d.find_first_of(" "));
ymin = strtod(s.c_str(), NULL);
box3d = box3d.substr(box3d.find_first_of(",")+1);
box3d = box3d.substr(box3d.find_first_not_of(" "));
s = box3d.substr(0, box3d.find_first_of(" "));
xmax = strtod(s.c_str(), NULL);
box3d = box3d.substr(box3d.find_first_of(" ")+1);
s = box3d.substr(0, box3d.find_first_of(" "));
ymax = strtod(s.c_str(), NULL);
}
QgsPostGisBox3d::~QgsPostGisBox3d()
{
// NO-OP
}
QString QgsPostGisBox3d::stringRepAsBox3d()
{
QString s;
s = QString( "BOX3D(%f %f,%f %f)" )
.arg( xmin )
.arg( ymin )
.arg( xmax )
.arg( ymax );
std::cerr << "QgsPostGisBox3d: stringRepAsBox3d is returning '" << s.toLocal8Bit().data() << "'" << std::endl;
return s;
}