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
Polygons with holes? #464
Comments
Hi @pcace - polygons with holes are currently still unsupported (sadly!), because most of the operations in the geom package are relying on a single boundary representation and also because, personally, I had only rare use for them. However, I've got some old implementation which I've been meaning to re-integrate and at least add support for those operators which make sense. Technically, the best way for that will be to define a separate type of polygon, rather than complicating the existing setup. Let me think about this for a few days & I will report back ASAP... |
- add complexPolygon() factory fn - add bounds() & centroid() impls
) BREAKING CHANGE: update path related ctors & functions - add `subPaths` argument for Path ctor/factory fn - rename `Path.add()` => `Path.addSegments()` - add `Path.addSubPaths()` - update `Path.toHiccup()` to include sub-paths - update `pathFromSvg()` to always return a single path only - sub-paths are included in main path now - update impls for following ops to also process sub-paths: - bounds() - rotate() - scale() - simplify() - translate() - transform() - transformVertices()
- add implementations for: - arcLength() - area() - asPath() - closestPoint() - convexHull() - edges() - flip() - pointInside() - resample() - rotate() - scale() - simplify() - subdivCurve() - transform() - transformVertices() - translate() - vertices() - add tests
…464) BREAKING CHANGE: update asPolygon() to return array of polylines - add/update impls for complexpoly & path to produce multiple results - update other internal callsites - update tests
@pcace Just FYI, posted an update: https://mastodon.thi.ng/@toxi/112383330661412657 |
@postspectacular Thank you so much!!! |
@pcace Just released v7.0.0 with support for polygons with holes and paths with holes (or multiple curves in general). Please see full changelog here: https://github.com/thi-ng/umbrella/blob/develop/packages/geom/CHANGELOG.md#700-2024-05-08 Most of the polymorphic geom operators also support these new/updated shape types, but please let me know if you run into any problems... |
That is an issue I currently have no real solution for, other than having to manually cast the result of some of these functions, like so: // add type-only import
import { type Polygon } from "@thi.ng/geom";
const combined = complexPolygon(poly1, [<Polygon>flip(poly2)]));
// or via the different syntax:
const combined = complexPolygon(poly1, [flip(poly2) as Polygon])); This is part of the https://en.wikipedia.org/wiki/Expression_problem (esp. in typed languages) and I've been trying a few approaches to improve that, but none of them are truly "watertight" and/or as extensible as these polymorphic functions are intended to be... e.g. if had a custom shape type defined yourself, you can add an implementation for it via e.g. |
I appreciate your suggestion. 🙏 |
Hi there,
i am currently trying to convert geojsons to svg to be able to print them in a webapplication.
The Problem i am facing is that Polygon does not support holes (https://docs.thi.ng/umbrella/geom/#md:shape-types)
what i do is to is basically this:
this kind of works, but returns all holes from the geojson as additional polygons, overlaying the others.
How can i turn these polygons into holes?
Thanks a lot!!
The text was updated successfully, but these errors were encountered: