Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vectortile
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
vectortile
Commits
37968d67
Commit
37968d67
authored
1 year ago
by
Knuiman, Bart
Browse files
Options
Downloads
Patches
Plain Diff
Added function to obtain WaterIslands from vector tile.
parent
7206a23e
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/VectorTile.cs
+38
-1
38 additions, 1 deletion
Runtime/VectorTile.cs
with
38 additions
and
1 deletion
Runtime/VectorTile.cs
+
38
−
1
View file @
37968d67
using
GluonGui.WorkspaceWindow.Views.WorkspaceExplorer.Configuration
;
using
Mapbox.Vector.Tile
;
using
System
;
using
System.Collections.Generic
;
...
...
@@ -193,6 +192,13 @@ namespace Wander
return
numFailedPolys
;
}
bool
IsPolygonLayerWater
(
int
layerIdx
,
int
featureIdx
,
int
waterLayerIdx
)
{
var
layer
=
layers
[
layerIdx
];
var
feature
=
layer
.
VectorTileFeatures
[
featureIdx
];
return
feature
.
SelectedLayerIdx
==
waterLayerIdx
;
}
bool
DoesPolygonLayerQualify
(
int
layerIdx
,
int
featureIdx
)
{
var
layer
=
layers
[
layerIdx
];
...
...
@@ -351,6 +357,37 @@ namespace Wander
layersIdentified
=
true
;
}
public
List
<
List
<
TriangulatedPolygon
>>
GetWaterPolygons
(
int
waterLayerIdx
,
ref
bool
cancelToken
)
{
UnityEngine
.
Debug
.
Assert
(
triangulated
,
"First call Triangulate."
);
UnityEngine
.
Debug
.
Assert
(
layersIdentified
,
"Identify layers first."
);
Stopwatch
sw
=
new
Stopwatch
();
sw
.
Restart
();
var
waters
=
new
List
<
List
<
TriangulatedPolygon
>>();
for
(
int
l
=
0
;
l
<
polygonLayers
.
Count
;
l
++)
{
var
layer
=
layers
[
l
];
var
water
=
new
List
<
TriangulatedPolygon
>();
for
(
int
f
=
0
;
f
<
layer
.
VectorTileFeatures
.
Count
&&
!
cancelToken
;
f
++)
{
if
(
DoesPolygonLayerQualify
(
l
,
f
)
&&
IsPolygonLayerWater
(
l
,
f
,
waterLayerIdx
))
{
var
poly
=
polygonLayers
[
l
][
f
];
water
.
Add
(
poly
);
}
}
if
(
water
.
Count
>
0
)
{
waters
.
Add
(
water
);
}
}
return
waters
;
}
// Generates a raster for each position (pixel). 2 pixels are pushed in 1 (each 16 bit).
// If no polygon was hit, 15 is encoded (reserved).
// If polygon was hit, but no feature was matched, also 15 is encoded.
...
...
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