Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs-feliks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Feliks Kiszkurno
ogs-feliks
Commits
ff26db73
Commit
ff26db73
authored
12 years ago
by
Tom Fischer
Browse files
Options
Downloads
Patches
Plain Diff
Using logog logging in class SHPInterface and refomatting source code.
parent
c491984c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
FileIO/SHPInterface.cpp
+62
-62
62 additions, 62 deletions
FileIO/SHPInterface.cpp
FileIO/SHPInterface.h
+13
-3
13 additions, 3 deletions
FileIO/SHPInterface.h
with
75 additions
and
65 deletions
FileIO/SHPInterface.cpp
+
62
−
62
View file @
ff26db73
/**
* \file SHPInterface.cpp
* 25/01/2010 KR Initial implementation
* @copyright
* Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
* @file SHPInterface.cpp
* @date 25/01/2010
* @author Karsten Rink
*/
// ThirdParty/logog
#include
"logog/include/logog.hpp"
#include
"SHPInterface.h"
// BaseLib
#include
"StringTools.h"
// MathLib
...
...
@@ -11,15 +23,15 @@
bool
SHPInterface
::
readSHPInfo
(
const
std
::
string
&
filename
,
int
&
shapeType
,
int
&
numberOfEntities
)
{
SHPHandle
hSHP
=
SHPOpen
(
filename
.
c_str
(),
"rb"
);
if
(
!
hSHP
)
SHPHandle
hSHP
=
SHPOpen
(
filename
.
c_str
(),
"rb"
);
if
(
!
hSHP
)
return
false
;
double
padfMinBound
[
4
],
padfMaxBound
[
4
];
// The SHPGetInfo() function retrieves various information about shapefile as a whole.
// The bounds are read from the file header, and may be inaccurate if the file was improperly generated.
SHPGetInfo
(
hSHP
,
&
numberOfEntities
,
&
shapeType
,
padfMinBound
,
padfMaxBound
);
SHPGetInfo
(
hSHP
,
&
numberOfEntities
,
&
shapeType
,
padfMinBound
,
padfMaxBound
);
SHPClose
(
hSHP
);
return
true
;
...
...
@@ -30,35 +42,33 @@ void SHPInterface::readSHPFile(const std::string &filename, OGSType choice, std:
int
shapeType
,
numberOfElements
;
double
padfMinBound
[
4
],
padfMaxBound
[
4
];
SHPHandle
hSHP
=
SHPOpen
(
filename
.
c_str
(),
"rb"
);
SHPGetInfo
(
hSHP
,
&
numberOfElements
,
&
shapeType
,
padfMinBound
,
padfMaxBound
);
SHPHandle
hSHP
=
SHPOpen
(
filename
.
c_str
(),
"rb"
);
SHPGetInfo
(
hSHP
,
&
numberOfElements
,
&
shapeType
,
padfMinBound
,
padfMaxBound
);
if
(
((
shapeType
-
1
)
%
10
==
0
)
&&
(
choice
==
SHPInterface
::
POINT
)
)
if
(((
shapeType
-
1
)
%
10
==
0
)
&&
(
choice
==
SHPInterface
::
POINT
))
readPoints
(
hSHP
,
numberOfElements
,
listName
);
if
(
((
shapeType
-
1
)
%
10
==
0
)
&&
(
choice
==
SHPInterface
::
STATION
)
)
if
(((
shapeType
-
1
)
%
10
==
0
)
&&
(
choice
==
SHPInterface
::
STATION
))
readStations
(
hSHP
,
numberOfElements
,
listName
);
if
(
((
shapeType
-
3
)
%
10
==
0
||
(
shapeType
-
5
)
%
10
==
0
)
&&
(
choice
==
SHPInterface
::
POLYLINE
)
)
if
(((
shapeType
-
3
)
%
10
==
0
||
(
shapeType
-
5
)
%
10
==
0
)
&&
(
choice
==
SHPInterface
::
POLYLINE
))
readPolylines
(
hSHP
,
numberOfElements
,
listName
);
if
(
((
shapeType
-
3
)
%
10
==
0
||
(
shapeType
-
5
)
%
10
==
0
)
&&
(
choice
==
SHPInterface
::
POLYGON
)
)
if
(((
shapeType
-
3
)
%
10
==
0
||
(
shapeType
-
5
)
%
10
==
0
)
&&
(
choice
==
SHPInterface
::
POLYGON
))
readPolygons
(
hSHP
,
numberOfElements
,
listName
);
}
void
SHPInterface
::
readPoints
(
const
SHPHandle
&
hSHP
,
int
numberOfElements
,
std
::
string
listName
)
{
if
(
numberOfElements
>
0
)
{
if
(
numberOfElements
>
0
)
{
std
::
vector
<
GeoLib
::
Point
*>*
points
=
new
std
::
vector
<
GeoLib
::
Point
*>
();
SHPObject
*
hSHPObject
;
for
(
int
i
=
0
;
i
<
numberOfElements
;
i
++
)
{
hSHPObject
=
SHPReadObject
(
hSHP
,
i
);
for
(
int
i
=
0
;
i
<
numberOfElements
;
i
++
)
{
hSHPObject
=
SHPReadObject
(
hSHP
,
i
);
GeoLib
::
Point
*
pnt
=
new
GeoLib
::
Point
(
*
(
hSHPObject
->
padfX
),
*
(
hSHPObject
->
padfY
),
*
(
hSHPObject
->
padfZ
)
);
new
GeoLib
::
Point
(
*
(
hSHPObject
->
padfX
),
*
(
hSHPObject
->
padfY
),
*
(
hSHPObject
->
padfZ
));
points
->
push_back
(
pnt
);
}
...
...
@@ -69,19 +79,17 @@ void SHPInterface::readPoints(const SHPHandle &hSHP, int numberOfElements, std::
void
SHPInterface
::
readStations
(
const
SHPHandle
&
hSHP
,
int
numberOfElements
,
std
::
string
listName
)
{
if
(
numberOfElements
>
0
)
{
std
::
vector
<
GeoLib
::
Point
*>*
stations
(
new
std
::
vector
<
GeoLib
::
Point
*>
);
stations
->
reserve
(
numberOfElements
);
if
(
numberOfElements
>
0
)
{
std
::
vector
<
GeoLib
::
Point
*>*
stations
(
new
std
::
vector
<
GeoLib
::
Point
*>
);
stations
->
reserve
(
numberOfElements
);
SHPObject
*
hSHPObject
;
for
(
int
i
=
0
;
i
<
numberOfElements
;
i
++
)
{
hSHPObject
=
SHPReadObject
(
hSHP
,
i
);
GeoLib
::
Station
*
stn
=
GeoLib
::
Station
::
createStation
(
BaseLib
::
number2str
(
i
),
*
(
hSHPObject
->
padfX
),
*
(
hSHPObject
->
padfY
),
*
(
hSHPObject
->
padfZ
)
);
for
(
int
i
=
0
;
i
<
numberOfElements
;
i
++
)
{
hSHPObject
=
SHPReadObject
(
hSHP
,
i
);
GeoLib
::
Station
*
stn
=
GeoLib
::
Station
::
createStation
(
BaseLib
::
number2str
(
i
),
*
(
hSHPObject
->
padfX
),
*
(
hSHPObject
->
padfY
),
*
(
hSHPObject
->
padfZ
));
stations
->
push_back
(
stn
);
}
...
...
@@ -92,33 +100,28 @@ void SHPInterface::readStations(const SHPHandle &hSHP, int numberOfElements, std
void
SHPInterface
::
readPolylines
(
const
SHPHandle
&
hSHP
,
int
numberOfElements
,
std
::
string
listName
)
{
size_t
noOfPoints
=
0
,
noOfParts
=
0
;
std
::
size_t
noOfPoints
=
0
,
noOfParts
=
0
;
std
::
vector
<
GeoLib
::
Point
*>*
points
=
new
std
::
vector
<
GeoLib
::
Point
*>
();
std
::
vector
<
GeoLib
::
Polyline
*>*
lines
=
new
std
::
vector
<
GeoLib
::
Polyline
*>
();
SHPObject
*
hSHPObject
;
// for each polyline)
for
(
int
i
=
0
;
i
<
numberOfElements
;
i
++
)
{
hSHPObject
=
SHPReadObject
(
hSHP
,
i
);
for
(
int
i
=
0
;
i
<
numberOfElements
;
i
++
)
{
hSHPObject
=
SHPReadObject
(
hSHP
,
i
);
noOfPoints
=
hSHPObject
->
nVertices
;
noOfParts
=
hSHPObject
->
nParts
;
noOfParts
=
hSHPObject
->
nParts
;
for
(
size_t
p
=
0
;
p
<
noOfParts
;
p
++
)
{
for
(
std
::
size_t
p
=
0
;
p
<
noOfParts
;
p
++
)
{
int
firstPnt
=
*
(
hSHPObject
->
panPartStart
+
p
);
int
lastPnt
=
(
p
<
(
noOfParts
-
1
))
?
*
(
hSHPObject
->
panPartStart
+
p
+
1
)
:
noOfPoints
;
int
lastPnt
=
(
p
<
(
noOfParts
-
1
))
?
*
(
hSHPObject
->
panPartStart
+
p
+
1
)
:
noOfPoints
;
GeoLib
::
Polyline
*
line
=
new
GeoLib
::
Polyline
(
*
points
);
// for each point in that polyline
for
(
int
j
=
firstPnt
;
j
<
lastPnt
;
j
++
)
{
GeoLib
::
Point
*
pnt
=
new
GeoLib
::
Point
(
*
(
hSHPObject
->
padfX
+
j
),
*
(
hSHPObject
->
padfY
+
j
),
*
(
hSHPObject
->
padfZ
+
j
)
);
for
(
int
j
=
firstPnt
;
j
<
lastPnt
;
j
++
)
{
GeoLib
::
Point
*
pnt
=
new
GeoLib
::
Point
(
*
(
hSHPObject
->
padfX
+
j
),
*
(
hSHPObject
->
padfY
+
j
),
*
(
hSHPObject
->
padfZ
+
j
));
points
->
push_back
(
pnt
);
line
->
addPoint
(
points
->
size
()
-
1
);
}
...
...
@@ -128,8 +131,7 @@ void SHPInterface::readPolylines(const SHPHandle &hSHP, int numberOfElements, st
}
}
if
(
numberOfElements
>
0
)
{
if
(
numberOfElements
>
0
)
{
// add points vector to GEOObjects (and check for duplicate points)
_geoObjects
->
addPointVec
(
points
,
listName
);
...
...
@@ -145,14 +147,13 @@ void SHPInterface::readPolygons(const SHPHandle &hSHP, int numberOfElements, std
{
this
->
readPolylines
(
hSHP
,
numberOfElements
,
listName
);
const
std
::
vector
<
GeoLib
::
Polyline
*>*
polylines
(
_geoObjects
->
getPolylineVec
(
listName
));
const
std
::
vector
<
GeoLib
::
Polyline
*>*
polylines
(
_geoObjects
->
getPolylineVec
(
listName
));
std
::
vector
<
GeoLib
::
Surface
*>*
sfc_vec
(
new
std
::
vector
<
GeoLib
::
Surface
*>
);
for
(
std
::
vector
<
GeoLib
::
Polyline
*>::
const_iterator
poly_it
(
polylines
->
begin
());
poly_it
!=
polylines
->
end
();
poly_it
++
)
{
std
::
cout
<<
"triangulation of Polygon with "
<<
(
*
poly_it
)
->
getNumberOfPoints
()
<<
" points ... "
<<
std
::
flush
;
for
(
std
::
vector
<
GeoLib
::
Polyline
*>::
const_iterator
poly_it
(
polylines
->
begin
());
poly_it
!=
polylines
->
end
();
poly_it
++
)
{
INFO
(
"SHPInterface::readPolygons(): Triangulation of Polygon with %d points."
,
(
*
poly_it
)
->
getNumberOfPoints
());
sfc_vec
->
push_back
(
GeoLib
::
Surface
::
createSurface
(
*
(
*
poly_it
)));
}
...
...
@@ -160,17 +161,16 @@ void SHPInterface::readPolygons(const SHPHandle &hSHP, int numberOfElements, std
_geoObjects
->
addSurfaceVec
(
sfc_vec
,
listName
);
}
void
SHPInterface
::
adjustPolylines
(
std
::
vector
<
GeoLib
::
Polyline
*>*
lines
,
std
::
vector
<
size_t
>
id_map
)
void
SHPInterface
::
adjustPolylines
(
std
::
vector
<
GeoLib
::
Polyline
*>*
lines
,
std
::
vector
<
std
::
size_t
>
id_map
)
{
for
(
size_t
i
=
0
;
i
<
lines
->
size
();
i
++
)
{
GeoLib
::
Polyline
*
line
(
(
*
lines
)[
i
]
);
size_t
previous_pnt_id
(
std
::
numeric_limits
<
size_t
>::
max
());
for
(
std
::
size_t
i
=
0
;
i
<
lines
->
size
();
i
++
)
{
GeoLib
::
Polyline
*
line
((
*
lines
)[
i
]);
std
::
size_t
previous_pnt_id
(
std
::
numeric_limits
<
std
::
size_t
>::
max
());
for
(
size_t
j
=
0
;
j
<
line
->
getNumberOfPoints
();
j
++
)
{
size_t
jth_pnt_id
(
id_map
[
line
->
getPointID
(
j
)]);
for
(
std
::
size_t
j
=
0
;
j
<
line
->
getNumberOfPoints
();
j
++
)
{
std
::
size_t
jth_pnt_id
(
id_map
[
line
->
getPointID
(
j
)]);
if
(
previous_pnt_id
==
jth_pnt_id
)
{
line
->
removePoint
(
j
);
j
--
;
...
...
This diff is collapsed.
Click to expand it.
FileIO/SHPInterface.h
+
13
−
3
View file @
ff26db73
/**
* \file SHPInterface.cpp
* 25/01/2010 KR Initial implementation
* @copyright
* Copyright (c) 2013, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
* @file SHPInterface.h
* @date 25/01/2010
* @author Karsten Rink
*/
#ifndef SHPINTERFACE_H
#define SHPINTERFACE_H
...
...
@@ -10,6 +18,7 @@
//ShapeLib includes
#include
"shapefil.h"
// GeoLib
#include
"GEOObjects.h"
/**
...
...
@@ -50,7 +59,8 @@ private:
/// Reads lines into a vector of Polyline and Surface objects.
void
readPolygons
(
const
SHPHandle
&
hSHP
,
int
numberOfElements
,
std
::
string
listName
);
void
adjustPolylines
(
std
::
vector
<
GeoLib
::
Polyline
*>*
lines
,
std
::
vector
<
std
::
size_t
>
id_map
);
void
adjustPolylines
(
std
::
vector
<
GeoLib
::
Polyline
*>*
lines
,
std
::
vector
<
std
::
size_t
>
id_map
);
GeoLib
::
GEOObjects
*
_geoObjects
;
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment