dgeoutils 2.2.1 → 2.2.5

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.
@@ -4,13 +4,46 @@ import { DLine } from './DLine';
4
4
  import { DPolygonLoop } from './DPolygonLoop';
5
5
  export declare const MIN_POINTS_IN_VALID_POLYGON = 3;
6
6
  export declare class DPolygon {
7
+ private pPoints;
7
8
  properties: {
8
9
  [key: string]: any;
9
10
  };
10
11
  holes: DPolygon[];
11
- private pPoints;
12
12
  private searchStore;
13
- constructor(points?: DPoint[]);
13
+ constructor(pPoints?: DPoint[]);
14
+ /**
15
+ * Specifies a round line buffer end cap style.
16
+ */
17
+ static CAP_ROUND: number;
18
+ /**
19
+ * Specifies a flat line buffer end cap style.
20
+ */
21
+ static CAP_FLAT: number;
22
+ /**
23
+ * Specifies a square line buffer end cap style.
24
+ */
25
+ static CAP_SQUARE: number;
26
+ /**
27
+ * Transform array of triangles to Three.JS vertices
28
+ *
29
+ * ```
30
+ * const geometry = new THREE.BufferGeometry();
31
+ * // create a simple square shape. We duplicate the top left and bottom right
32
+ * // vertices because each vertex needs to appear once per triangle.
33
+ * const vertices = new Float32Array( DPolygon.arrayOfTrianglesToVertices(triangles, 10) );
34
+ *
35
+ * // itemSize = 3 because there are 3 values (components) per vertex
36
+ * geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
37
+ * const material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
38
+ * mesh = new THREE.Mesh( geometry, material );
39
+ *
40
+ * scene.add( mesh );
41
+ * ```
42
+ *
43
+ * @param triangles
44
+ * @param [height=0]
45
+ */
46
+ static arrayOfTrianglesToVertices(triangles: DPolygon[], height?: number): number[];
14
47
  /**
15
48
  * Get size of min area rectangle.
16
49
  * @param poly should be `minAreaRectangle`
@@ -138,37 +171,25 @@ export declare class DPolygon {
138
171
  * @param newCenter
139
172
  */
140
173
  setCenter(newCenter: DPoint): DPolygon;
141
- toWKT(): string;
174
+ static WKT_LINESTRING: string;
175
+ static WKT_POLYGON: string;
142
176
  /**
143
- * Rotate polygon with center in point {0, 0}
144
- * @param a Radians
177
+ * @param [type = DPolygon.WKT_POLYGON] Available values `DPolygon.WKT_POLYGON`, `DPolygon.WKT_LINESTRING`
145
178
  */
146
- rotate(a: number): DPolygon;
179
+ toWKT(type?: string): string;
147
180
  /**
148
181
  * Filter points
149
182
  * @param f
150
183
  */
151
184
  filter(f: (p: DPoint) => boolean): DPolygon;
152
- move(x?: number | DPoint, y?: number): DPolygon;
153
- scale(x?: number | DPoint, y?: number): DPolygon;
154
- divide(x?: number | DPoint, y?: number): DPolygon;
155
- round(): DPolygon;
156
- floor(): DPolygon;
157
- ceil(): DPolygon;
158
- flipVertically(size: DPoint | number): DPolygon;
159
- toFixed(n?: number): DPolygon;
160
185
  map(f: (r: DPoint, index?: number) => DPoint): DPolygon;
161
- p(index: number, divide?: boolean): DPoint;
186
+ at(index: number): DPoint;
162
187
  pop(): DPoint;
163
188
  push(...args: DPoint[]): number;
164
189
  shift(): DPoint;
165
190
  unshift(...args: DPoint[]): number;
166
191
  reverse(): DPolygon;
167
192
  getValue(): string;
168
- degreeToMeters(): DPolygon;
169
- metersToDegree(): DPolygon;
170
- radiansToMeters(): DPolygon;
171
- metersToRadians(): DPolygon;
172
193
  toString(): string;
173
194
  /**
174
195
  * Add to the end of polygon point equal to first point if it not exist
@@ -178,11 +199,6 @@ export declare class DPolygon {
178
199
  * Remove from the end of polygon point equal to first point if it exist
179
200
  */
180
201
  open(): DPolygon;
181
- /**
182
- * Set `height` (`z`)
183
- * @param z
184
- */
185
- height(z: number): DPolygon;
186
202
  add(poly: DPolygon): DPolygon;
187
203
  /**
188
204
  * Check if has point in list of points
@@ -204,7 +220,7 @@ export declare class DPolygon {
204
220
  /**
205
221
  * Get polygon approximation by
206
222
  * [Ramer–Douglas–Peucker algorithm](https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm)
207
- * @param e
223
+ * @param [e=Math.sqrt(this.perimeter)*APPROXIMATION_VALUE]
208
224
  */
209
225
  approximation(e?: number): DPolygon;
210
226
  insertAfter(index: number, ...points: DPoint[]): void;
@@ -224,8 +240,8 @@ export declare class DPolygon {
224
240
  /**
225
241
  * Check if contain point
226
242
  * @param p
227
- * @param isBorderInside
228
- * @param move Ignore this parameter
243
+ * @param [isBorderInside=false]
244
+ * @param [move=(0,0)] Ignore this parameter
229
245
  */
230
246
  contain(p: DPoint, isBorderInside?: boolean, move?: DPoint): boolean;
231
247
  /**
@@ -242,11 +258,20 @@ export declare class DPolygon {
242
258
  */
243
259
  removeDuplicates(): DPolygon;
244
260
  /**
245
- * Parse from [OpenLayers](https://openlayers.org/) coordinates or
246
- * [GeoJSON](https://en.wikipedia.org/wiki/GeoJSON) coordinates
261
+ * Parse from [OpenLayers](https://openlayers.org/) coordinates
262
+ * @param a
263
+ */
264
+ static parse(a: LatLng[]): DPolygon;
265
+ /**
266
+ * Parse from [GeoJSON](https://en.wikipedia.org/wiki/GeoJSON) coordinates
267
+ * @param a
268
+ */
269
+ static parse(a: number[][]): DPolygon;
270
+ /**
271
+ * Parse from [OpenLayers](https://openlayers.org/) coordinates
247
272
  * @param a
248
273
  */
249
- static parse(a: LatLng[] | number[][] | DCoord[]): DPolygon;
274
+ static parse(a: DCoord[]): DPolygon;
250
275
  /**
251
276
  * Transform to array of coordinates for [OpenLayers](https://openlayers.org/) or
252
277
  * [GeoJSON](https://en.wikipedia.org/wiki/GeoJSON)
@@ -270,14 +295,16 @@ export declare class DPolygon {
270
295
  /**
271
296
  * Divide polygon to triangles
272
297
  *
273
- * ![Example](/media/examples/toTriangles.png)
298
+ * ![Example](https://edejin.github.io/DGeoUtils/media/examples/toTriangles.png)
274
299
  */
275
300
  toTriangles(): DPolygon[];
301
+ get closed(): boolean;
276
302
  /**
277
- * @internal
303
+ * @param v
304
+ * @param [quadrantSegments=64]
305
+ * @param [type=DPolygon.CAP_ROUND] DPolygon.CAP_ROUND || DPolygon.CAP_FLAT || DPolygon.CAP_SQUARE
278
306
  */
279
- getTriangle(): DPolygon | void;
280
- private innerAndNotIntersect;
307
+ buffer(v: number, quadrantSegments?: number, type?: number): DPolygon;
281
308
  private simpleIncludeX;
282
309
  private simpleIncludeY;
283
310
  private douglasPeucker;