GitXplorerGitXplorer
v

polydraw

public
5 stars
0 forks
0 issues

Commits

List of commits on branch main.
Unverified
736e28c102f910018d4614209211747139376f6a

feat: nginx, deploy script, next 15, husky

vverekia committed 2 months ago
Unverified
7a08e542dce759f27c6b192972c4166168c2b509

perf: use bun 1.1.36

vverekia committed 2 months ago
Unverified
f68eaa54af38260d1d4a9380fe56efb3391e19cf

fix: remove export mode

vverekia committed 2 months ago
Unverified
8d6e44685e2428bd79d08143983fe25e90428d2b

feat: dockerize

vverekia committed 2 months ago
Unverified
6c6da69c9d446c7cac4ab748b6c0196c5ddd4e52

fx: fix github link

vverekia committed 9 months ago
Unverified
5f21ab16f728d6d66ec8e139fdcb1f5a4d5360a4

docs: update readme

vverekia committed 9 months ago

README

The README file for this repository.

🔺 PolyDraw

Use it on polydraw.v1v2.io

Resolving your JSON data

Here is what a PolyDraw exported JSON file looks like:

{
  "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).

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

Known issues

  • Custom JSON keeps showing the previous value of other points.
  • Number inputs behave weird sometimes, cannot type dot.