Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
geotiff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
WANDER
geotiff
Commits
69a4fb61
Commit
69a4fb61
authored
2 years ago
by
Knuiman, Bart
Browse files
Options
Downloads
Patches
Plain Diff
Fixes for getting tiff from url.
parent
4dee5431
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Runtime/GeoTiffHeight.cs
+30
-16
30 additions, 16 deletions
Runtime/GeoTiffHeight.cs
with
30 additions
and
16 deletions
Runtime/GeoTiffHeight.cs
+
30
−
16
View file @
69a4fb61
...
...
@@ -5,6 +5,7 @@ using System.IO;
using
System.Threading.Tasks
;
using
UnityEngine
;
using
UnityEngine.Networking
;
using
UnityEngine.Windows
;
namespace
Wander
{
...
...
@@ -67,7 +68,7 @@ namespace Wander
public
bool
IsFinished
()
{
if
(
finished
)
if
(
finished
||
asyncOp
==
null
)
return
true
;
// Still in progress
...
...
@@ -137,7 +138,9 @@ namespace Wander
public
static
string
BuildPDOKWCSUrl
(
float
rdMinX
,
float
rdMaxX
,
float
rdMinY
,
float
rdMaxY
,
int
resWidth
=
1024
,
int
resHeight
=
1024
)
{
string
url
=
$"https://service.pdok.nl/rws/ahn3/wcs/v1_0?SERVICE=WCS&VERSION=1.0.0&REQUEST=GetCoverage&coverage=ahn3_05m_dtm&CRS=EPSG:28992&BBOX=
{
rdMinX
}
,
{
rdMinX
}
,
{
rdMaxX
}
,
{
rdMaxY
}
&WIDTH=
{
resWidth
}
&HEIGHT=
{
resHeight
}
&FORMAT=image/tiff&interpolation=average"
;
//&interpolation=average
string
url
=
$"https://service.pdok.nl/rws/ahn3/wcs/v1_0?SERVICE=WCS&VERSION=1.0.0&REQUEST=GetCoverage&coverage=ahn3_05m_dtm&CRS=EPSG:28992&BBOX=
{
rdMinX
}
,
{
rdMinY
}
,
{
rdMaxX
}
,
{
rdMaxY
}
&WIDTH=
{
resWidth
}
&HEIGHT=
{
resHeight
}
&FORMAT=image/tiff&interpolation=average"
;
//string url = $"https://service.pdok.nl/rws/ahn3/wcs/v1_0?SERVICE=WCS&VERSION=1.0.0&REQUEST=GetCoverage&coverage=ahn3_05m_dtm&CRS=EPSG:28992&BBOX={rdMinX},{rdMinY},{rdMaxX},{rdMaxY}&WIDTH={resWidth}&HEIGHT={resHeight}&FORMAT=GeoTIFF_FLOAT32";
return
url
;
}
...
...
@@ -205,16 +208,6 @@ namespace Wander
throw
new
InvalidDataException
(
"Tiff data not valid"
);
}
width
=
tiff
.
GetField
(
TiffTag
.
IMAGEWIDTH
)[
0
].
ToInt
();
height
=
tiff
.
GetField
(
TiffTag
.
IMAGELENGTH
)[
0
].
ToInt
();
int
tileSize
=
tiff
.
TileSize
();
var
tile_width_field
=
tiff
.
GetField
(
TiffTag
.
TILEWIDTH
);
var
tile_length_field
=
tiff
.
GetField
(
TiffTag
.
TILELENGTH
);
int
tile_width
=
tileSize
;
// tile_width_field[0].ToInt();
int
tile_height
=
tileSize
;
// tile_length_field[0].ToInt();
byte
[]
tileData
=
new
byte
[
tileSize
];
// Obtain coords
{
FieldValue
[]
modelPixelScaleTag
=
tiff
.
GetField
((
TiffTag
)
33550
);
...
...
@@ -229,11 +222,19 @@ namespace Wander
originY
=
BitConverter
.
ToDouble
(
modelTransformation
,
32
);
}
// output
output
=
new
float
[
width
*
height
];
for
(
int
row
=
0
;
row
<
height
;
row
+=
tile_height
)
width
=
tiff
.
GetField
(
TiffTag
.
IMAGEWIDTH
)[
0
].
ToInt
();
height
=
tiff
.
GetField
(
TiffTag
.
IMAGELENGTH
)[
0
].
ToInt
();
output
=
new
float
[
width
*
height
];
int
tileSize
=
tiff
.
TileSize
();
if
(
tiff
.
IsTiled
())
{
for
(
int
col
=
0
;
col
<
width
;
col
+=
tile_width
)
byte
[]
tileData
=
new
byte
[
tileSize
];
int
tile_width
=
tiff
.
GetField
(
TiffTag
.
TILEWIDTH
)[
0
].
ToInt
();
int
tile_height
=
tiff
.
GetField
(
TiffTag
.
TILELENGTH
)[
0
].
ToInt
();
for
(
int
row
=
0
;
row
<
height
;
row
+=
tile_height
)
for
(
int
col
=
0
;
col
<
width
;
col
+=
tile_width
)
{
// Read the tile into an RGBA array
int
res
=
tiff
.
ReadTile
(
tileData
,
0
,
col
,
row
,
0
,
0
);
...
...
@@ -257,6 +258,19 @@ namespace Wander
}
}
}
else
{
int
samplesPerPixel
=
tiff
.
GetField
(
TiffTag
.
SAMPLESPERPIXEL
)[
0
].
ToInt
();
int
bitsPerSample
=
tiff
.
GetField
(
TiffTag
.
BITSPERSAMPLE
)[
0
].
ToInt
();
Debug
.
Assert
(
samplesPerPixel
==
1
&&
bitsPerSample
==
32
,
"Expecting 32-bit floating point texture. Others are not handled."
);
int
scanlineSize
=
tiff
.
ScanlineSize
();
byte
[]
scanline
=
new
byte
[
scanlineSize
];
for
(
int
i
=
0
;
i
<
height
;++
i
)
{
tiff
.
ReadScanline
(
scanline
,
i
);
Buffer
.
BlockCopy
(
scanline
,
0
,
output
,
i
*
width
*
4
,
scanlineSize
);
}
}
}
return
output
;
...
...
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