boolean library
Boolean spatial predicates for GeoJSON geometries (contains, within, equal, etc.).
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
- Position
- Please make sure, you arrange your parameters like this:
Functions
-
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. -
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