Skip to content

Commit

Permalink
修复图标 buffer 未绘制的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
zlzforever committed May 22, 2024
1 parent 2e43fe8 commit 38f5bc5
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 42 deletions.
10 changes: 6 additions & 4 deletions src/ZMap.Renderer.SkiaSharp/SymbolRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ public override void Render(SKCanvas graphics, Geometry geometry, Envelope exten
var interiorPoint = geometry.InteriorPoint;
var centroid = new Coordinate(interiorPoint.X, interiorPoint.Y);

if (!extent.Contains(centroid))
{
return;
}
// comment by lewis at 20240522
// 不能过滤, 有一些越界的矢量也必须绘制
// if (!extent.Contains(centroid))
// {
// return;
// }

var half = (style.Size.Value ?? 14) / 2;

Expand Down
110 changes: 72 additions & 38 deletions src/ZMap.TileGrid/GridSetFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,77 @@ public static GridSet CreateGridSet(
return gridSet;
}

// public static GridSet CreateGridSet(
// string name,
// int srs,
// Envelope extent,
// bool alignTopLeft,
// int levels,
// double? metersPerUnit,
// double pixelSize,
// int tileWidth,
// int tileHeight,
// bool yCoordinateFirst)
// {
// var extentWidth = extent.Width;
// var extentHeight = extent.Height;
//
// var resX = extentWidth / tileWidth;
// var resY = extentHeight / tileHeight;
//
// int tilesWide, tilesHigh;
//
// if (resX <= resY)
// {
// // use one tile wide by N tiles high
// tilesWide = 1;
// tilesHigh = (int)Math.Round(resY / resX);
// // previous resY was assuming 1 tile high, recompute with the actual number of tiles
// // high
// resY /= tilesHigh;
// }
// else
// {
// // use one tile high by N tiles wide
// tilesHigh = 1;
// tilesWide = (int)Math.Round(resX / resY);
// // previous resX was assuming 1 tile wide, recompute with the actual number of tiles
// // wide
// resX /= tilesWide;
// }
//
// // the maximum of resX and resY is the one that adjusts better
// var res = Math.Max(resX, resY);
//
// var adjustedExtentWidth = tilesWide * tileWidth * res;
// var adjustedExtentHeight = tilesHigh * tileHeight * res;
//
// var adjExtent = new Envelope(extent.MinX, extent.MinX + adjustedExtentWidth,
// extent.MaxY - adjustedExtentHeight, extent.MinY + adjustedExtentHeight);
//
// var resolutions = new double[levels];
// resolutions[0] = res;
//
// for (var i = 1; i < levels; i++)
// {
// resolutions[i] = resolutions[i - 1] / 2;
// }
//
// return CreateGridSet(
// name,
// srs,
// adjExtent,
// alignTopLeft,
// resolutions,
// null,
// metersPerUnit,
// pixelSize,
// null,
// tileWidth,
// tileHeight,
// yCoordinateFirst);
// }

public static GridSet CreateGridSet(
string name,
int srs,
Expand All @@ -179,50 +250,13 @@ public static GridSet CreateGridSet(
int tileHeight,
bool yCoordinateFirst)
{
// var extentWidth = extent.Width;
// var extentHeight = extent.Height;
//
// var resX = extentWidth / tileWidth;
// var resY = extentHeight / tileHeight;

// int tilesWide, tilesHigh;
//
// if (resX <= resY)
// {
// // use one tile wide by N tiles high
// tilesWide = 1;
// tilesHigh = (int)Math.Round(resY / resX);
// // previous resY was assuming 1 tile high, recompute with the actual number of tiles
// // high
// resY /= tilesHigh;
// }
// else
// {
// // use one tile high by N tiles wide
// tilesHigh = 1;
// tilesWide = (int)Math.Round(resX / resY);
// // previous resX was assuming 1 tile wide, recompute with the actual number of tiles
// // wide
// resX /= tilesWide;
// }
//
// // the maximum of resX and resY is the one that adjusts better
// var res = Math.Max(resX, resY);
//
// var adjustedExtentWidth = tilesWide * tileWidth * res;
// var adjustedExtentHeight = tilesHigh * tileHeight * res;
//
// var adjExtent = new Envelope(extent.MinX, extent.MinX + adjustedExtentWidth,
// extent.MaxY - adjustedExtentHeight, extent.MinY + adjustedExtentHeight);

var resolutions = new double[levels];
// resolutions[0] = res;
var size = extent.Width / tileWidth;
for (var i = 0; i < levels; i++)
{
resolutions[i] = size / Math.Pow(2, i);
}

return CreateGridSet(
name,
srs,
Expand Down

0 comments on commit 38f5bc5

Please sign in to comment.