turf library
A turf.js-like geospatial analysis library for Dart.
This is the umbrella library that re-exports every turf module so consumers
can import 'package:turf/turf.dart'; and access the full API surface.
Classes
- BBox
-
Please make sure, you arrange your parameters like this:
Longitude 1, Latitude 1, Altitude 1 (optional), Longitude 2, Latitude 2, Altitude 2 (optional)
You can either specify 4 or 6 parameters
If you are using the default constructor with two dimensional positions (lng + lat only), please use the constructor like this:
BBox(lng1, lat1, lng2, lat2); - CoordinateType
- Coordinate types, following https://tools.ietf.org/html/rfc7946#section-4
-
Feature<
T extends GeometryObject> - Feature, as specified here https://tools.ietf.org/html/rfc7946#section-3.2
-
FeatureCollection<
T extends GeometryObject> - FeatureCollection, as specified here https://tools.ietf.org/html/rfc7946#section-3.3
- GeoJSONObject
- GeometryCollection
- GeometryCollection, as specified here https://tools.ietf.org/html/rfc7946#section-3.1.8
- GeometryObject
-
GeometryType<
T> - LineString
- LineString, as specified here https://tools.ietf.org/html/rfc7946#section-3.1.4
- MultiLineString
- MultiLineString, as specified here https://tools.ietf.org/html/rfc7946#section-3.1.5
- MultiPoint
- MultiPoint, as specified here https://tools.ietf.org/html/rfc7946#section-3.1.3
- MultiPolygon
- MultiPolygon, as specified here https://tools.ietf.org/html/rfc7946#section-3.1.7
- Point
- Point, as specified here https://tools.ietf.org/html/rfc7946#section-3.1.2
- Polygon
- Polygon, as specified here https://tools.ietf.org/html/rfc7946#section-3.1.6
- Polyline
- Based off of the offical Google document Some parts from this implementation by Mark McClure
- Position
- Please make sure, you arrange your parameters like this:
Enums
- BoundaryType
- CoordinateSystem
- Coordinate reference systems for spatial data
- Corner
- DistanceGeometry
- Whether to calculate the distance based on geodesic (spheroid) or planar (flat) method.
- GeoJSONObjectType
- Grid
- Unit
Extensions
-
FeatureCollectionMetaExtension
on FeatureCollection<
GeometryObject> -
FeatureCollectionOtherMembersExtension
on FeatureCollection<
GeometryObject> - Extension to add "other members" support specifically to FeatureCollection
-
FeatureOtherMembersExtension
on Feature<
GeometryObject> - Extension to add "other members" support specifically to Feature
- GeoJSONObjectMetaExtension on GeoJSONObject
- GeoJSONObjectOtherMembersExtension on GeoJSONObject
- Extension to add "other members" support to GeoJSONObject This follows RFC 7946 specification: "A GeoJSON object MAY have 'other members'. Implementations MUST NOT interpret foreign members as having any meaning unless part of an extension or profile."
- GeometryObjectOtherMembersExtension on GeometryObject
- Extension to add "other members" support specifically to GeometryObject
Constants
-
areaFactors
→ const Map<
Unit, num> - Area of measurement factors based on 1 square meter.
- conversionEarthRadius → const double
- Earth radius in meters used for coordinate system conversions
-
coordSystemConstants
→ const Map<
String, double> - Coordinate system conversion constants
- earthRadius → const double
- Earth Radius used with the Harvesine formula and approximates using a spherical (non-ellipsoid) Earth.
-
factors
→ const Map<
Unit, num> - Unit of measurement factors using a spherical (non-ellipsoid) earth radius. Keys are the name of the unit, values are the number of that unit in a single radian
- mercatorLimit → const double
- Maximum extent of the Web Mercator projection in meters
-
unitsFactors
→ const Map<
Unit, num>
Functions
-
along(
Feature< LineString> line, num distance, [Unit unit = Unit.kilometers]) → Feature<Point> -
Takes a
lineand returns a Point at a specifieddistancealong the line. -
applyFilter(
Map? properties, dynamic filter) → bool -
applyFilter
Takes a Map
propertiesand afilter, Returns a bool indicating filter is applied to the properties. -
area(
GeoJSONObject geojson) → num? - Takes a GeoJSONObject and returns their area in square meters.
-
bbox(
GeoJSONObject geoJson, {bool recompute = false}) → BBox -
Calculates the bounding box for any
geoJsonobject, including FeatureCollection. Ifrecomputeis not set and the bbox is not null, the function uses the bbox of the given GeoJSONObject. -
bboxPolygon(
BBox bbox, {Map< String, dynamic> properties = const {}, dynamic id}) → Feature<Polygon> - Takes a BBox and returns an equivalent Feature<Polygon>.
-
bearing(
Point start, Point end, {bool calcFinal = false}) → num - Takes two Points and finds the geographic bearing between them, i.e. the angle measured in degrees from the north line (0 degrees) For example:
-
bearingRaw(
Position start, Position end, {bool calcFinal = false}) → num -
bearingToAzimuth(
num bearing) → num - Converts any bearing angle from the north line direction (positive clockwise) and returns an angle between 0-360 degrees (positive clockwise), 0 being the north line
-
bitCode(
Position p, BBox bbox) → int -
booleanClockwise(
LineString line) → bool -
Takes a ring and return
trueorfalsewhether or not the ring is clockwise or counter-clockwise. Takes a Feature<LineString> orLineString or a List<Position> to be evaluated. example: -
booleanConcave(
Polygon polygon) → bool -
Takes a Polygon and returns
trueorfalseas to whether it is concave or not. example: -
booleanContains(
GeoJSONObject feature1, GeoJSONObject feature2) → bool -
booleanContains returns
trueif the second geometry is completely contained by the first geometry. The interiors of both geometries must intersect and, the interior and boundary of the secondary must not intersect the exterior of the primary. booleanContains returns the exact opposite result of the booleanWithin. example: -
booleanCrosses(
GeoJSONObject feature1, GeoJSONObject feature2) → bool -
booleanCrosses returns
trueif the intersection results in a geometry whose dimension is one less than the maximum dimension of the two source geometries and the intersection set is interior to both source geometries. booleanCrosses returnstruefor only MultiPoint/Polygon, MultiPoint/LineString, LineString/LineString, LineString/Polygon, and LineString/MultiPolygon comparisons. Other comparisons are not supported as they are outside the OpenGIS Simple Features spec and may give unexpected results. example: -
booleanDisjoint(
GeoJSONObject feature1, GeoJSONObject feature2, {bool ignoreSelfIntersections = false}) → bool -
Returns
trueif the intersection of the two geometries is an empty set. example: -
booleanEqual(
GeoJSONObject feature1, GeoJSONObject feature2, {int precision = 6, bool direction = false, bool shiftedPolygon = false}) → bool -
Determine whether two geometries of the same type have identical X,Y coordinate values.
See http://edndoc.esri.com/arcsde/9.0/general_topics/understand_spatial_relations.htm
precision=6 sets decimal precision to use when comparing coordinates. Withdirectionset totrue, even if the LineStrings are reverse versions of each other but they have similar Positions, they will be considered the same. IfshiftedPolygonistrue, two Polygons with shifted Positions are considered the same. Returnstrueif the objects are equal,falseotherwise example: -
booleanIntersects(
GeoJSONObject feature1, GeoJSONObject feature2, {bool ignoreSelfIntersections = true}) → bool -
Returns
truewhen two geometries intersect. Takesfeature1&feature2parameters of type GeoJSONObject which can be a Feature or GeometryType. example -
booleanOverlap(
Feature< GeometryObject> firstFeature, Feature<GeometryObject> secondFeature) → bool -
Takes two geometries
firstFeatureandsecondFeatureand checks if they share an common area but are not completely contained by each other. -
booleanParallel(
LineString line1, LineString line2) → bool -
Returns
trueif each segment ofline1is parallel to the correspondent segment ofline2example: -
booleanPointInPolygon(
Position point, GeoJSONObject polygon, {bool ignoreBoundary = false}) → bool -
Takes a Point, and a Polygon or MultiPolygonand determines if the
Point resides within the Polygon. The Polygon can be convex or concave.
The function accounts for holes. By taking a Feature<Polygon> or a
Feature<MultiPolygon>. The
ignoreBoundaryflag (defaultfalse) should be set totrueif the Polygon's boundary should be ignored when determining if the Point is inside the Polygon, otherwisefalse. example: -
booleanPointOnLine(
Point pt, LineString line, {bool ignoreEndVertices = false, num? epsilon}) → bool -
Returns
trueif a point is on a line. Accepts an optional parameter to ignore the start and end vertices of the LineString. TheignoreEndVerticesflag (defaultfalse) controls whether to ignore the start and end vertices.epsilonis the fractional number to compare with the cross product result. It's useful for dealing with floating points in lng/lat. -
booleanTouches(
GeoJSONObject feature1, GeoJSONObject feature2) → bool -
Boolean-touches returns
trueif none of the Points common to both geometries intersect the interiors of both geometries. example -
booleanValid(
GeoJSONObject feature) → bool - booleanValid checks if the geometry is a valid according to the OGC Simple Feature Specification. Take a Feature or a GeometryType example
-
booleanWithin(
GeoJSONObject feature1, GeoJSONObject feature2) → bool -
Returns
trueif the first GeoJSONObject is completely within the second GeoJSONObject. The interiors of both geometries must intersect and, the interior and boundary of the primary (geometry a) must not intersect the exterior of the secondary (geometry b). booleanWithin returns the exact opposite result of booleanContains. -
calculateFinalBearing(
Point start, Point end) → num - Calculates Final Bearing
-
calculateFinalBearingRaw(
Position start, Position end) → num -
calculateRhumbBearing(
Position from, Position to) → num - Returns the bearing from ‘this’ Point to destination Point along a rhumb line. Adapted from Geodesy: https://github.com/chrisveness/geodesy/blob/master/latlon-spherical.js Returns Bearing in degrees from north. example
-
calculateRhumbDestination(
Position origin, num distance, num bearing, [num radius = earthRadius]) → Position -
calculateRhumbDistance(
Position origin, Position destination, [num radius = earthRadius]) → num - Returns the distance traveling from ‘this’ point to destination point along a rhumb line. Adapted from Geodesy ‘distanceTo‘: https://github.com/chrisveness/geodesy/blob/master/latlon-spherical.js
-
center(
GeoJSONObject geoJSON, {dynamic id, BBox? bbox, Map< String, dynamic> ? properties}) → Feature<Point> - Takes a Feature or a FeatureCollection and returns the absolute center point of all feature(s).
-
centerOfMass(
GeoJSONObject geoJson, {Map< String, dynamic> ? properties = const {}}) → Feature<Point> - Computes the center of mass of any GeoJSON object and returns it as a Feature<Point>.
-
centroid(
GeoJSONObject geoJSON, {Map< String, dynamic> ? properties}) → Feature<Point> - Takes a Feature or a FeatureCollection and computes the centroid as the mean of all vertices within the object.
-
circle(
GeoJSONObject center, num radius, {num? steps, Unit? unit, Map< String, dynamic> ? properties}) → Feature<Polygon> - Takes a Point or a Feature<Point> and calculates the circle polygon given a radius in degrees, radians, miles, or kilometers; and steps for precision.
-
cleanCoords(
GeoJSONObject geojson, {bool mutate = false}) → Feature< GeometryObject> -
Removes redundant coordinates from any GeometryType.
Takes a Feature or GeometryType
mutateallows GeoJSON input to be mutated Returns the cleaned input Feature example: -
clusterEach(
FeatureCollection< GeometryObject> geojson, dynamic property, ClusterEachCallback callback) → void -
clusterEach
Takes a FeatureCollection, a dynamic
propertykey/value used to create clusters, and a ClusterEachCallback method that takes (cluster, clusterValue, currentIndex) and Returns void. For example: -
clusterReduce<
T> (FeatureCollection< GeometryObject> geojson, dynamic property, ClusterReduceCallback<T> callback, dynamic initialValue) → T? -
Reduces clusters in Features, similar to Iterable.reduce
Takes a FeatureCollection
geojson, a dynamicproperty, a GeoJSONObject's property key/value used to create clusters, a ClusterReduceCallback method, and aninitialValueto use as the first argument to the first call of the callback. Returns the value that results from the reduction. For example: -
combine(
FeatureCollection< GeometryObject> collection) → FeatureCollection<GeometryObject> - Combines a FeatureCollection of Point, LineString, or Polygon features (and their Multi* counterparts) into MultiPoint, MultiLineString, or MultiPolygon features.
-
convertArea(
num area, [dynamic originalUnit = Unit.meters, dynamic finalUnit = Unit.kilometers]) → num - Converts a area to the requested unit. Valid units: Unit.kilometers, Unit.meters, Unit.centimeters, Unit.millimeters, Unit.acres, Unit.miles, Unit.yards, Unit.feet, Unit.inches
-
convertCoordinates(
Position coord, CoordinateSystem fromSystem, CoordinateSystem toSystem) → Position - Converts coordinates from one system to another.
-
convertLength(
num length, [Unit originalUnit = Unit.kilometers, Unit finalUnit = Unit.kilometers]) → num - Converts a length to the requested unit. Valid units: Unit.miles, Unit.nauticalmiles, Unit.inches, Unit.yards, Unit.meters, Unit.kilometers, Unit.centimeters, Unit.feet
-
coordAll(
GeoJSONObject geojson) → List< Position?> - Gets all coordinates from any GeoJSONObject. Receives any GeoJSONObject Returns List<Position> For example:
-
coordEach(
GeoJSONObject geoJSON, Function callback, [bool excludeWrapCoord = false]) → void -
Iterates over coordinates in any
geoJSONObject, similar to Iterable.forEach example: -
coordReduce<
T> (GeoJSONObject geojson, CoordReduceCallback< T> callback, T? initialValue, [bool excludeWrapCoord = false]) → T? - Reduces coordinates in any GeoJSONObject, similar to Iterable.reduce
-
createBins(
FeatureCollection< GeometryObject> geojson, dynamic property) → Map<dynamic, List< int> > -
createBins
Takes a FeatureCollection geojson, and dynamic
propertykey whose corresponding values of the Features will be used to create bins. Returns Map<String, List -
degreesToRadians(
num degrees) → num - Converts an angle in degrees to radians
-
destination(
Point origin, num distance, num bearing, [Unit unit = Unit.kilometers]) → Point - Takes a Point and calculates the location of a destination point given a distance in degrees, radians, miles, or kilometers; and bearing in degrees. This uses the Haversine formula to account for global curvature. For example:
-
destinationRaw(
Position origin, num distance, num bearing, [Unit unit = Unit.kilometers]) → Position -
distance(
Point from, Point to, [Unit unit = Unit.kilometers]) → num - Calculates the distance between two Points in degrees, radians, miles, or kilometers. This uses the Haversine formula to account for global curvature. For example:
-
distanceRaw(
Position from, Position to, [Unit unit = Unit.kilometers]) → num -
envelope(
GeoJSONObject geojson) → Feature< Polygon> - Returns a rectangular Polygon (envelope) that fully contains the given GeoJSON object.
-
explode(
GeoJSONObject geojson) → FeatureCollection< Point> - Takes a feature or set of features and returns all positions as Points. Takes GeoJSONObject input. Returns FeatureCollection<point> representing the exploded input features Throws Exception if it encounters an unknown geometry type
-
extractOtherMembers(
Map< String, dynamic> json, List<String> standardKeys) → Map<String, dynamic> - Utility to extract "other members" from GeoJSON objects according to RFC 7946 specification.
-
featureEach(
GeoJSONObject geoJSON, FeatureEachCallback callback) → void -
Iterates over features in any
geoJSONObject, callingcallbackon each iteration. Similar to Iterable.forEach. For example: -
featureReduce<
T> (GeoJSONObject geojson, FeatureReduceCallback< T> callback, T? initialValue) → T? - Reduces features in any GeoJSONObject, similar to Iterable.reduce.
-
filterProperties(
Map< String, dynamic> properties, List<String> ? keys) → Map<String, dynamic> -
filterProperties
Takes Map<String, dynamic>
properties, and List<String>keysused to filter Properties. Returns Map<String, dynamic> filtered Properties For example: -
flatten(
GeoJSONObject geojson) → FeatureCollection< GeometryObject> - Takes any GeoJSONObject and returns a FeatureCollection of simple features. The function flattens all Multi* geometries into single-geometry Features.
-
flattenEach(
GeoJSONObject geoJSON, FlattenEachCallback callback) → void -
Iterates over flattened features in any
geoJSONObject, similar to Iterable.forEach, callingcallbackon each flattened feature -
flattenReduce<
T> (GeoJSONObject geojson, FlattenReduceCallback< T> callback, T? initialValue) → T? -
Reduces flattened features in any GeoJSONObject, similar to Iterable.reduce.
Takes a FeatureCollection, Feature, or GeometryType
a FlattenReduceCallback method that takes (previousValue, currentFeature, featureIndex, multiFeatureIndex),
an
initialValueValue to use as the first argument to the first call of the callback. Returns the value that results from the reduction. For example: -
flip(
Feature< GeometryType> ? geojson) → Feature<GeometryType> - Flip the coordinates of a Feature, with proper typing for each geometry
-
flipPosition(
Position pos) → Position - Swap lat/lng of a Position
-
geomEach(
GeoJSONObject geoJSON, GeomEachCallback callback) → void -
Iterates over each geometry in
geoJSON, callingcallbackon each iteration. Similar to Iterable.forEach -
geomReduce<
T> (GeoJSONObject geoJSON, GeomReduceCallback< T> callback, T? initialValue) → T? - Reduces geometry in any GeoJSONObject, similar to Iterable.reduce.
-
geoToMercator(
GeoJSONObject geojson, {bool mutate = false}) → GeoJSONObject - Converts a WGS84 GeoJSON object into Web Mercator (EPSG:3857 / 900913) projection.
-
geoToWgs84(
GeoJSONObject geojson, {bool mutate = false}) → GeoJSONObject - Converts a Web Mercator (EPSG:3857 / 900913) GeoJSON object back into WGS84 projection.
-
getCluster(
FeatureCollection< GeometryObject> geojson, dynamic filter) → FeatureCollection<GeometryObject> -
Get Cluster
Takes a FeatureCollection<Feature> and a
dynamicfilterused on GeoJSON properties to get Cluster. Returns a FeatureCollection single cluster filtered by GeoJSON Properties For example: -
getCoord(
dynamic coord) → Position - Unwraps a coordinate from a Point, Feature<Point>, and a Position.
-
getCoords(
dynamic coords) → List - Unwraps coordinates from a Feature, GeometryObject or a List Gets a List<dynamic>, GeometryObject or a Feature or a List<dynamic> and returns List<dynamic>. For example:
-
getGeom(
GeoJSONObject geojson) → GeometryObject - Get Geometry or Geometries from Feature or GeometryCollection Returns List<GeometryType> in case geojson is a GeometryCollection and a GeometryType if geojson is a simple GeometryType. example:
-
greatCircle(
Position start, Position end, {Map< String, dynamic> properties = const {}, int npoints = 100, int offset = 10}) → Feature<GeometryType> - Calculates the great circle route between two points on a sphere
-
intersect(
Position a, Position b, int edge, BBox bbox) → Position -
isAbove(
Position p1, Position p2, Position p3) → bool -
Returns true if
p3is above the line fromp1top2. -
isBelow(
Position p1, Position p2, Position p3) → bool -
Returns true if
p3is below the line fromp1top2. -
isLeft(
Position p1, Position p2, Position p3) → num -
Returns a positive value if
p3is to the left of the line fromp1top2, negative if to the right, and 0 if collinear. -
isPointOnLineEnd(
Point point, LineString line) → bool -
isPointOnLineSegmentCleanCoordsVariant(
Position start, Position end, Position point) → bool -
Returns if
pointis on the segment betweenstartandend. Borrowed frombooleanPointOnLineto speed up the evaluation (instead of using the module as dependency).startis the coord pair of start of line,endis the coord pair of end of line, andpointis the coord pair of point to check. -
isPointOnLineSegmentCrossesVariant(
Position start, Position end, Position pt, bool incEnd) → bool -
Only takes into account outer rings
See http://stackoverflow.com/a/4833823/1979085
lineSegmentStart Position of start of line
lineSegmentEnd Position of end of line
pt Position of point to check
incEndcontrols whether the Point is allowed to fall on the line ends -
length(
Feature< LineString> line, [Unit unit = Unit.kilometers]) → num -
Takes a
lineand measures its length in the specifiedunit. -
lengthToDegrees(
num distance, [Unit unit = Unit.kilometers]) → num - Convert a distance measurement (assuming a spherical Earth) from a real-world unit into degrees Valid units: Unit.miles, Unit.nauticalmiles, Unit.inches, Unit.yards, Unit.meters, Unit.centimeters, Unit.kilometers, Unit.feet
-
lengthToRadians(
num distance, [Unit unit = Unit.kilometers]) → num - Convert a distance measurement (assuming a spherical Earth) from a real-world unit into radians Valid units: Unit.miles, Unit.nauticalmiles, Unit.inches, Unit.yards, Unit.meters, Unit.kilometers, Unit.centimeters, Unit.feet
-
lineclip(
List< Position> points, BBox bbox, [List<List< ? result]) → List<Position> >List< Position> > -
lineIntersect(
GeoJSONObject line1, GeoJSONObject line2, {bool removeDuplicates = true, bool ignoreSelfIntersections = false}) → FeatureCollection< Point> -
Takes any LineString or Polygon and returns the intersecting Point.
removeDuplicates(defaulttrue) removes duplicate intersections,ignoreSelfIntersections(defaultfalse) ignores self-intersections on input features Returns a FeatureCollection<Point> containing point(s) that intersect both example: -
lineOverlap(
Feature< GeometryObject> feature1, Feature<GeometryObject> feature2, {num tolerance = 0, Unit unit = Unit.kilometers}) → FeatureCollection<LineString> -
Takes any LineString, MultiLineString, Polygon or MultiPolygon and
returns the overlapping lines between both features.
feature1first featurefeature2second featuretolerancetolerance distance to match overlapping line segments, default is 0unitthe unit in which the tolerance is expressed, default is kilometers returns FeatureCollection<LineString> lines(s) that are overlapping between both features -
lineSegment(
GeoJSONObject geoJson, {bool combineGeometries = false}) → FeatureCollection< LineString> - Creates a FeatureCollection of 2-vertex LineString segments from a LineString or MultiLineString or Polygon and MultiPolygon Returns FeatureCollection<LineString> 2-vertex line segments For example:
-
lineSlice(
Feature< Point> startPt, Feature<Point> stopPt, Feature<LineString> line) → Feature<LineString> -
Takes a
line, at a start pointstartPt, and a stop pointstopPtand returns a subsection of the line in-between those points. The start & stop points don't need to fall exactly on the line. -
lineSliceAlong(
Feature< LineString> line, double startDist, double stopDist, [Unit unit = Unit.kilometers]) → Feature<LineString> -
Takes a
line, at a start distancestartDistand a stop distancestopDistand returns a subsection of the line in-between those distances. -
lineSliceAlongRaw(
LineString line, double startDist, double stopDist, [Unit unit = Unit.kilometers]) → LineString -
Takes a
line, at a start distancestartDistand a stop distancestopDistand returns a subsection of the line in-between those distances. -
lineStringToPolygon(
GeoJSONObject line, bool autoComplete, bool orderCoords, {Map< String, dynamic> ? properties}) → Feature<Polygon> -
Converts LineString to Polygon
Takes a optional boolean
autoCompletethat auto completes LineStrings Takes an optionalorderCoordsthat sorts LineStrings to place outer ring at the first Position of the coordinates. -
lineToPolygon(
GeoJSONObject lines, {Map< String, dynamic> ? properties, bool autoComplete = true, bool orderCoords = true, bool mutate = false}) → Feature<GeometryObject> -
Converts LineStrings & MultiLineString to Polygon or MultiPolygon.
Takes an optional boolean
autoCompletethat auto completes LineStrings (matches first & last coordinates). Takes an optionalorderCoordsthat sorts LineStrings to place outer ring at the first Position of the coordinates. Takes an optionalmutatethat mutates the original LineString usingautoComplete(matches first & last coordinates. Returns Feature<Polygon> or Feature<MultiPolygon> converted to Polygons. example: -
midpoint(
Point point1, Point point2) → Point - Takes two Points and returns a point midway between them. The midpoint is calculated geodesically, meaning the curvature of the earth is taken into account. For example:
-
midpointRaw(
Position point1, Position point2) → Position -
nearestPoint(
Feature< Point> targetPoint, FeatureCollection<Point> points) → Feature<Point> - Takes a reference Point and a FeatureCollection of Features with Point geometries and returns the point from the FeatureCollection closest to the reference. This calculation is geodesic. For example:
-
nearestPointOnLine(
LineString line, Point point, [Unit unit = Unit.kilometers]) → Feature< Point> - Takes a Point and a LineString and calculates the closest Point on the LineString.
-
nearestPointOnMultiLine(
MultiLineString lines, Point point, [Unit unit = Unit.kilometers]) → Feature< Point> ? - Takes a Point and a MultiLineString and calculates the closest Point on the MultiLineString.
-
pointOnFeature(
dynamic featureInput) → Feature< Point> - Returns a Feature<Point> that represents a point guaranteed to be on the feature.
-
pointToLineDistance(
Point point, LineString line, {Unit unit = Unit.kilometers, DistanceGeometry method = DistanceGeometry.geodesic}) → num -
Returns the minimum distance between a
pointand aline, being the distance from a line the minimum distance between the point and any segment of the LineString. -
polygonclip(
List< Position> points, BBox bbox) → List<Position> -
polygonize(
GeoJSONObject geoJSON, {PolygonizeConfig? config}) → FeatureCollection< Polygon> - Converts a collection of LineString features to a collection of Polygon features.
-
polygonSmooth(
GeoJSONObject inputPolys, {int iterations = 1}) → FeatureCollection< GeometryObject> -
Smooths a Polygon, MultiPolygon, also inside Features, FeatureCollections, or GeometryCollection. Based on Chaikin's algorithm.
Warning: may create degenerate polygons.
The optional parameter
iterationsis the number of times to smooth the polygon. A higher value means a smoother polygon. The functions returns a FeatureCollection of Polygons and MultiPolygons. -
polygonTangents(
Point point, GeoJSONObject inputPolys) → FeatureCollection< Point> - Finds the tangents of a Polygon or MultiPolygon from a Point.
-
polygonToLine(
GeoJSONObject poly, {Map< String, dynamic> ? properties}) → GeoJSONObject - Converts a Polygon to LineString or MultiLineString or a MultiPolygon to a FeatureCollection of LineString or MultiLineString. Returns FeatureCollection or Feature<LineString> or Feature<MultiLinestring> example:
-
processPolygon(
List< Position> polygonCoords, Position pointCoords, double eprev, Position rtan, Position ltan) → List<Position> - Processes a polygon to determine the right and left tangents.
-
propEach(
GeoJSONObject geoJSON, PropEachCallback callback) → void -
Iterates over properties in any
geoJSONobject, callingcallbackon each iteration. Similar to Iterable.forEach -
propertiesContainsFilter(
Map properties, Map filter) → bool -
Properties contains filter (does not apply deepEqual operations)
Takes a Map
propertiesvalue, and a Map filter and Returns bool if filter does equal thepropertiesFor example -
propReduce<
T> (GeoJSONObject geojson, PropReduceCallback< T> callback, T? initialValue) → T? - Reduces properties in any GeoJSONObject into a single value, similar to how Iterable.reduce works. However, in this case we lazily run the reduction, so List of all properties is unnecessary.
-
radiansToDegrees(
num radians) → num - Converts an angle in radians to degrees
-
radiansToLength(
num radians, [Unit unit = Unit.kilometers]) → num - Convert a distance measurement (assuming a spherical Earth) from radians to a more friendly unit. Valid units: Unit.miles, Unit.nauticalmiles, Unit.inches, Unit.yards, Unit.meters, Unit.kilometers, Unit.centimeters, Unit.feet
-
randomLineString(
int count, {BBox? bbox, int numVertices = 10, double maxLength = 0.0001, double maxRotation = pi / 8}) → FeatureCollection< LineString> - Takes an optional bbox and a mandatory integer to generate x number of linestrings. Other optional parameters: numVertices, maxLength, maxRotation Returns a random linestring
-
rhumbBearing(
Point start, Point end, {bool kFinal = false}) → num -
Takes two Point and finds the bearing angle between them along a Rhumb line
i.e. the angle measured in degrees start the north line (0 degrees)
kFinalcalculates the final bearing if true. Returns bearing from north in decimal degrees, between -180 and 180 degrees (positive clockwise) example: -
rhumbDestination(
Point origin, num distance, num bearing, {Unit? unit = Unit.kilometers, Map< String, dynamic> ? properties}) → Feature<Point> - Returns the destination Point having traveled the given distance along a Rhumb line from the origin Point with the (variant) given bearing.
-
rhumbDistance(
Point from, Point to, [Unit unit = Unit.kilometers]) → num - Calculates the distance along a rhumb line between two Point in degrees, radians, miles, or kilometers.
-
round(
num value, [num precision = 0]) → num - Round number to precision
-
segmentEach(
GeoJSONObject geojson, SegmentEachCallback callback, {bool combineNestedGeometries = true}) → void - Iterates over 2-vertex line segment in any GeoJSON object, similar to Iterable.forEach (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
-
segmentReduce<
T> (GeoJSONObject geojson, SegmentReduceCallback< T> callback, T? initialValue, {bool combineNestedGeometries = true}) → T? - Reduces 2-vertex line segment in any GeoJSON object, similar to Iterable.reduce (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
-
simplify(
Feature< LineString> points, {double tolerance = 1, bool highestQuality = false}) → Feature<LineString> - Simplify a LineString feature using dart port of simplify.js high-performance JS polyline simplification library.
-
square(
BBox bbox) → BBox - Takes a BBox and returns a square BBox of equal dimensions.
-
toMercator(
Position coord) → Position - Converts a WGS84 coordinate to Web Mercator.
-
toWGS84(
Position coord) → Position - Converts a Web Mercator coordinate to WGS84.
-
transformRotate(
GeoJSONObject geoJSON, num angle, {Point? pivot, bool mutate = false}) → GeoJSONObject -
Rotates any GeoJSONObject of a specified angle, around its
centroidor a givenpivotPoint. -
truncate(
GeoJSONObject geojson, {int precision = 6, int coordinates = 3, bool mutate = false}) → GeoJSONObject -
Takes a Feature or FeatureCollection and truncates the precision of the geometry.
precisionsets the coordinate decimal precisioncoordinatessets the maximum number of coordinates (primarly used to remove z coordinates)mutateallows GeoJSONObject input to be mutated (significant performance increase if true) Returns GeoJSONObject layer with truncated geometry
Typedefs
-
ClusterEachCallback
= dynamic Function(FeatureCollection<
GeometryObject> ? cluster, dynamic clusterValue, int? currentIndex) -
ClusterEachCallback
Takes a FeatureCollection, the cluster being processed, a
clusterValueused to create cluster being processed, and thecurrentIndex, the index of current element being processed in the List. Starts at index 0 Returns void. -
ClusterReduceCallback<
T> = T? Function(T? previousValue, FeatureCollection< GeometryObject> ? cluster, dynamic clusterValue, int? currentIndex) -
ClusterReduceCallback
The first time the callback function is called, the values provided as arguments depend
on whether the reduce method has an
initialValueargument. - CoordEachCallback = dynamic Function(Position? currentCoord, int? coordIndex, int? featureIndex, int? multiFeatureIndex, int? geometryIndex)
-
CoordReduceCallback<
T> = T? Function(T? previousValue, Position? currentCoord, int? coordIndex, int? featureIndex, int? multiFeatureIndex, int? geometryIndex) - Callback for coordReduce
-
FeatureEachCallback
= dynamic Function(Feature<
GeometryObject> currentFeature, int featureIndex) - Callback for featureEach
-
FeatureReduceCallback<
T> = T? Function(T? previousValue, Feature< GeometryObject> currentFeature, int featureIndex) - Callback for featureReduce
-
FlattenEachCallback
= dynamic Function(Feature<
GeometryType> currentFeature, int featureIndex, int multiFeatureIndex) - Callback for flattenEach
-
FlattenReduceCallback<
T> = T? Function(T? previousValue, Feature< GeometryObject> currentFeature, int featureIndex, int multiFeatureIndex) -
Callback for flattenReduce
The first time the callback function is called, the values provided as
arguments depend on whether the reduce method has an
initialValueargument. If aninitialValueis provided to the reduce method: -
GeomEachCallback
= dynamic Function(GeometryType? currentGeometry, int? featureIndex, Map<
String, dynamic> ? featureProperties, BBox? featureBBox, dynamic featureId) -
GeomReduceCallback<
T> = T? Function(T? previousValue, GeometryType? currentGeometry, int? featureIndex, Map< String, dynamic> ? featureProperties, BBox? featureBBox, dynamic featureId) - Callback for geomReduce
- LocalizedCoordEachCallback = dynamic Function(Position? currentCoord, int? coordIndex, int? featureIndex, int? multiFeatureIndex, int? geometryIndex, int? localCoordIndex)
-
PropEachCallback
= dynamic Function(Map<
String, dynamic> ? currentProperties, int featureIndex) - Callback for propEach
-
PropReduceCallback<
T> = T? Function(T? previousValue, Map< String, dynamic> ? currentProperties, int featureIndex) - Callback for propReduce
-
SegmentEachCallback
= dynamic Function(Feature<
LineString> currentSegment, int featureIndex, int? multiFeatureIndex, int? geometryIndex, int segmentIndex) - SegmentEachCallback
-
SegmentReduceCallback<
T> = T? Function(T? previousValue, Feature< LineString> currentSegment, T? initialValue, int featureIndex, int? multiFeatureIndex, int? geometryIndex, int segmentIndex) - Callback for segmentReduce