Code Monkey home page Code Monkey logo

Comments (6)

vasturiano avatar vasturiano commented on June 12, 2024

@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.

grzesebe avatar grzesebe commented on June 12, 2024

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]
          ]
        ]
      }
    }
  ]
}

image
image

@lilesper did you manage to solve it?

from three-conic-polygon-geometry.

grzesebe avatar grzesebe commented on June 12, 2024

@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.

lilesper avatar lilesper commented on June 12, 2024

Coolbeans, I'll try .reverse() ! thank you

from three-conic-polygon-geometry.

SimeonRolev avatar SimeonRolev commented on June 12, 2024

@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.

vasturiano avatar vasturiano commented on June 12, 2024

@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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.