Beispiel #1
0
 public void QueryEnvelope(RectangularTileIndex forTile,
                           [NotNull] IEnvelope envelope)
 {
     RectangularTilingUtils.QueryTileEnvelope(OriginX, OriginY,
                                              TileWidth, TileHeight,
                                              forTile, envelope);
 }
Beispiel #2
0
        public IEnumerable <RectangularTileIndex> GetIntersectingTiles(
            double xMin, double yMin, double xMax, double yMax)
        {
            RectangularTileIndex minIndex = GetTileIndexAt(xMin, yMin);

            RectangularTileIndex maxIndex = GetTileIndexAt(xMax, yMax);

            return(GetAllTilesBetween(minIndex, maxIndex));
        }
Beispiel #3
0
        public IEnvelope GetIntersectedTilesExtent([NotNull] IEnvelope extent,
                                                   [NotNull] IEnvelope constraintExtent)
        {
            Assert.ArgumentNotNull(extent, nameof(extent));
            Assert.False(extent.IsEmpty, "extent is empty");
            Assert.ArgumentNotNull(constraintExtent, nameof(constraintExtent));
            Assert.False(constraintExtent.IsEmpty, "constraintExtent is empty");

            IEnvelope projectedExtent;

            GeometryUtils.EnsureSpatialReference(extent, SpatialReference, true,
                                                 out projectedExtent);
            IEnvelope projectedConstraintExtent;

            GeometryUtils.EnsureSpatialReference(constraintExtent, SpatialReference,
                                                 true,
                                                 out projectedConstraintExtent);

            int?leftIndex;
            int?rightIndex;

            RectangularTilingUtils.GetTileIndexes1D(OriginX, TileWidth,
                                                    projectedExtent.XMin, projectedExtent.XMax,
                                                    projectedConstraintExtent.XMin,
                                                    projectedConstraintExtent.XMax,
                                                    out leftIndex, out rightIndex);

            int?bottomIndex;
            int?topIndex;

            RectangularTilingUtils.GetTileIndexes1D(OriginY, TileHeight,
                                                    projectedExtent.YMin, projectedExtent.YMax,
                                                    projectedConstraintExtent.YMin,
                                                    projectedConstraintExtent.YMax,
                                                    out bottomIndex, out topIndex);

            IEnvelope result;

            if (leftIndex == null || rightIndex == null || bottomIndex == null ||
                topIndex == null)
            {
                result = new EnvelopeClass();
                result.SpatialReference = SpatialReference;
            }
            else
            {
                var tileLL =
                    new RectangularTileIndex(leftIndex.Value, bottomIndex.Value);
                var tileUR =
                    new RectangularTileIndex(rightIndex.Value, topIndex.Value);

                result = GetTileEnvelope(SpatialReference, tileLL, tileUR);
            }

            return(result);
        }
Beispiel #4
0
 public static void GetTileBounds(RectangularTileIndex index,
                                  double originX,
                                  double originY,
                                  double tileWidth, double tileHeight,
                                  out double xMin, out double yMin,
                                  out double xMax, out double yMax)
 {
     xMin = originX + (index.East * tileWidth);
     yMin = originY + (index.North * tileHeight);
     xMax = xMin + tileWidth;
     yMax = yMin + tileHeight;
 }
Beispiel #5
0
 private static IEnumerable <RectangularTileIndex> GetAllTilesBetween(
     RectangularTileIndex minIndex,
     RectangularTileIndex maxIndex)
 {
     for (int i = minIndex.East; i <= maxIndex.East; i++)
     {
         for (int j = minIndex.North; j <= maxIndex.North; j++)
         {
             yield return(new RectangularTileIndex(i, j));
         }
     }
 }
Beispiel #6
0
        public static void QueryTileEnvelope(double originX, double originY,
                                             double tileWidth, double tileHeight,
                                             RectangularTileIndex tileIndex,
                                             [NotNull] IEnvelope envelope)
        {
            double xMin;
            double yMin;
            double xMax;
            double yMax;

            GetTileBounds(tileIndex, originX, originY, tileWidth, tileHeight,
                          out xMin, out yMin, out xMax, out yMax);

            envelope.SetEmpty();
            envelope.SpatialReference = null;

            envelope.PutCoords(xMin, yMin, xMax, yMax);
        }