Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@geoblocks/edittrack

Package Overview
Dependencies
Maintainers
5
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@geoblocks/edittrack - npm Package Compare versions

Comparing version 2.0.0-beta.5 to 2.0.0-beta.6

21

lib/profiler/SwisstopoProfiler.js

@@ -16,4 +16,7 @@ import GeoJSONFormat from 'ol/format/GeoJSON.js';

async computeProfile(segment) {
// TODO: round to coordinate to meter precision
const geom = this.geojsonFormat.writeGeometry(segment.getGeometry());
const geometry = segment.getGeometry();
if (geometry.getCoordinates().length != 2) {
throw new Error('SwisstopoProfiler requires a segment with exactly 2 coordinates');
}
const geom = this.geojsonFormat.writeGeometry(geometry);
const request = await fetch(this.url, {

@@ -24,6 +27,12 @@ method: 'POST',

},
body: `geom=${geom}&sr=2056&offset=1`
body: `geom=${geom}&sr=2056&offset=1&distinct_points=true`
});
const profile = await request.json();
segment.set('profile', profile.map(swisstopoToXYZM.bind(null, this.projection)));
const profile = (await request.json()).map(swisstopoToXYZM.bind(null, this.projection));
// Despite the fact that the distinct_points parameter is set and the passed coordinates
// must not be modified, the API rounds the coordinates.
// Therefore, we need to update the first and last coordinates of the profile with the
// original coordinates.
profile.at(0).splice(0, 2, ...geometry.getCoordinateAt(0));
profile.at(-1).splice(0, 2, ...geometry.getCoordinateAt(-1));
segment.set('profile', profile);
}

@@ -34,2 +43,2 @@ }

}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU3dpc3N0b3BvUHJvZmlsZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvcHJvZmlsZXIvU3dpc3N0b3BvUHJvZmlsZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxhQUFhLE1BQU0sc0JBQXNCLENBQUM7QUFDakQsT0FBTyxF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BQUMsRUFBRSxHQUFHLFFBQVEsQ0FBQyxlQUFlLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUMzRCxPQUFPLENBQUMsRUFBRSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsTUFBTSxDQUFDLENBQUMsRUFBRSxDQUFDLEVBQUUsR0FBRyxRQUFRLENBQUMsZUFBZSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUU3RCxPQUFPLENBQUMsR0FBRyxDQUFDLFNBQVMsRUFBRSxPQUFPLENBQUMsQ0FBQztJQUNsQyxDQUFDO0NBQ0Y7QUFFRCxTQUFTLGVBQWUsQ0FBQyxVQUEwQixFQUFFLENBQXVCO0lBQzFFLE9BQU8sU0FBUyxDQUFDLENBQUMsQ0FBQyxDQUFDLE9BQU8sRUFBRSxDQUFDLENBQUMsUUFBUSxFQUFFLENBQUMsQ0FBQyxJQUFJLENBQUMsSUFBSSxFQUFFLENBQUMsQ0FBQyxJQUFJLENBQUMsRUFBRSxXQUFXLEVBQUUsVUFBVSxDQUFDLENBQUM7QUFDMUYsQ0FBQyJ9
{
"name": "@geoblocks/edittrack",
"version": "2.0.0-beta.5",
"version": "2.0.0-beta.6",
"description": "Geoblocks edittrack",

@@ -43,4 +43,4 @@ "scripts": {

"@types/mocha": "10.0.6",
"@typescript-eslint/eslint-plugin": "7.6.0",
"@typescript-eslint/parser": "7.6.0",
"@typescript-eslint/eslint-plugin": "7.7.0",
"@typescript-eslint/parser": "7.7.0",
"chai": "5.1.0",

@@ -47,0 +47,0 @@ "eslint": "8.57.0",

@@ -40,4 +40,7 @@ import GeoJSONFormat from 'ol/format/GeoJSON.js';

async computeProfile(segment: Feature<LineString>): Promise<void> {
// TODO: round to coordinate to meter precision
const geom = this.geojsonFormat.writeGeometry(segment.getGeometry());
const geometry = segment.getGeometry();
if (geometry.getCoordinates().length != 2) {
throw new Error('SwisstopoProfiler requires a segment with exactly 2 coordinates');
}
const geom = this.geojsonFormat.writeGeometry(geometry);

@@ -49,6 +52,15 @@ const request = await fetch(this.url, {

},
body: `geom=${geom}&sr=2056&offset=1`
body: `geom=${geom}&sr=2056&offset=1&distinct_points=true`
});
const profile = await request.json();
segment.set('profile', profile.map(swisstopoToXYZM.bind(null, this.projection)));
const profile = (await request.json()).map(swisstopoToXYZM.bind(null, this.projection));
// Despite the fact that the distinct_points parameter is set and the passed coordinates
// must not be modified, the API rounds the coordinates.
// Therefore, we need to update the first and last coordinates of the profile with the
// original coordinates.
profile.at(0).splice(0, 2, ...geometry.getCoordinateAt(0));
profile.at(-1).splice(0, 2, ...geometry.getCoordinateAt(-1));
segment.set('profile', profile);
}

@@ -55,0 +67,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc