Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
caddies
caddies-api
Commits
1d33c019
Commit
1d33c019
authored
Apr 28, 2020
by
mjg226
Browse files
bug fix asciigrid
added simple upscaling to CellBuff
parent
a3e53b6a
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1132 additions
and
17 deletions
+1132
-17
impls/square-cell/vn-neighbours/1-levels/simple/CellBuff.hpp
impls/square-cell/vn-neighbours/1-levels/simple/CellBuff.hpp
+65
-14
impls/square-cell/vn-neighbours/1-levels/simple/ESRI_ASCIIGrid.hpp
...are-cell/vn-neighbours/1-levels/simple/ESRI_ASCIIGrid.hpp
+1067
-3
No files found.
impls/square-cell/vn-neighbours/1-levels/simple/CellBuff.hpp
View file @
1d33c019
...
...
@@ -375,23 +375,74 @@ namespace CA {
// Check that the given memory location is big enough to contain
// the data of the region.
if
(
box
.
w
()
>
mem_x_size
||
box
.
h
()
>
mem_y_size
)
if
(
box
.
w
()
<
mem_x_size
||
box
.
h
()
<
mem_y_size
)
return
;
// Cycle through the region of cells to read. i_reg and j_reg are
// the region indices. i_mem and j_mem are the memory indices. The
// _border value is used to avoid reading the border.
for
(
Unsigned
j_reg
=
box
.
y
()
+
_cagrid
.
cb_border
,
j_mem
=
0
;
j_reg
<
box
.
h
()
+
box
.
y
()
+
_cagrid
.
cb_border
;
++
j_reg
,
++
j_mem
)
if
(
box
.
w
()
>
mem_x_size
||
box
.
h
()
>
mem_y_size
)
{
for
(
Unsigned
i_reg
=
box
.
x
()
+
_cagrid
.
cb_border
,
i_mem
=
0
;
i_reg
<
box
.
w
()
+
box
.
x
()
+
_cagrid
.
cb_border
;
++
i_reg
,
++
i_mem
)
{
_buff
[
j_reg
*
_cagrid
.
cb_x_size
+
i_reg
]
=
mem
[
j_mem
*
mem_x_size
+
i_mem
];
}
}
}
// upsample, assuming it is a clean upsampling
int
x_scale
=
box
.
w
()
/
mem_x_size
;
int
y_scale
=
box
.
h
()
/
mem_y_size
;
double
x_scale_check
=
box
.
w
()
/
mem_x_size
;
double
y_scale_check
=
box
.
h
()
/
mem_y_size
;
if
(
x_scale
!=
x_scale_check
)
return
;
if
(
y_scale
!=
y_scale_check
)
return
;
//std::cout << "x_scale: " << x_scale << std::endl;
//std::cout << "y_scale: " << y_scale << std::endl;
// Cycle through the region of cells to read. i_reg and j_reg are
// the region indices. i_mem and j_mem are the memory indices. The
// _border value is used to avoid reading the border.
// i_box and j_box, are the region indicies within the box locally
for
(
Unsigned
j_reg
=
box
.
y
()
+
_cagrid
.
cb_border
,
j_mem
=
0
,
j_box
=
0
;
j_reg
<
box
.
h
()
+
box
.
y
()
+
_cagrid
.
cb_border
;
++
j_reg
,
++
j_box
)
{
if
(
j_box
%
y_scale
==
0
&&
j_box
!=
0
)
++
j_mem
;
for
(
Unsigned
i_reg
=
box
.
x
()
+
_cagrid
.
cb_border
,
i_mem
=
0
,
i_box
=
0
;
i_reg
<
box
.
w
()
+
box
.
x
()
+
_cagrid
.
cb_border
;
++
i_reg
,
++
i_box
)
{
if
(
i_box
%
x_scale
==
0
&&
i_box
!=
0
)
++
i_mem
;
_buff
[
j_reg
*
_cagrid
.
cb_x_size
+
i_reg
]
=
mem
[
j_mem
*
mem_x_size
+
i_mem
];
}
}
}
else
{
// Cycle through the region of cells to read. i_reg and j_reg are
// the region indices. i_mem and j_mem are the memory indices. The
// _border value is used to avoid reading the border.
for
(
Unsigned
j_reg
=
box
.
y
()
+
_cagrid
.
cb_border
,
j_mem
=
0
;
j_reg
<
box
.
h
()
+
box
.
y
()
+
_cagrid
.
cb_border
;
++
j_reg
,
++
j_mem
)
{
for
(
Unsigned
i_reg
=
box
.
x
()
+
_cagrid
.
cb_border
,
i_mem
=
0
;
i_reg
<
box
.
w
()
+
box
.
x
()
+
_cagrid
.
cb_border
;
++
i_reg
,
++
i_mem
)
{
_buff
[
j_reg
*
_cagrid
.
cb_x_size
+
i_reg
]
=
mem
[
j_mem
*
mem_x_size
+
i_mem
];
}
}
}
}
// end of insertData
template
<
typename
T
>
...
...
impls/square-cell/vn-neighbours/1-levels/simple/ESRI_ASCIIGrid.hpp
View file @
1d33c019
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment