Comments (6)
@lilesper thanks for reaching out.
There's a chance you may have a reverse wound polygon there, so it's filling the outer side of the sphere instead. Could you try and .reverse()
the coordinates array to see if you get a different result?
from three-conic-polygon-geometry.
I have a similar issue.
It happens with any JSON generated with https://geojson.io/
but with examples downloaded from https://geojson-maps.ash.ms/, everything works fine
Example JSON:
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[-289.6875, -2.811371193331128],
[-291.09375, -20.632784250388013],
[-285.46875, -29.535229562948444],
[-271.40625, -34.30714385628803],
[-255.9375, -36.597889133070204],
[-236.25, -31.95216223802496],
[-233.43749999999997, -15.28418511407642],
[-233.43749999999997, -7.01366792756663],
[-237.65625, 5.61598581915534],
[-243.28125, 13.923403897723347],
[-248.90624999999997, 24.5271348225978],
[-241.875, 34.30714385628804],
[-241.875, 50.736455137010665],
[-250.31250000000003, 54.97761367069628],
[-289.6875, -2.811371193331128]
]
]
}
}
]
}
@lilesper did you manage to solve it?
from three-conic-polygon-geometry.
@lilesper
.reverse()
did the trick, but do you know how can we programmatically detect if we are dealing with reverse-wound polygon? I have a bunch of data and some of it is correct so reversing every array messes things up.
from three-conic-polygon-geometry.
Coolbeans, I'll try .reverse() ! thank you
from three-conic-polygon-geometry.
@vasturiano Same problem here. Is there a simple way to get the smaller mesh by area/volume? Something like:
const coordinates = polygonGeoJson.features[0].geometry.coordinates;
const cones1 = new ConicPolygonGeometry(coordinates, 0, 49, false, true, false)
const reversedCoords = [...coordinates]
reversedCoords[0].reverse();
const cones2 = new ConicPolygonGeometry(reversedCoords, 0, 49, false, true, false)
const cones = cones1.getArea() > cones2.getArea() ? cones2 : cones1
I don't find a getArea()
method, just a suggestion on how to programatically decide whether to reverse the coords ...
from three-conic-polygon-geometry.
@SimeonRolev calculating the area of a polygon is not a trivial operation, and also shouldn't be the responsibility of this module as it would incur a performance penalty. The best is if the consumer of this module decides or not to do this verification and reversal before the geojson data is input to it.
I'd recomend d3-geo's geoArea as a utility to perform this calculation.
from three-conic-polygon-geometry.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from three-conic-polygon-geometry.