You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.
Adding an additional PreparedGeometry.Contains check to return the whole tile as geometry should improve the performance a lot:
/// <summary>/// Returns all the tiles this polygon is part of and the polygonal portion in it../// </summary>/// <param name="polygon">The linestring.</param>/// <param name="zoom">The zoom.</param>/// <param name="margin">The margin for the tiles polygon (in %)</param>/// <returns>An enumerable of all tiles.</returns>publicstaticIEnumerable<(ulong,IPolygonal)>Tiles(Polygonpolygon,intzoom,intmargin=5){// Get the envelopevarenvelope=polygon.EnvelopeInternal;varlt=Tile.CreateAroundLocation(envelope.MaxY,envelope.MinX,zoom);if(lt==null)thrownewException();varrb=Tile.CreateAroundLocation(envelope.MinY,envelope.MaxX,zoom);if(rb==null)thrownewException();// Compute the possible tile rangevartileRange=newTileRange(lt.X,lt.Y,rb.X,rb.Y,zoom);// Build a prepared geometry to perform faster intersection predicatevarprep=Geometries.Prepared.PreparedGeometryFactory.Prepare(polygon);// Test polygon tiles.foreach(vartileintileRange){if(tile==null)continue;vartestPolygon=tile.ToPolygon(margin);if(prep.Contains(testPolygon)){// the whole tile polygon is inside the geometryyieldreturn(tile.Id,testPolygon);}elseif(prep.Intersects(testPolygon)){// Compute the intersection geometryvarresult=polygon.Intersection(testPolygon);// Only return if result is polygonalif(resultisIPolygonalpolygonalResult)yieldreturn(tile.Id,polygonalResult);}}}
Splitting large polygons can take hours while there is a lot of room for improvement.
We should change the PolygonTiler to take advantage of these properties.
The text was updated successfully, but these errors were encountered: