-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JIDEA-168: component tests for globe #93
Changes from all commits
6ef9f79
6dc3984
b21f78f
af2745a
4994839
ca70aaa
e0381e5
9b857d9
52ea4cc
d62f350
d54c25b
66aacaf
5e1c3fd
45c0993
8fbdee6
533af58
5d38a0c
4ecbd9a
27e8519
3f56bba
bc8e27a
7083591
302cb71
88058db
d682944
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* eslint-disable no-console */ | ||
/* eslint-disable node/prefer-global/process */ | ||
import * as fs from "node:fs"; | ||
|
||
// Get the file path from command-line arguments | ||
const filePath = process.argv[2]; | ||
|
||
if (!filePath) { | ||
console.error("Please provide the file path as a command-line argument."); | ||
process.exit(1); | ||
} | ||
|
||
// Load the GeoJSON file | ||
const fileContent = fs.readFileSync(filePath, "utf8"); | ||
|
||
// Extract the map object from the file content | ||
// eslint-disable-next-line no-eval | ||
const map = eval(fileContent.replace("export default", "")); | ||
|
||
// Function to reverse the winding order of coordinates | ||
function reverseWindingOrder(geometry) { | ||
if (geometry.type === "Polygon") { | ||
geometry.coordinates = geometry.coordinates.map(ring => ring.reverse()); | ||
} else if (geometry.type === "MultiPolygon") { | ||
geometry.coordinates = geometry.coordinates.map(polygon => polygon.map(ring => ring.reverse())); | ||
} | ||
} | ||
|
||
// Process each feature in the map | ||
map.features.forEach((feature) => { | ||
reverseWindingOrder(feature.geometry); | ||
}); | ||
|
||
// Convert the map object back to a string | ||
const updatedFileContent = `const map = ${JSON.stringify(map, null, 2)};\nexport default map;`; | ||
|
||
// Save the updated content back to the file | ||
fs.writeFileSync(`reversed_${filePath}`, updatedFileContent, "utf8"); | ||
|
||
console.log("Winding order reversed successfully."); | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Required by https://www.amcharts.com/docs/v5/getting-started/integrations/jest/ | ||
module.exports = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this file needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because this says so: https://www.amcharts.com/docs/v5/getting-started/integrations/jest/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah. Might be worth sticking in a comment to that effect as I for one will definitely forget that. |
||
presets: [ | ||
["@babel/preset-env", { targets: { node: "current" } }], | ||
"@babel/preset-typescript", | ||
], | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you could do this as a dynamic import. But it doesn't really matter!