@konfirm/geojson 1.0.0

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.
Files changed (122) hide show
  1. package/.editorconfig +16 -0
  2. package/.github/workflows/release.yml +21 -0
  3. package/.github/workflows/tests.yml +56 -0
  4. package/CHANGELOG.md +21 -0
  5. package/LICENSE +21 -0
  6. package/README.md +260 -0
  7. package/dist/Domain/Constants.d.ts +5 -0
  8. package/dist/Domain/GeoJSON/Concept/Altitude.d.ts +3 -0
  9. package/dist/Domain/GeoJSON/Concept/BoundingBox.d.ts +6 -0
  10. package/dist/Domain/GeoJSON/Concept/ExteriorRing.d.ts +4 -0
  11. package/dist/Domain/GeoJSON/Concept/GeoJSONObject.d.ts +11 -0
  12. package/dist/Domain/GeoJSON/Concept/InteriorRing.d.ts +4 -0
  13. package/dist/Domain/GeoJSON/Concept/Latitude.d.ts +3 -0
  14. package/dist/Domain/GeoJSON/Concept/LinearRing.d.ts +4 -0
  15. package/dist/Domain/GeoJSON/Concept/Longitude.d.ts +3 -0
  16. package/dist/Domain/GeoJSON/Concept/Position.d.ts +7 -0
  17. package/dist/Domain/GeoJSON/Feature.d.ts +12 -0
  18. package/dist/Domain/GeoJSON/FeatureCollection.d.ts +8 -0
  19. package/dist/Domain/GeoJSON/GeoJSON.d.ts +7 -0
  20. package/dist/Domain/GeoJSON/Geometry/LineString.d.ts +11 -0
  21. package/dist/Domain/GeoJSON/Geometry/MultiLineString.d.ts +7 -0
  22. package/dist/Domain/GeoJSON/Geometry/MultiPoint.d.ts +8 -0
  23. package/dist/Domain/GeoJSON/Geometry/MultiPolygon.d.ts +7 -0
  24. package/dist/Domain/GeoJSON/Geometry/Point.d.ts +11 -0
  25. package/dist/Domain/GeoJSON/Geometry/Polygon.d.ts +11 -0
  26. package/dist/Domain/GeoJSON/Geometry.d.ts +9 -0
  27. package/dist/Domain/GeoJSON/GeometryCollection.d.ts +8 -0
  28. package/dist/Domain/GeoJSON/GeometryObject.d.ts +12 -0
  29. package/dist/Domain/Guards/Number.d.ts +3 -0
  30. package/dist/Domain/Guards/Tuple.d.ts +3 -0
  31. package/dist/Domain/Iterator/IterablePair.d.ts +32 -0
  32. package/dist/Domain/Iterator/SimpleGeometry.d.ts +90 -0
  33. package/dist/Domain/Utility/Calculate.d.ts +9 -0
  34. package/dist/Domain/Utility/Distance.d.ts +3 -0
  35. package/dist/Domain/Utility/Intersect.d.ts +2 -0
  36. package/dist/Domain/Utility/Segments.d.ts +2 -0
  37. package/dist/Domain/Utility/Winding.d.ts +3 -0
  38. package/dist/geojson.cjs.js +655 -0
  39. package/dist/geojson.cjs.min.js +1 -0
  40. package/dist/geojson.d.ts +198 -0
  41. package/dist/geojson.es.js +627 -0
  42. package/dist/geojson.es.min.js +1 -0
  43. package/dist/geojson.js +660 -0
  44. package/dist/geojson.min.js +1 -0
  45. package/dist/main.d.ts +15 -0
  46. package/package.json +63 -0
  47. package/rollup.config.mjs +43 -0
  48. package/source/Domain/Constants.ts +5 -0
  49. package/source/Domain/GeoJSON/Concept/Altitude.ts +9 -0
  50. package/source/Domain/GeoJSON/Concept/BoundingBox.ts +31 -0
  51. package/source/Domain/GeoJSON/Concept/ExteriorRing.ts +12 -0
  52. package/source/Domain/GeoJSON/Concept/GeoJSONObject.ts +23 -0
  53. package/source/Domain/GeoJSON/Concept/InteriorRing.ts +12 -0
  54. package/source/Domain/GeoJSON/Concept/Latitude.ts +7 -0
  55. package/source/Domain/GeoJSON/Concept/LinearRing.ts +14 -0
  56. package/source/Domain/GeoJSON/Concept/Longitude.ts +7 -0
  57. package/source/Domain/GeoJSON/Concept/Position.ts +18 -0
  58. package/source/Domain/GeoJSON/Feature.ts +24 -0
  59. package/source/Domain/GeoJSON/FeatureCollection.ts +16 -0
  60. package/source/Domain/GeoJSON/GeoJSON.ts +9 -0
  61. package/source/Domain/GeoJSON/Geometry/LineString.ts +12 -0
  62. package/source/Domain/GeoJSON/Geometry/MultiLineString.ts +9 -0
  63. package/source/Domain/GeoJSON/Geometry/MultiPoint.ts +10 -0
  64. package/source/Domain/GeoJSON/Geometry/MultiPolygon.ts +9 -0
  65. package/source/Domain/GeoJSON/Geometry/Point.ts +12 -0
  66. package/source/Domain/GeoJSON/Geometry/Polygon.ts +20 -0
  67. package/source/Domain/GeoJSON/Geometry.ts +11 -0
  68. package/source/Domain/GeoJSON/GeometryCollection.ts +23 -0
  69. package/source/Domain/GeoJSON/GeometryObject.ts +20 -0
  70. package/source/Domain/Guards/Number.ts +13 -0
  71. package/source/Domain/Guards/Tuple.ts +6 -0
  72. package/source/Domain/Guards/Utility.ts +1 -0
  73. package/source/Domain/Iterator/IterablePair.ts +47 -0
  74. package/source/Domain/Iterator/SimpleGeometry.ts +137 -0
  75. package/source/Domain/Utility/Calculate.ts +143 -0
  76. package/source/Domain/Utility/Distance.ts +56 -0
  77. package/source/Domain/Utility/Intersect.ts +42 -0
  78. package/source/Domain/Utility/Numeric.ts +8 -0
  79. package/source/Domain/Utility/Segments.ts +5 -0
  80. package/source/Domain/Utility/Winding.ts +19 -0
  81. package/source/main.ts +20 -0
  82. package/test/Domain/GeoJSON/Concept/Altitude.ts +58 -0
  83. package/test/Domain/GeoJSON/Concept/BoundingBox.ts +77 -0
  84. package/test/Domain/GeoJSON/Concept/ExteriorRing.ts +65 -0
  85. package/test/Domain/GeoJSON/Concept/GeoJSONObject.ts +56 -0
  86. package/test/Domain/GeoJSON/Concept/InteriorRing.ts +65 -0
  87. package/test/Domain/GeoJSON/Concept/Latitude.ts +56 -0
  88. package/test/Domain/GeoJSON/Concept/LinearRing.ts +63 -0
  89. package/test/Domain/GeoJSON/Concept/Longitude.ts +56 -0
  90. package/test/Domain/GeoJSON/Concept/Position.ts +56 -0
  91. package/test/Domain/GeoJSON/Feature.ts +9 -0
  92. package/test/Domain/GeoJSON/FeatureCollection.ts +9 -0
  93. package/test/Domain/GeoJSON/GeoJSON.ts +21 -0
  94. package/test/Domain/GeoJSON/Geometry/LineString.ts +11 -0
  95. package/test/Domain/GeoJSON/Geometry/MultiLineString.ts +11 -0
  96. package/test/Domain/GeoJSON/Geometry/MultiPoint.ts +11 -0
  97. package/test/Domain/GeoJSON/Geometry/MultiPolygon.ts +11 -0
  98. package/test/Domain/GeoJSON/Geometry/Point.ts +11 -0
  99. package/test/Domain/GeoJSON/Geometry/Polygon.ts +11 -0
  100. package/test/Domain/GeoJSON/Geometry.ts +9 -0
  101. package/test/Domain/GeoJSON/GeometryCollection.ts +9 -0
  102. package/test/Domain/GeoJSON/GeometryObject.ts +4 -0
  103. package/test/Domain/Guards/Number.ts +49 -0
  104. package/test/Domain/Guards/Tuple.ts +27 -0
  105. package/test/Domain/Iterator/IterablePair.ts +203 -0
  106. package/test/Domain/Iterator/SimpleGeometry.ts +195 -0
  107. package/test/Domain/Utility/Calculate.ts +178 -0
  108. package/test/Domain/Utility/Distance.ts +19 -0
  109. package/test/Domain/Utility/Intersect.ts +54 -0
  110. package/test/Domain/Utility/Numeric.ts +30 -0
  111. package/test/Domain/Utility/Winding.ts +52 -0
  112. package/test/README.ts +123 -0
  113. package/test/data/Distance.ts +51 -0
  114. package/test/data/HolySee.ts +74 -0
  115. package/test/data/Intersect.ts +300 -0
  116. package/test/data/Italy.ts +2883 -0
  117. package/test/data/SanMarino.ts +83 -0
  118. package/test/data/Shapes.ts +107 -0
  119. package/test/helper/geometry.ts +76 -0
  120. package/test/helper/malform.ts +82 -0
  121. package/test/main.ts +4 -0
  122. package/tsconfig.json +12 -0
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Iterator class which traverses all value pairs of two or more Iterable instances
3
+ *
4
+ * @export
5
+ * @class IterablePairIterator
6
+ * @template T
7
+ */
8
+ export declare class IterablePairIterator<T = unknown> {
9
+ private readonly iterators;
10
+ /**
11
+ * Constructs a new instance of IterablePairIterator
12
+ *
13
+ * @param iterators
14
+ */
15
+ constructor(...iterators: [Iterable<T>, Iterable<T>, ...Array<Iterable<T>>]);
16
+ /**
17
+ * Generator yielding all value pairs from the provided iterators
18
+ *
19
+ * @return {*} {Iterator<[T, T]>}
20
+ * @memberof IterablePairIterator
21
+ */
22
+ [Symbol.iterator](): Iterator<[T, T]>;
23
+ /**
24
+ * Create unique Iterator<T> combinations to traverse over
25
+ *
26
+ * @private
27
+ * @param {Array<Iterable<T>>} source
28
+ * @return {*} {Array<[Iterable<T>, Iterable<T>]>}
29
+ * @memberof IterablePairIterator
30
+ */
31
+ private pairs;
32
+ }
@@ -0,0 +1,90 @@
1
+ import { LineString, Point, Polygon } from "../../main";
2
+ import { GeoJSON } from "../GeoJSON/GeoJSON";
3
+ type SimpleGeometry = Point | LineString | Polygon;
4
+ /**
5
+ * Iterator class to turn any GeoJSON structure into one or more SimpleGeometry (Point | LineString | Polygon) objects
6
+ *
7
+ * @export
8
+ * @class SimpleGeometryIterator
9
+ */
10
+ export declare class SimpleGeometryIterator {
11
+ private readonly inputs;
12
+ /**
13
+ * Creates an instance of SimpleGeometryIterator
14
+ *
15
+ * @param {...[GeoJSON, ...Array<GeoJSON>]} inputs
16
+ * @memberof SimpleGeometryIterator
17
+ */
18
+ constructor(...inputs: [GeoJSON, ...Array<GeoJSON>]);
19
+ /**
20
+ * Generator yielding all SimpleGeometry objects from the provided GeoJSON structure(s)
21
+ *
22
+ * @return {*} {Iterator<SimpleGeometry>}
23
+ * @memberof SimpleGeometryIterator
24
+ */
25
+ [Symbol.iterator](): Iterator<SimpleGeometry>;
26
+ /**
27
+ * unwrap any GeoJSON object into one or more SimpleGeometry object
28
+ *
29
+ * @private
30
+ * @param {GeoJSON} geo
31
+ * @return {*} {Iterable<SimpleGeometry>}
32
+ * @memberof SimpleGeometryIterator
33
+ */
34
+ private unwrap;
35
+ /**
36
+ * Generate the geometries in a GeometryCollection
37
+ *
38
+ * @private
39
+ * @param {GeometryCollection} { geometries }
40
+ * @return {*} {Iterable<SimpleGeometry>}
41
+ * @memberof SimpleGeometryIterator
42
+ */
43
+ private GeometryCollection;
44
+ /**
45
+ * Generate the geometries of the Feature object(s) in a FeatureCollection
46
+ *
47
+ * @private
48
+ * @param {FeatureCollection} { features }
49
+ * @return {*} {Iterable<SimpleGeometry>}
50
+ * @memberof SimpleGeometryIterator
51
+ */
52
+ private FeatureCollection;
53
+ /**
54
+ * Generate the geometry of a Feature object
55
+ *
56
+ * @private
57
+ * @param {Feature} { geometry }
58
+ * @return {*} {Iterable<SimpleGeometry>}
59
+ * @memberof SimpleGeometryIterator
60
+ */
61
+ private Feature;
62
+ /**
63
+ * Generate Point objects from a MultiPoint object
64
+ *
65
+ * @private
66
+ * @param {MultiPoint} multi
67
+ * @return {*} {Iterable<Point>}
68
+ * @memberof SimpleGeometryIterator
69
+ */
70
+ private MultiPoint;
71
+ /**
72
+ * Generate LineString objects from a MultiLineString object
73
+ *
74
+ * @private
75
+ * @param {MultiLineString} multi
76
+ * @return {*} {Iterable<LineString>}
77
+ * @memberof SimpleGeometryIterator
78
+ */
79
+ private MultiLineString;
80
+ /**
81
+ * Generate Polygon objects from a MultiPolygon object
82
+ *
83
+ * @private
84
+ * @param {MultiPolygon} multi
85
+ * @return {*} {Iterable<Polygon>}
86
+ * @memberof SimpleGeometryIterator
87
+ */
88
+ private MultiPolygon;
89
+ }
90
+ export {};
@@ -0,0 +1,9 @@
1
+ import { Point } from "../GeoJSON/Geometry/Point";
2
+ export type PointToPointCalculation = 'cartesian' | 'haversine' | 'vincenty' | ((a: Point['coordinates'], b: Point['coordinates']) => number);
3
+ export declare function getClosestPointOnLineByPoint(point: Point['coordinates'], line: [Point['coordinates'], Point['coordinates']]): Point['coordinates'];
4
+ export declare function getDistanceOfPointToPoint(a: Point['coordinates'], b: Point['coordinates'], calculation: PointToPointCalculation): number;
5
+ export declare function getDistanceOfPointToLine(point: Point['coordinates'], line: [Point['coordinates'], Point['coordinates']], calculation: PointToPointCalculation): number;
6
+ export declare function getDistanceOfLineToLine(a: [Point['coordinates'], Point['coordinates']], b: [Point['coordinates'], Point['coordinates']], calculation: PointToPointCalculation): number;
7
+ export declare function isLinesCrossing(a: [Point['coordinates'], Point['coordinates']], b: [Point['coordinates'], Point['coordinates']]): boolean;
8
+ export declare function isPointOnLine(point: Point['coordinates'], line: [Point['coordinates'], Point['coordinates']], threshold?: number): boolean;
9
+ export declare function isPointInRing(p: Point['coordinates'], ring: Array<Point['coordinates']>): boolean;
@@ -0,0 +1,3 @@
1
+ import { GeoJSON } from '../GeoJSON/GeoJSON';
2
+ import { PointToPointCalculation } from './Calculate';
3
+ export declare function distance(a: GeoJSON, b: GeoJSON, calculation?: PointToPointCalculation): number;
@@ -0,0 +1,2 @@
1
+ import { GeoJSON } from '../GeoJSON/GeoJSON';
2
+ export declare function intersect(a: GeoJSON, b: GeoJSON): boolean;
@@ -0,0 +1,2 @@
1
+ import { Point } from '../GeoJSON/Geometry/Point';
2
+ export declare function segments(line: Array<Point['coordinates']>): Array<[Point['coordinates'], Point['coordinates']]>;
@@ -0,0 +1,3 @@
1
+ import { Position } from "../GeoJSON/Concept/Position";
2
+ export declare function isClockwiseWinding<T extends Array<Position>>(value: any): value is T;
3
+ export declare function isCounterClockwiseWinding<T extends Array<Position>>(value: any): value is T;