bruce-models 3.4.0 → 3.4.2

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.
@@ -3830,6 +3830,66 @@
3830
3830
  return geometry;
3831
3831
  }
3832
3832
  Geometry.ParseGeometry = ParseGeometry;
3833
+ function ToGeoJson(params) {
3834
+ const { entities, excludeAltitude } = params;
3835
+ const features = [];
3836
+ const processGeometry = (geometry, ID) => {
3837
+ if (geometry.Polygon) {
3838
+ const sortedPolygons = geometry.Polygon.sort((a, b) => a.Facing === EPolygonRingType.Boundaries ? -1 : 1);
3839
+ const coordinates = sortedPolygons.map(polygonRing => polygonRing.LinearRing.split(' ').map(coord => {
3840
+ const [lon, lat, alt] = coord.split(',').map(Number);
3841
+ return excludeAltitude ? [lon, lat] : [lon, lat, ...(alt ? [alt] : [])];
3842
+ }));
3843
+ features.push({
3844
+ type: 'Feature',
3845
+ properties: { ID },
3846
+ geometry: {
3847
+ type: 'Polygon',
3848
+ coordinates: coordinates,
3849
+ }
3850
+ });
3851
+ }
3852
+ if (geometry.Point) {
3853
+ const [lon, lat, alt] = geometry.Point.split(',').map(Number);
3854
+ const coordinates = excludeAltitude ? [lon, lat] : [lon, lat, ...(alt ? [alt] : [])];
3855
+ features.push({
3856
+ type: 'Feature',
3857
+ properties: { ID },
3858
+ geometry: {
3859
+ type: 'Point',
3860
+ coordinates,
3861
+ }
3862
+ });
3863
+ }
3864
+ if (geometry.LineString) {
3865
+ const coordinates = geometry.LineString.split(' ').map(coord => {
3866
+ const [lon, lat, alt] = coord.split(',').map(Number);
3867
+ return excludeAltitude ? [lon, lat] : [lon, lat, ...(alt ? [alt] : [])];
3868
+ });
3869
+ features.push({
3870
+ type: 'Feature',
3871
+ properties: { ID },
3872
+ geometry: {
3873
+ type: 'LineString',
3874
+ coordinates,
3875
+ }
3876
+ });
3877
+ }
3878
+ if (geometry.MultiGeometry) {
3879
+ geometry.MultiGeometry.forEach(geo => processGeometry(geo, ID));
3880
+ }
3881
+ };
3882
+ entities.forEach(entity => {
3883
+ const { ID } = entity.Bruce;
3884
+ const { geometry } = entity;
3885
+ processGeometry(geometry, ID);
3886
+ });
3887
+ return {
3888
+ type: 'FeatureCollection',
3889
+ features,
3890
+ };
3891
+ }
3892
+ Geometry.ToGeoJson = ToGeoJson;
3833
3893
  })(exports.Geometry || (exports.Geometry = {}));
3834
3894
 
3835
3895
  (function (Bounds) {
@@ -10457,7 +10517,7 @@
10457
10517
  DataSource.GetList = GetList;
10458
10518
  })(exports.DataSource || (exports.DataSource = {}));
10459
10519
 
10460
- const VERSION = "3.4.0";
10520
+ const VERSION = "3.4.2";
10461
10521
 
10462
10522
  exports.VERSION = VERSION;
10463
10523
  exports.AbstractApi = AbstractApi;