Skip to content

Commit

Permalink
add descriptions and move simplify to be internal
Browse files Browse the repository at this point in the history
  • Loading branch information
mootw committed Nov 21, 2023
1 parent 080846f commit aa2e37e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 4 additions & 2 deletions lib/src/layer/polygon_layer/polygon_layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:math';
import 'dart:ui' as ui;

import 'package:flutter/widgets.dart';
import 'package:flutter_map/simplify.dart';
import 'package:flutter_map/src/misc/simplify.dart';
import 'package:flutter_map/src/geo/latlng_bounds.dart';
import 'package:flutter_map/src/layer/general/mobile_layer_transformer.dart';
import 'package:flutter_map/src/layer/polygon_layer/label.dart';
Expand Down Expand Up @@ -113,7 +113,9 @@ class PolygonLayer extends StatelessWidget {
/// how much to simplify the polygons, in decimal degrees scaled to floored zoom
final double? simplificationTolerance;

/// use high quality simplification
/// high quality simplification uses the https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm
/// otherwise, points within the radial distance of the threshold value are merged. (Also called radial distance simplification)
/// radial distance is faster, but does not preserve the shape of the original line as well as Douglas Peucker
final bool simplificationHighQuality;

// Turn on/off per-polygon label drawing on the layer-level.
Expand Down
6 changes: 4 additions & 2 deletions lib/src/layer/polyline_layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'dart:ui' as ui;

import 'package:flutter/widgets.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_map/simplify.dart';
import 'package:flutter_map/src/misc/simplify.dart';
import 'package:latlong2/latlong.dart';

class Polyline {
Expand Down Expand Up @@ -59,7 +59,9 @@ class PolylineLayer extends StatelessWidget {
/// how much to simplify the polygons, in decimal degrees scaled to floored zoom
final double? simplificationTolerance;

/// use high quality simplification
/// high quality simplification uses the https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm
/// otherwise, points within the radial distance of the threshold value are merged. (Also called radial distance simplification)
/// radial distance is faster, but does not preserve the shape of the original line as well as Douglas Peucker
final bool simplificationHighQuality;

const PolylineLayer({
Expand Down
3 changes: 1 addition & 2 deletions lib/simplify.dart → lib/src/misc/simplify.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// implementation based on
// https://github.com/mourner/simplify-js/blob/master/simplify.js

library simplify;

import 'package:latlong2/latlong.dart';

double _getSqDist(
Expand Down Expand Up @@ -42,6 +40,7 @@ double _getSqSegDist(
return dx * dx + dy * dy;
}


List<LatLng> simplifyRadialDist(
List<LatLng> points,
double sqTolerance,
Expand Down

0 comments on commit aa2e37e

Please sign in to comment.