@overmap-ai/core 1.0.65-mapbox.1 → 1.0.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -397,21 +397,70 @@ var __publicField = (obj, key, value) => {
397
397
  const selectAccessToken = (state) => state.authReducer.accessToken;
398
398
  const selectIsLoggedIn = (state) => state.authReducer.isLoggedIn;
399
399
  const authReducer = authSlice.reducer;
400
- const createPointGeometry = (position) => {
400
+ const coordinatesToLiteral = (coordinates) => {
401
+ return { lng: coordinates[0], lat: coordinates[1] };
402
+ };
403
+ const literalToCoordinates = (literal) => {
404
+ return [literal.lng, literal.lat];
405
+ };
406
+ const flipCoordinates = (coordinates) => {
407
+ return [coordinates[1], coordinates[0]];
408
+ };
409
+ const flipBounds = (bounds) => {
410
+ return [flipCoordinates(bounds[0]), flipCoordinates(bounds[1])];
411
+ };
412
+ function offsetPositionByMeters(originalPosition, latMeters, lngMeters) {
413
+ const { lat, lng } = originalPosition;
414
+ const earthRadius = 6378137;
415
+ const metersPerDegree = 2 * Math.PI * earthRadius / 360;
416
+ const newLng = lng + lngMeters / metersPerDegree / Math.cos(lat * Math.PI / 180);
417
+ const newLat = lat - latMeters / metersPerDegree;
418
+ return { lat: newLat, lng: newLng };
419
+ }
420
+ const createPointGeometry = (coordinates) => {
401
421
  return {
402
422
  type: "Point",
403
- coordinates: position
423
+ coordinates
404
424
  };
405
425
  };
426
+ const coordinatesAreEqual = (a, b) => {
427
+ return a[0] === b[0] && a[1] === b[1];
428
+ };
429
+ const coordinatesToText = (coordinates, decimalPlaces) => {
430
+ if (!coordinates)
431
+ return "(No Location)";
432
+ const { lat, lng } = coordinatesToLiteral(coordinates);
433
+ if (decimalPlaces)
434
+ return `${lat.toFixed(decimalPlaces)}, ${lng.toFixed(decimalPlaces)}`;
435
+ return `${lat}, ${lng}`;
436
+ };
437
+ const coordinatesToUrlText = (coordinates) => {
438
+ const { lat, lng } = coordinatesToLiteral(coordinates);
439
+ return `${lat}%2C${lng}`;
440
+ };
441
+ const openCoordsInGoogleMaps = (coordinates) => {
442
+ const url = `https://www.google.com/maps/search/?api=1&query=${coordinatesToUrlText(coordinates)}`;
443
+ window.open(url);
444
+ };
445
+ const openDirectionsInGoogleMaps = (startingPoint, destination) => {
446
+ const startingPointUrl = coordinatesToUrlText(startingPoint);
447
+ const destinationUrl = coordinatesToUrlText(destination);
448
+ const url = `https://www.google.com/maps/dir/?api=1&origin=${startingPointUrl}&destination=${destinationUrl}`;
449
+ window.open(url);
450
+ };
451
+ const worldBounds = {
452
+ type: "MultiPoint",
453
+ coordinates: [
454
+ [90, -180],
455
+ [-90, 180]
456
+ ]
457
+ };
406
458
  const createMultiPointGeometry = (coordinates) => {
407
459
  return {
408
460
  type: "MultiPoint",
409
461
  coordinates
410
462
  };
411
463
  };
412
- const coordinatesAreEqual = (a, b) => {
413
- return a[0] === b[0] && a[1] === b[1];
414
- };
415
464
  function classNames(...args) {
416
465
  const classes = [];
417
466
  for (const arg of args) {
@@ -589,11 +638,14 @@ var __publicField = (obj, key, value) => {
589
638
  return v.file_sha1 === value.file_sha1;
590
639
  }) === index;
591
640
  }
641
+ function boundsContainPoint(bounds, coordinates) {
642
+ return bounds[0][0] > coordinates[0] && bounds[1][0] < coordinates[0] && bounds[0][1] > coordinates[1] && bounds[1][1] < coordinates[1];
643
+ }
592
644
  const emailRegex = /^.+@.+\..+$/;
593
645
  const fullAssetMarkerSize = 45;
594
646
  const DEFAULT_ISSUE_STATUS = IssueStatus.BACKLOG;
595
647
  const DEFAULT_ISSUE_PRIORITY = IssuePriority.MEDIUM;
596
- const OUTBOX_RETRY_DELAY = 5e3;
648
+ const OUTBOX_RETRY_DELAY = 6e4;
597
649
  const EMPTY_ARRAY = Object.freeze([]);
598
650
  let debug = false;
599
651
  const REACT_APP_DEBUG_MEMOIZATION = {}.REACT_APP_DEBUG_MEMOIZATION || "";
@@ -7624,6 +7676,7 @@ var __publicField = (obj, key, value) => {
7624
7676
  exports2.authReducer = authReducer;
7625
7677
  exports2.authSlice = authSlice;
7626
7678
  exports2.blobToBase64 = blobToBase64;
7679
+ exports2.boundsContainPoint = boundsContainPoint;
7627
7680
  exports2.categoryReducer = categoryReducer;
7628
7681
  exports2.categorySlice = categorySlice;
7629
7682
  exports2.classNames = classNames;
@@ -7631,6 +7684,9 @@ var __publicField = (obj, key, value) => {
7631
7684
  exports2.clearTokens = clearTokens;
7632
7685
  exports2.constructUploadedFilePayloads = constructUploadedFilePayloads;
7633
7686
  exports2.coordinatesAreEqual = coordinatesAreEqual;
7687
+ exports2.coordinatesToLiteral = coordinatesToLiteral;
7688
+ exports2.coordinatesToText = coordinatesToText;
7689
+ exports2.coordinatesToUrlText = coordinatesToUrlText;
7634
7690
  exports2.createMultiPointGeometry = createMultiPointGeometry;
7635
7691
  exports2.createOfflineAction = createOfflineAction;
7636
7692
  exports2.createPointGeometry = createPointGeometry;
@@ -7693,6 +7749,8 @@ var __publicField = (obj, key, value) => {
7693
7749
  exports2.fileReducer = fileReducer;
7694
7750
  exports2.fileSlice = fileSlice;
7695
7751
  exports2.fileToBlob = fileToBlob;
7752
+ exports2.flipBounds = flipBounds;
7753
+ exports2.flipCoordinates = flipCoordinates;
7696
7754
  exports2.formReducer = formReducer;
7697
7755
  exports2.formRevisionAttachmentReducer = formRevisionAttachmentReducer;
7698
7756
  exports2.formRevisionAttachmentSlice = formRevisionAttachmentSlice;
@@ -7759,14 +7817,18 @@ var __publicField = (obj, key, value) => {
7759
7817
  exports2.issueUpdateSlice = issueUpdateSlice;
7760
7818
  exports2.licenseReducer = licenseReducer;
7761
7819
  exports2.licenseSlice = licenseSlice;
7820
+ exports2.literalToCoordinates = literalToCoordinates;
7762
7821
  exports2.logOnlyOnce = logOnlyOnce;
7763
7822
  exports2.markAsDeleted = markAsDeleted;
7764
7823
  exports2.markForDeletion = markForDeletion;
7765
7824
  exports2.memoize = memoize;
7766
7825
  exports2.moveDocument = moveDocument;
7767
7826
  exports2.offline = offline;
7827
+ exports2.offsetPositionByMeters = offsetPositionByMeters;
7768
7828
  exports2.onlyUniqueHashes = onlyUniqueHashes;
7769
7829
  exports2.onlyUniqueOfflineIds = onlyUniqueOfflineIds;
7830
+ exports2.openCoordsInGoogleMaps = openCoordsInGoogleMaps;
7831
+ exports2.openDirectionsInGoogleMaps = openDirectionsInGoogleMaps;
7770
7832
  exports2.organizationAccessReducer = organizationAccessReducer;
7771
7833
  exports2.organizationAccessSlice = organizationAccessSlice;
7772
7834
  exports2.organizationReducer = organizationReducer;
@@ -8082,6 +8144,7 @@ var __publicField = (obj, key, value) => {
8082
8144
  exports2.warningColor = warningColor;
8083
8145
  exports2.workspaceReducer = workspaceReducer;
8084
8146
  exports2.workspaceSlice = workspaceSlice;
8147
+ exports2.worldBounds = worldBounds;
8085
8148
  Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
8086
8149
  });
8087
8150
  //# sourceMappingURL=overmap-core.umd.cjs.map