index.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. var geojson_equality_1 = __importDefault(require("geojson-equality"));
  7. var clean_coords_1 = __importDefault(require("@turf/clean-coords"));
  8. var invariant_1 = require("@turf/invariant");
  9. /**
  10. * Determine whether two geometries of the same type have identical X,Y coordinate values.
  11. * See http://edndoc.esri.com/arcsde/9.0/general_topics/understand_spatial_relations.htm
  12. *
  13. * @name booleanEqual
  14. * @param {Geometry|Feature} feature1 GeoJSON input
  15. * @param {Geometry|Feature} feature2 GeoJSON input
  16. * @returns {boolean} true if the objects are equal, false otherwise
  17. * @example
  18. * var pt1 = turf.point([0, 0]);
  19. * var pt2 = turf.point([0, 0]);
  20. * var pt3 = turf.point([1, 1]);
  21. *
  22. * turf.booleanEqual(pt1, pt2);
  23. * //= true
  24. * turf.booleanEqual(pt2, pt3);
  25. * //= false
  26. */
  27. function booleanEqual(feature1, feature2) {
  28. var type1 = invariant_1.getGeom(feature1).type;
  29. var type2 = invariant_1.getGeom(feature2).type;
  30. if (type1 !== type2)
  31. return false;
  32. var equality = new geojson_equality_1.default({ precision: 6 });
  33. return equality.compare(clean_coords_1.default(feature1), clean_coords_1.default(feature2));
  34. }
  35. exports.default = booleanEqual;