Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
Özgür Ozan Sen
ogs
Commits
8f737db3
Commit
8f737db3
authored
8 months ago
by
Karsten Rink
Committed by
Dmitri Naumov
7 months ago
Browse files
Options
Downloads
Patches
Plain Diff
generalised interface for xyz raster files
parent
0f84d3c6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
GeoLib/IO/AsciiRasterInterface.cpp
+30
-54
30 additions, 54 deletions
GeoLib/IO/AsciiRasterInterface.cpp
with
30 additions
and
54 deletions
GeoLib/IO/AsciiRasterInterface.cpp
+
30
−
54
View file @
8f737db3
...
@@ -272,67 +272,43 @@ GeoLib::Raster* AsciiRasterInterface::getRasterFromXyzFile(
...
@@ -272,67 +272,43 @@ GeoLib::Raster* AsciiRasterInterface::getRasterFromXyzFile(
{
{
return
nullptr
;
return
nullptr
;
}
}
double
x_min
=
(
*
coords
)[
0
];
double
x_max
=
(
*
coords
)[
0
];
double
y_min
=
(
*
coords
)[
1
];
double
y_max
=
(
*
coords
)[
1
];
double
cellsize
=
std
::
numeric_limits
<
double
>::
max
();
std
::
vector
<
double
>
values
;
while
((
coords
=
readCoordinates
(
in
)))
values
.
push_back
((
*
coords
)[
2
]);
auto
coords2
=
readCoordinates
(
in
);
if
(
coords2
==
std
::
nullopt
)
{
{
return
nullptr
;
double
const
diff
=
(
*
coords
)[
0
]
-
x_min
;
if
(
diff
>
0
)
cellsize
=
std
::
min
(
cellsize
,
diff
);
x_min
=
std
::
min
((
*
coords
)[
0
],
x_min
);
x_max
=
std
::
max
((
*
coords
)[
0
],
x_max
);
y_min
=
std
::
min
((
*
coords
)[
1
],
y_min
);
y_max
=
std
::
max
((
*
coords
)[
1
],
y_max
);
}
}
values
.
push_back
((
*
coords2
)[
2
]);
in
.
close
();
GeoLib
::
RasterHeader
header
{
0
,
0
,
1
,
GeoLib
::
Point
(
*
coords
),
(
*
coords2
)[
0
]
-
(
*
coords
)[
0
],
-
9999
};
GeoLib
::
RasterHeader
header
;
header
.
cell_size
=
cellsize
;
header
.
no_data
=
-
9999
;
header
.
n_cols
=
static_cast
<
std
::
size_t
>
(((
x_max
-
x_min
)
/
cellsize
)
+
1
);
header
.
n_rows
=
static_cast
<
std
::
size_t
>
(((
y_max
-
y_min
)
/
cellsize
)
+
1
);
header
.
n_depth
=
1
;
header
.
origin
[
0
]
=
x_min
;
header
.
origin
[
1
]
=
y_min
;
std
::
size_t
n_cols
=
2
,
n_rows
=
1
;
std
::
vector
<
double
>
values
(
header
.
n_cols
*
header
.
n_rows
,
-
9999
);
in
.
open
(
fname
);
while
((
coords
=
readCoordinates
(
in
)))
while
((
coords
=
readCoordinates
(
in
)))
{
{
values
.
push_back
((
*
coords
)[
2
]);
std
::
size_t
idx
=
static_cast
<
std
::
size_t
>
(
if
((
*
coords
)[
0
]
>
(
*
coords2
)[
0
])
(
header
.
n_cols
*
(((
*
coords
)[
1
]
-
y_min
)
/
cellsize
))
+
{
(((
*
coords
)[
0
]
-
x_min
)
/
cellsize
));
if
((
*
coords
)[
0
]
-
(
*
coords2
)[
0
]
!=
header
.
cell_size
)
values
[
idx
]
=
(
*
coords
)[
2
];
{
ERR
(
"Varying cell sizes or unordered pixel values found. "
"Aborting..."
);
return
nullptr
;
}
n_cols
++
;
}
else
// new line
{
if
((
*
coords
)[
1
]
-
(
*
coords2
)[
1
]
!=
header
.
cell_size
)
{
ERR
(
"Varying cell sizes or unordered pixel values found. "
"Aborting..."
);
return
nullptr
;
}
n_rows
++
;
// define #columns
if
(
header
.
n_cols
==
0
)
{
header
.
n_cols
=
n_cols
;
}
// just check if #columns is consistent
else
{
if
(
n_cols
!=
header
.
n_cols
)
{
ERR
(
"Different number of pixels per line. Aborting!"
);
return
nullptr
;
}
}
n_cols
=
1
;
}
coords2
=
coords
;
}
header
.
n_rows
=
n_rows
;
if
(
header
.
n_cols
==
0
)
{
ERR
(
"Could not determine raster size. Note that minimum allowed raster "
"size is 2 x 2 pixels."
);
return
nullptr
;
}
}
in
.
close
();
return
new
GeoLib
::
Raster
(
header
,
values
.
begin
(),
values
.
end
());
return
new
GeoLib
::
Raster
(
header
,
values
.
begin
(),
values
.
end
());
}
}
...
...
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