https://github.com/verekia/polydraw-support
🔺 PolyDraw.app | Issues and Feedback
https://github.com/verekia/polydraw-support
Last synced: 7 months ago
JSON representation
🔺 PolyDraw.app | Issues and Feedback
- Host: GitHub
- URL: https://github.com/verekia/polydraw-support
- Owner: verekia
- Created: 2023-11-01T10:38:30.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-01T15:49:53.000Z (almost 2 years ago)
- Last Synced: 2025-02-06T10:46:15.014Z (8 months ago)
- Homepage: https://polydraw.app
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🔺 PolyDraw.app
[**PolyDraw**](https://polydraw.app) is currently not open source, but you can submit issues and feedback in this repository.
## Resolving your JSON data
Here is what a PolyDraw exported JSON file looks like:
```json
{
"points": [
{ "id": "IXXp8", "x": 21.4, "y": 54.6 },
{ "id": "h8axL", "x": 25.4, "y": 71.6 },
{ "id": "A8LYy", "x": 42.8, "y": 82.4 },
{ "id": "05EtD", "x": 69.6, "y": 81.2 }
],
"pointGroups": [
{
"id": "G5kjN",
"pointIds": ["IXXp8", "h8axL", "A8LYy", "05EtD"],
"name": "forest1"
}
],
"superGroups": [{ "pointGroupIds": ["G5kjN"], "name": "forests" }]
}
```In your application code, you will likely want to resolve `pointIds` and `pointGroupIds` to have direct access to the point and point group objects. Here is a way to do it that removes `id`, `pointIds`, and `pointGroupIds` fields from the final object (remove the `!` operators if you are not using TypeScript).
```ts
import rawData from './raw-data.json'const idToPoint = new Map(rawData.points.map(({ id, ...point }) => [id, point]))
const idToPointGroup = new Map(
rawData.pointGroups.map(({ id, pointIds, ...pointGroup }) => [
id,
{ ...pointGroup, points: pointIds.map(id => idToPoint.get(id)!) },
]),
)const resolvedData = {
points: Array.from(idToPoint.values()),
pointGroups: rawData.pointGroups.map(({ id, pointIds, ...pointGroup }) => ({
...pointGroup,
points: pointIds.map(id => idToPoint.get(id)!),
})),
superGroups: rawData.superGroups.map(({ pointGroupIds, ...superGroup }) => ({
...superGroup,
pointGroups: pointGroupIds.map(id => idToPointGroup.get(id)!),
})),
}export default resolvedData
```