Skip to content
Snippets Groups Projects
Commit 37968d67 authored by Knuiman, Bart's avatar Knuiman, Bart
Browse files

Added function to obtain WaterIslands from vector tile.

parent 7206a23e
Branches
No related tags found
No related merge requests found
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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment