bruce-models 4.6.7 → 4.6.9

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.
@@ -4468,7 +4468,7 @@
4468
4468
  * @returns returns GeoJSON or null if conversion failed or resulted in an empty object.
4469
4469
  */
4470
4470
  function ToGeoJsonFeature(params) {
4471
- const { geometry, properties, altitude } = params;
4471
+ const { geometry, properties, altitude, noAltitude } = params;
4472
4472
  // Primary collection of geometries.
4473
4473
  // We will return a single feature that contains many geometries.
4474
4474
  // That way we can attach properties to the top-level.
@@ -4523,6 +4523,9 @@
4523
4523
  const points = ParsePoints(polygon.LinearRing);
4524
4524
  return removeConsecutiveDuplicates(points.map(coord => {
4525
4525
  const { longitude: lon, latitude: lat, altitude: alt } = coord;
4526
+ if (noAltitude) {
4527
+ return [lon, lat];
4528
+ }
4526
4529
  return (altitude != null ? [lon, lat, altitude] : [lon, lat, alt !== undefined ? alt : 0]);
4527
4530
  }));
4528
4531
  }));
@@ -4537,6 +4540,9 @@
4537
4540
  const points = ParsePoints(geometry.LineString);
4538
4541
  const coordinates = removeConsecutiveDuplicates(points.map(coord => {
4539
4542
  const { longitude: lon, latitude: lat, altitude: alt } = coord;
4543
+ if (noAltitude) {
4544
+ return [lon, lat];
4545
+ }
4540
4546
  return (altitude != null ? [lon, lat, altitude] : [lon, lat, alt !== undefined ? alt : 0]);
4541
4547
  }));
4542
4548
  if (coordinates.length >= 2) {
@@ -4550,7 +4556,13 @@
4550
4556
  const points = ParsePoints(geometry.Point);
4551
4557
  if (points.length) {
4552
4558
  const { longitude: lon, latitude: lat, altitude: alt } = points[0];
4553
- const coordinates = altitude != null ? [lon, lat, altitude] : [lon, lat, alt !== undefined ? alt : 0];
4559
+ let coordinates;
4560
+ if (noAltitude) {
4561
+ coordinates = [lon, lat];
4562
+ }
4563
+ else {
4564
+ coordinates = altitude != null ? [lon, lat, altitude] : [lon, lat, alt !== undefined ? alt : 0];
4565
+ }
4554
4566
  jGeometry = {
4555
4567
  coordinates: coordinates,
4556
4568
  type: exports.GeoJson.EType.Point
@@ -4616,15 +4628,11 @@
4616
4628
  // This will append to the "full" object as it goes.
4617
4629
  const traverse = (feature) => {
4618
4630
  // Geometry collections don't have coords so we have to cast as any.
4619
- const { type, coordinates, properties } = feature.geometry;
4631
+ const { type, coordinates, properties, geometries } = feature.geometry;
4620
4632
  // Unknown thing. Ignoring.
4621
4633
  if (!type) {
4622
4634
  return;
4623
4635
  }
4624
- // No coordinates. Ignoring.
4625
- if (!coordinates) {
4626
- return;
4627
- }
4628
4636
  // Simple properties merge.
4629
4637
  // Doesn't handle nested properties very well.
4630
4638
  if (properties) {
@@ -4633,9 +4641,8 @@
4633
4641
  // We'll first match cases of nested collections and handle them early.
4634
4642
  // Then we'll be left with simple geometry cases.
4635
4643
  if (type === exports.GeoJson.EType.GeometryCollection) {
4636
- const collection = feature;
4637
- for (let i = 0; i < collection.geometries.length; i++) {
4638
- const geo = collection.geometries[i];
4644
+ for (let i = 0; i < geometries.length; i++) {
4645
+ const geo = geometries[i];
4639
4646
  traverse({
4640
4647
  type: exports.GeoJson.EType.Feature,
4641
4648
  geometry: geo,
@@ -4651,6 +4658,10 @@
4651
4658
  }
4652
4659
  return;
4653
4660
  }
4661
+ // No coordinates. Ignoring.
4662
+ if (!coordinates) {
4663
+ return;
4664
+ }
4654
4665
  const geometry = {};
4655
4666
  switch (type) {
4656
4667
  case exports.GeoJson.EType.Polygon:
@@ -13751,7 +13762,7 @@
13751
13762
  })(exports.DataSource || (exports.DataSource = {}));
13752
13763
 
13753
13764
  // This is updated with the package.json version on build.
13754
- const VERSION = "4.6.7";
13765
+ const VERSION = "4.6.9";
13755
13766
 
13756
13767
  exports.VERSION = VERSION;
13757
13768
  exports.AbstractApi = AbstractApi;