Skip to content

Commit

Permalink
remove stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
mootw committed Dec 3, 2024
1 parent d726a5e commit 54127a9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
1 change: 1 addition & 0 deletions lib/src/layer/tile_layer/tile_layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,7 @@ class _TileLayerState extends State<TileLayer> with TickerProviderStateMixin {
}
}

// TODO replace with simple implementation of (Offset - Offset).distanceSq
double _distanceSq(TileCoordinates coord, Point<double> center) {
final dx = center.x - coord.x;
final dy = center.y - coord.y;
Expand Down
12 changes: 9 additions & 3 deletions lib/src/layer/tile_layer/tile_range.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ class EmptyTileRange extends TileRange {
const Iterable<TileCoordinates>.empty();
}

Point<int> _floor(Point<double> point) =>
Point<int>(point.x.floor(), point.y.floor());

Point<int> _ceil(Point<double> point) =>
Point<int>(point.x.ceil(), point.y.ceil());

/// Every [TileRange] is a [DiscreteTileRange] if it's not an [EmptyTileRange].
@immutable
class DiscreteTileRange extends TileRange {
Expand All @@ -46,12 +52,12 @@ class DiscreteTileRange extends TileRange {
}) {
final Bounds<int> bounds;
if (pixelBounds.min == pixelBounds.max) {
final minAndMax = (pixelBounds.min / tileDimension).floor();
final minAndMax = _floor(pixelBounds.min / tileDimension);
bounds = Bounds<int>(minAndMax, minAndMax);
} else {
bounds = Bounds<int>(
(pixelBounds.min / tileDimension).floor(),
(pixelBounds.max / tileDimension).ceil() - const Point(1, 1),
_floor(pixelBounds.min / tileDimension),
_ceil(pixelBounds.max / tileDimension) - const Point(1, 1),
);
}

Expand Down
17 changes: 1 addition & 16 deletions lib/src/misc/extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,18 @@ import 'dart:ui';
/// Extension methods for the math.[Point] class
extension PointExtension<T extends num> on Point<T> {
/// Create a new [Point] where the [x] and [y] values are divided by [factor].
@Deprecated('Replace with Offset')
/// REPLACE IN FAVOR OF OFFSET
Point<double> operator /(num factor) {
return Point<double>(x / factor, y / factor);
}

/// Create a new [Point] where the [x] and [y] values are rounded up to the
/// nearest integer.
@Deprecated('Replace with Offset')
Point<int> ceil() {
return Point<int>(x.ceil(), y.ceil());
}

/// Create a new [Point] where the [x] and [y] values are rounded down to the
/// nearest integer.
@Deprecated('Replace with Offset')
Point<int> floor() {
return Point<int>(x.floor(), y.floor());
}

/// Converts to offset
Offset toOffset() => Offset(x.toDouble(), y.toDouble());
}

/// Extension methods for [Offset]
extension OffsetToPointExtension on Offset {
/// Creates a [Point] representation of this offset. This is ONLY used for backwards compatibility
@Deprecated('Only used for backwards compatibility')
Point<double> toPoint() => Point(dx, dy);

/// Create a new [Offset] whose [dx] and [dy] values are rotated clockwise by
Expand Down

0 comments on commit 54127a9

Please sign in to comment.