Skip to content

Commit

Permalink
Merge pull request #1070 from geoadmin/develop
Browse files Browse the repository at this point in the history
New Release v1.47.1 - #patch
  • Loading branch information
ltshb authored Sep 17, 2024
2 parents 7b8ead7 + 228cdf8 commit c0ed7cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/config/baseUrl.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,4 @@ export function getVectorTilesBaseUrl() {
}

export const internalDomainRegex =
import.meta.env.VITE_APP_INTERNAL_DOMAIN_REGEX ?? /^https:\/\/[^/]*(bgdi|admin)\.ch/
import.meta.env.VITE_APP_INTERNAL_DOMAIN_REGEX ?? /^https:\/\/[^/]*(bgdi|geo\.admin)\.ch/
9 changes: 5 additions & 4 deletions src/utils/geodesicManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,19 @@ export const HALFSIZE_WEBMERCATOR = Math.PI * 6378137
*
* @param {number[][]} coords - An array of coordinates representing the polygon. The coordinates
* should be in the format [[longitude, latitude], [longitude, latitude], ...].
* @param {Boolean} isPolyline Tells if the given coords are describing a polyline (unclosed
* polygon) or a polygon. If true is given, the length will be calculated (instead of area)
* @returns {Object} An object containing the calculated area and perimeter of the polygon.
* @returns {number} Return.area - The calculated area of the polygon in square meters.
* @returns {number} Return.perimeter - The calculated perimeter of the polygon in meters.
*/
export function computePolygonPerimeterArea(coords) {
const geodesicPolygon = new PolygonArea.PolygonArea(geod, false)
export function computePolygonPerimeterArea(coords, isPolyline = false) {
const geodesicPolygon = new PolygonArea.PolygonArea(geod, isPolyline)
for (const coord of coords) {
geodesicPolygon.AddPoint(coord[1], coord[0])
}
const result = geodesicPolygon.Compute(false, true)
result.area = Math.abs(result.area)

return result
}

Expand Down Expand Up @@ -173,7 +174,7 @@ export class GeodesicGeometries {

/* The following "_calculate*" methods are helper methods of "_calculateEverything" */
_calculateGlobalProperties() {
const res = computePolygonPerimeterArea(this.coords)
const res = computePolygonPerimeterArea(this.coords, !this.isPolygon)
this.totalLength = res.perimeter
this.totalArea = res.area
if (this.hasAzimuthCircle) {
Expand Down

0 comments on commit c0ed7cf

Please sign in to comment.